@@ -42,53 +42,28 @@ function createMockStore() {
4242 } ;
4343}
4444
45- describe ( 'workspace type selection' , ( ) => {
46- it ( 'should derive workspace types from RESOURCE_TYPE_METADATA workspaceSupported flag' , ( ) => {
47- const derivedTypes = Object . values ( ResourceType ) . filter (
48- ( type ) => RESOURCE_TYPE_METADATA [ type ] . workspaceSupported === true
49- ) ;
50- expect ( derivedTypes ) . toContain ( ResourceType . NamedValue ) ;
51- expect ( derivedTypes ) . toContain ( ResourceType . Tag ) ;
52- expect ( derivedTypes ) . toContain ( ResourceType . Backend ) ;
53- expect ( derivedTypes ) . toContain ( ResourceType . Logger ) ;
54- expect ( derivedTypes ) . toContain ( ResourceType . Group ) ;
55- expect ( derivedTypes ) . toContain ( ResourceType . Diagnostic ) ;
56- expect ( derivedTypes ) . toContain ( ResourceType . PolicyFragment ) ;
57- expect ( derivedTypes ) . toContain ( ResourceType . Product ) ;
58- expect ( derivedTypes ) . toContain ( ResourceType . Api ) ;
59- expect ( derivedTypes ) . toContain ( ResourceType . Subscription ) ;
60- expect ( derivedTypes ) . toContain ( ResourceType . GlobalSchema ) ;
61- expect ( derivedTypes ) . toContain ( ResourceType . Documentation ) ;
62- expect ( derivedTypes ) . toHaveLength ( 12 ) ;
63- } ) ;
45+ describe ( 'workspace-extractor' , ( ) => {
46+ describe ( 'extractWorkspaces' , ( ) => {
47+ it ( 'should iterate only workspaceSupported types in enum order' , async ( ) => {
48+ const client = createMockClient ( ) ;
49+ const seenTypes : ResourceType [ ] = [ ] ;
50+ // eslint-disable-next-line require-yield
51+ client . listResources = async function * ( _ctx : ApimServiceContext , type : ResourceType ) {
52+ seenTypes . push ( type ) ;
53+ } ;
54+ const store = createMockStore ( ) ;
55+ const filter : FilterConfig = { workspaceNames : [ 'ws-1' ] } ;
6456
65- it ( 'should not include non-workspace types' , ( ) => {
66- const derivedTypes = Object . values ( ResourceType ) . filter (
67- ( type ) => RESOURCE_TYPE_METADATA [ type ] . workspaceSupported === true
68- ) ;
69- expect ( derivedTypes ) . not . toContain ( ResourceType . ServicePolicy ) ;
70- expect ( derivedTypes ) . not . toContain ( ResourceType . ProductApi ) ;
71- expect ( derivedTypes ) . not . toContain ( ResourceType . GatewayApi ) ;
72- expect ( derivedTypes ) . not . toContain ( ResourceType . ApiPolicy ) ;
73- } ) ;
57+ await extractWorkspaces (
58+ client , store , testContext , '/output' , filter
59+ ) ;
7460
75- it ( 'should return types in enum declaration order' , ( ) => {
76- const derivedTypes = Object . values ( ResourceType ) . filter (
77- ( type ) => RESOURCE_TYPE_METADATA [ type ] . workspaceSupported === true
78- ) ;
79- // Enum order: NamedValue, Tag, ..., Backend, Logger, Group, Diagnostic, PolicyFragment, ..., Product, Api, ..., Subscription, GlobalSchema, ..., Documentation
80- const namedValueIdx = derivedTypes . indexOf ( ResourceType . NamedValue ) ;
81- const tagIdx = derivedTypes . indexOf ( ResourceType . Tag ) ;
82- const apiIdx = derivedTypes . indexOf ( ResourceType . Api ) ;
83- const subscriptionIdx = derivedTypes . indexOf ( ResourceType . Subscription ) ;
84- expect ( namedValueIdx ) . toBeLessThan ( tagIdx ) ;
85- expect ( tagIdx ) . toBeLessThan ( apiIdx ) ;
86- expect ( apiIdx ) . toBeLessThan ( subscriptionIdx ) ;
87- } ) ;
88- } ) ;
61+ const expectedTypes = Object . values ( ResourceType ) . filter (
62+ ( type ) => RESOURCE_TYPE_METADATA [ type ] . workspaceSupported === true
63+ ) ;
64+ expect ( seenTypes ) . toEqual ( expectedTypes ) ;
65+ } ) ;
8966
90- describe ( 'workspace-extractor' , ( ) => {
91- describe ( 'extractWorkspaces' , ( ) => {
9267 it ( 'should skip extraction when no workspace names in filter' , async ( ) => {
9368 const client = createMockClient ( ) ;
9469 const store = createMockStore ( ) ;
0 commit comments