2021-03-08 18:12:59 +05:30
import { GlLink , GlSprintf , GlAlert } from '@gitlab/ui' ;
2021-03-11 19:13:27 +05:30
import { shallowMount } from '@vue/test-utils' ;
2020-10-24 23:57:45 +05:30
import AncestorNotice from '~/clusters_list/components/ancestor_notice.vue' ;
import ClusterStore from '~/clusters_list/store' ;
2020-07-28 23:09:34 +05:30
describe ( 'ClustersAncestorNotice' , ( ) => {
let store ;
let wrapper ;
const createWrapper = ( ) => {
store = ClusterStore ( { ancestorHelperPath : '/some/ancestor/path' } ) ;
2021-03-08 18:12:59 +05:30
wrapper = shallowMount ( AncestorNotice , { store , stubs : { GlSprintf , GlAlert } } ) ;
2020-07-28 23:09:34 +05:30
return wrapper . vm . $nextTick ( ) ;
} ;
beforeEach ( ( ) => {
return createWrapper ( ) ;
} ) ;
afterEach ( ( ) => {
wrapper . destroy ( ) ;
} ) ;
describe ( 'when cluster does not have ancestors' , ( ) => {
beforeEach ( ( ) => {
store . state . hasAncestorClusters = false ;
return wrapper . vm . $nextTick ( ) ;
} ) ;
it ( 'displays no notice' , ( ) => {
2020-11-24 15:15:51 +05:30
expect ( wrapper . html ( ) ) . toBe ( '' ) ;
2020-07-28 23:09:34 +05:30
} ) ;
} ) ;
describe ( 'when cluster has ancestors' , ( ) => {
beforeEach ( ( ) => {
store . state . hasAncestorClusters = true ;
return wrapper . vm . $nextTick ( ) ;
} ) ;
it ( 'displays notice text' , ( ) => {
expect ( wrapper . text ( ) ) . toContain (
'Clusters are utilized by selecting the nearest ancestor with a matching environment scope. For example, project clusters will override group clusters.' ,
) ;
} ) ;
it ( 'displays link' , ( ) => {
2020-11-24 15:15:51 +05:30
expect ( wrapper . find ( GlLink ) . exists ( ) ) . toBe ( true ) ;
2020-07-28 23:09:34 +05:30
} ) ;
} ) ;
} ) ;