@@ -12,7 +12,6 @@ import TabNavigator from '@/components/ContentNode/TabNavigator.vue';
12
12
import { mount } from '@vue/test-utils' ;
13
13
import Tabnav from '@/components/Tabnav.vue' ;
14
14
import TabnavItem from '@/components/TabnavItem.vue' ;
15
- import ImageLoadingStrategy from '@/constants/ImageLoadingStrategy' ;
16
15
import { flushPromises } from '../../../../test-utils' ;
17
16
18
17
const titles = [ 'Long tab title' , 'A Longer tab title' , 'The Longest tab title' ] ;
@@ -54,9 +53,13 @@ describe('TabNavigator.spec', () => {
54
53
value : titles [ 0 ] ,
55
54
} ) ;
56
55
expect ( wrapper . findAll ( TabnavItem ) ) . toHaveLength ( 3 ) ;
57
- expect ( wrapper . find ( '.tabs-content' ) . text ( ) ) . toEqual ( 'First' ) ;
58
- // eslint-disable-next-line no-underscore-dangle
59
- expect ( wrapper . vm . _provided ) . toHaveProperty ( 'imageLoadingStrategy' , ImageLoadingStrategy . eager ) ;
56
+ const tabs = wrapper . findAll ( '.tab-container' ) ;
57
+ expect ( tabs ) . toHaveLength ( 3 ) ;
58
+ expect ( tabs . at ( 0 ) . classes ( ) ) . toContain ( 'active' ) ;
59
+ expect ( tabs . at ( 0 ) . isVisible ( ) ) . toBe ( true ) ;
60
+ expect ( tabs . at ( 1 ) . classes ( ) ) . not . toContain ( 'active' ) ;
61
+ expect ( tabs . at ( 1 ) . isVisible ( ) ) . toBe ( false ) ;
62
+ expect ( tabs . at ( 0 ) . text ( ) ) . toEqual ( 'First' ) ;
60
63
} ) ;
61
64
62
65
it ( 'sets the TabNavigator in `vertical` mode' , async ( ) => {
@@ -75,40 +78,40 @@ describe('TabNavigator.spec', () => {
75
78
await flushPromises ( ) ;
76
79
const tabnav = wrapper . find ( Tabnav ) ;
77
80
tabnav . vm . $emit ( 'input' , titles [ 1 ] ) ;
78
- expect ( wrapper . find ( '.tabs-content ' ) . text ( ) ) . toBe ( 'Second' ) ;
81
+ expect ( wrapper . find ( '.tab-container.active ' ) . text ( ) ) . toBe ( 'Second' ) ;
79
82
expect ( tabnav . props ( 'value' ) ) . toEqual ( titles [ 1 ] ) ;
80
83
} ) ;
81
84
82
85
it ( 'selects the added tab when adding a tab' , ( ) => {
83
86
const wrapper = createWrapper ( ) ;
84
- expect ( wrapper . find ( '.tabs-content ' ) . text ( ) ) . toBe ( 'First' ) ;
87
+ expect ( wrapper . find ( '.tab-container.active ' ) . text ( ) ) . toBe ( 'First' ) ;
85
88
86
89
wrapper . setProps ( { titles : longerTitles } ) ;
87
- expect ( wrapper . find ( '.tabs-content ' ) . text ( ) ) . toBe ( 'Fourth' ) ;
90
+ expect ( wrapper . find ( '.tab-container.active ' ) . text ( ) ) . toBe ( 'Fourth' ) ;
88
91
const tabnav = wrapper . find ( Tabnav ) ;
89
92
expect ( tabnav . props ( 'value' ) ) . toEqual ( longerTitles [ 3 ] ) ;
90
93
} ) ;
91
94
92
95
it ( 'selects first tab when deleting current tab' , ( ) => {
93
96
const wrapper = createWrapper ( ) ;
94
97
wrapper . setProps ( { titles : longerTitles } ) ;
95
- expect ( wrapper . find ( '.tabs-content ' ) . text ( ) ) . toBe ( 'Fourth' ) ;
98
+ expect ( wrapper . find ( '.tab-container.active ' ) . text ( ) ) . toBe ( 'Fourth' ) ;
96
99
97
100
wrapper . setProps ( { titles } ) ;
98
- expect ( wrapper . find ( '.tabs-content ' ) . text ( ) ) . toBe ( 'First' ) ;
101
+ expect ( wrapper . find ( '.tab-container.active ' ) . text ( ) ) . toBe ( 'First' ) ;
99
102
const tabnav = wrapper . find ( Tabnav ) ;
100
103
expect ( tabnav . props ( 'value' ) ) . toEqual ( titles [ 0 ] ) ;
101
104
} ) ;
102
105
103
106
it ( 'keep currently selected tab when deleting a tab' , ( ) => {
104
107
const wrapper = createWrapper ( ) ;
105
108
wrapper . setProps ( { titles : longerTitles } ) ;
106
- expect ( wrapper . find ( '.tabs-content ' ) . text ( ) ) . toBe ( 'Fourth' ) ; // Current tab
109
+ expect ( wrapper . find ( '.tab-container.active ' ) . text ( ) ) . toBe ( 'Fourth' ) ; // Current tab
107
110
108
111
const removedTitles = [ 'Long tab title' ,
109
112
'A Longer tab title' , 'added title' ] ;
110
113
wrapper . setProps ( { titles : removedTitles } ) ;
111
- expect ( wrapper . find ( '.tabs-content ' ) . text ( ) ) . toBe ( 'Fourth' ) ; // Keeps current tab
114
+ expect ( wrapper . find ( '.tab-container.active ' ) . text ( ) ) . toBe ( 'Fourth' ) ; // Keeps current tab
112
115
const tabnav = wrapper . find ( Tabnav ) ;
113
116
expect ( tabnav . props ( 'value' ) ) . toEqual ( longerTitles [ 3 ] ) ;
114
117
} ) ;
@@ -117,23 +120,23 @@ describe('TabNavigator.spec', () => {
117
120
const changedLastTab = [ 'Long tab title' ,
118
121
'A Longer tab title' , 'changed last tab' ] ;
119
122
const wrapper = createWrapper ( ) ;
120
- expect ( wrapper . find ( '.tabs-content ' ) . text ( ) ) . toBe ( 'First' ) ;
123
+ expect ( wrapper . find ( '.tab-container.active ' ) . text ( ) ) . toBe ( 'First' ) ;
121
124
wrapper . setProps ( { titles : changedLastTab } ) ;
122
- expect ( wrapper . find ( '.tabs-content ' ) . text ( ) ) . toBe ( 'Last' ) ;
125
+ expect ( wrapper . find ( '.tab-container.active ' ) . text ( ) ) . toBe ( 'Last' ) ;
123
126
let tabnav = wrapper . find ( Tabnav ) ;
124
127
expect ( tabnav . props ( 'value' ) ) . toEqual ( changedLastTab [ 2 ] ) ;
125
128
126
129
const changedFirstTab = [ 'changed first tab' ,
127
130
'A Longer tab title' , 'changed last tab' ] ;
128
131
wrapper . setProps ( { titles : changedFirstTab } ) ;
129
- expect ( wrapper . find ( '.tabs-content ' ) . text ( ) ) . toBe ( 'First' ) ;
132
+ expect ( wrapper . find ( '.tab-container.active ' ) . text ( ) ) . toBe ( 'First' ) ;
130
133
tabnav = wrapper . find ( Tabnav ) ;
131
134
expect ( tabnav . props ( 'value' ) ) . toEqual ( changedFirstTab [ 0 ] ) ;
132
135
133
136
const changedMidTab = [ 'changed first tab' ,
134
137
'changed middle tab' , 'changed last tab' ] ;
135
138
wrapper . setProps ( { titles : changedMidTab } ) ;
136
- expect ( wrapper . find ( '.tabs-content ' ) . text ( ) ) . toBe ( 'Middle' ) ;
139
+ expect ( wrapper . find ( '.tab-container.active ' ) . text ( ) ) . toBe ( 'Middle' ) ;
137
140
tabnav = wrapper . find ( Tabnav ) ;
138
141
expect ( tabnav . props ( 'value' ) ) . toEqual ( changedMidTab [ 1 ] ) ;
139
142
} ) ;
0 commit comments