11import { ScopeDefSample } from '../../components/__tests-data__/scopes' ;
22import { ContextSingleton } from '../../utils/context' ;
3- import { getGroupName , getGroupsForScope , getStepInto } from '../scope' ;
3+ import { getGroupName , getGroupsForScope , getStepInto , resolveGroupTypes } from '../scope' ;
44
55describe ( 'Check enabled groups' , ( ) => {
66 beforeEach ( ( ) => {
@@ -9,14 +9,15 @@ describe('Check enabled groups', () => {
99
1010 it ( 'should get group from scope' , ( ) => {
1111 let groups = getGroupsForScope ( 'cluster' , ScopeDefSample ) ;
12- expect ( groups ) . toEqual ( [ 'none' ] ) ;
12+ expect ( groups ) . toEqual ( [ 'none' , 'auto' ] ) ;
1313
1414 groups = getGroupsForScope ( 'host' , ScopeDefSample ) ;
15- expect ( groups ) . toEqual ( [ 'none' , 'clusters' , 'zones' , 'clusters+zones' ] ) ;
15+ expect ( groups ) . toEqual ( [ 'none' , 'auto' , ' clusters', 'zones' , 'clusters+zones' ] ) ;
1616
1717 groups = getGroupsForScope ( 'owner' , ScopeDefSample ) ;
1818 expect ( groups ) . toEqual ( [
1919 'none' ,
20+ 'auto' ,
2021 'clusters' ,
2122 'clusters+zones' ,
2223 'clusters+hosts' ,
@@ -30,6 +31,23 @@ describe('Check enabled groups', () => {
3031 ] ) ;
3132 } ) ;
3233
34+ it ( 'should resolve auto group' , ( ) => {
35+ let group = resolveGroupTypes ( 'auto' , 'resource' , ScopeDefSample ) ;
36+ expect ( group ) . toEqual ( 'namespaces' ) ;
37+
38+ group = resolveGroupTypes ( 'auto' , 'owner' , ScopeDefSample ) ;
39+ expect ( group ) . toEqual ( 'namespaces' ) ;
40+
41+ group = resolveGroupTypes ( 'auto' , 'namespace' , ScopeDefSample ) ;
42+ expect ( group ) . toEqual ( 'none' ) ;
43+
44+ group = resolveGroupTypes ( 'auto' , 'host' , ScopeDefSample ) ;
45+ expect ( group ) . toEqual ( 'none' ) ;
46+
47+ group = resolveGroupTypes ( 'hosts' , 'resource' , ScopeDefSample ) ;
48+ expect ( group ) . toEqual ( 'hosts' ) ;
49+ } ) ;
50+
3351 it ( 'should get group name' , ( ) => {
3452 let name = getGroupName ( 'hosts' , ScopeDefSample , ( s : string ) => s ) ;
3553 expect ( name ) . toEqual ( 'Node' ) ;
0 commit comments