Skip to content

Commit 74ed8d9

Browse files
committed
Fix Pager.spec.js
1 parent a6f395c commit 74ed8d9

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

tests/unit/components/Pager.spec.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe('Pager', () => {
4646
expect(indicators.length).toBe(propsData.pages.length);
4747
});
4848

49-
it('collapses the controllers if contentWidth is smaller than the large contentWidth + the gutters width in large viewport', () => {
49+
it('collapses the controllers if contentWidth is smaller than the large contentWidth + the gutters width in large viewport', async () => {
5050
// set large viewport
5151
window.innerWidth = BreakpointAttributes.default.large.minWidth + 1;
5252
const wrapper = shallowMount(Pager, { propsData });
@@ -55,19 +55,21 @@ describe('Pager', () => {
5555
contentWidth: BreakpointAttributes.default.large.contentWidth + GUTTERS_WIDTH + 10,
5656
},
5757
});
58+
await wrapper.vm.$nextTick();
5859

59-
expect(wrapper.classes('with-compact-controls')).toBe(false);
60+
expect(wrapper.classes()).not.toContain('with-compact-controls');
6061

6162
wrapper.setData({
6263
appState: {
6364
contentWidth: BreakpointAttributes.default.large.contentWidth + GUTTERS_WIDTH - 10,
6465
},
6566
});
67+
await wrapper.vm.$nextTick();
6668

67-
expect(wrapper.classes('with-compact-controls')).toBe(true);
69+
expect(wrapper.classes()).toContain('with-compact-controls');
6870
});
6971

70-
it('collapses the controllers if contentWidth is smaller than the medium contentWidth + the gutters width in medium viewport', () => {
72+
it('collapses the controllers if contentWidth is smaller than the medium contentWidth + the gutters width in medium viewport', async () => {
7173
// set medium viewport
7274
window.innerWidth = BreakpointAttributes.default.medium.maxWidth - 1;
7375
const wrapper = shallowMount(Pager, { propsData });
@@ -77,16 +79,18 @@ describe('Pager', () => {
7779
contentWidth: BreakpointAttributes.default.medium.contentWidth + GUTTERS_WIDTH + 10,
7880
},
7981
});
82+
await wrapper.vm.$nextTick();
8083

81-
expect(wrapper.classes('with-compact-controls')).toBe(false);
84+
expect(wrapper.classes()).not.toContain('with-compact-controls');
8285

8386
wrapper.setData({
8487
appState: {
8588
contentWidth: BreakpointAttributes.default.medium.contentWidth + GUTTERS_WIDTH - 10,
8689
},
8790
});
91+
await wrapper.vm.$nextTick();
8892

89-
expect(wrapper.classes('with-compact-controls')).toBe(true);
93+
expect(wrapper.classes()).toContain('with-compact-controls');
9094
});
9195

9296
it('collapses the controllers in small viewports', () => {
@@ -100,7 +104,7 @@ describe('Pager', () => {
100104
},
101105
});
102106

103-
expect(wrapper.classes('with-compact-controls')).toBe(true);
107+
expect(wrapper.classes()).toContain('with-compact-controls');
104108
});
105109

106110
it('renders each page using provided slots', () => {
@@ -126,33 +130,33 @@ describe('Pager', () => {
126130

127131
let pages = wrapper.findAll('.page');
128132
let indicators = wrapper.findAll('.indicator');
129-
expect(pages.at(0).classes('active')).toBe(true);
133+
expect(pages.at(0).classes()).toContain('active');
130134
expect(indicators.at(0).attributes('aria-current')).toBeTruthy();
131-
expect(pages.at(1).classes('active')).toBe(false);
135+
expect(pages.at(1).classes()).not.toContain('active');
132136
expect(indicators.at(1).attributes('aria-current')).toBeFalsy();
133-
expect(pages.at(2).classes('active')).toBe(false);
137+
expect(pages.at(2).classes()).not.toContain('active');
134138
expect(indicators.at(2).attributes('aria-current')).toBeFalsy();
135139

136140
await indicators.at(1).trigger('click');
137141

138142
pages = wrapper.findAll('.page');
139143
indicators = wrapper.findAll('.indicator');
140-
expect(pages.at(0).classes('active')).toBe(false);
144+
expect(pages.at(0).classes()).not.toContain('active');
141145
expect(indicators.at(0).attributes('aria-current')).toBeFalsy();
142-
expect(pages.at(1).classes('active')).toBe(true);
146+
expect(pages.at(1).classes()).toContain('active');
143147
expect(indicators.at(1).attributes('aria-current')).toBeTruthy();
144-
expect(pages.at(2).classes('active')).toBe(false);
148+
expect(pages.at(2).classes()).not.toContain('active');
145149
expect(indicators.at(2).attributes('aria-current')).toBeFalsy();
146150

147151
await indicators.at(2).trigger('click');
148152

149153
pages = wrapper.findAll('.page');
150154
indicators = wrapper.findAll('.indicator');
151-
expect(pages.at(0).classes('active')).toBe(false);
155+
expect(pages.at(0).classes()).not.toContain('active');
152156
expect(indicators.at(0).attributes('aria-current')).toBeFalsy();
153-
expect(pages.at(1).classes('active')).toBe(false);
157+
expect(pages.at(1).classes()).not.toContain('active');
154158
expect(indicators.at(1).attributes('aria-current')).toBeFalsy();
155-
expect(pages.at(2).classes('active')).toBe(true);
159+
expect(pages.at(2).classes()).toContain('active');
156160
expect(indicators.at(2).attributes('aria-current')).toBeTruthy();
157161
});
158162

0 commit comments

Comments
 (0)