Skip to content

Commit 6f54bd6

Browse files
committed
WIP: Fix tests were failing
1 parent 32c81f8 commit 6f54bd6

File tree

3 files changed

+53
-39
lines changed

3 files changed

+53
-39
lines changed

tests/unit/components/ContentNode/Column.spec.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@ describe('Column', () => {
2424
expect(wrapper.classes()).toContain('column');
2525
expect(wrapper.text()).toBe('Default Content');
2626
expect(wrapper.vm.style).toHaveProperty('--col-span', null);
27-
wrapper.setProps({
28-
span: 5,
27+
});
28+
29+
it('renders with span', () => {
30+
const wrapper = createWrapper({
31+
propsData: {
32+
span: 5,
33+
},
2934
});
3035
expect(wrapper.vm.style).toHaveProperty('--col-span', 5);
3136
});

tests/unit/components/DocumentationTopic/Summary/LanguageSwitcher.spec.js

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,59 +52,61 @@ describe('LanguageSwitcher', () => {
5252
});
5353

5454
it('renders a summary `Section`', () => {
55-
expect(wrapper.is('.language')).toBe(true);
55+
expect(wrapper.classes()).toContain('language');
5656

57-
const section = wrapper.find(Section);
57+
const section = wrapper.findComponent(Section);
5858
expect(section.exists()).toBe(true);
59-
expect(section.classes('language')).toBe(true);
59+
expect(section.classes()).toContain('language');
6060
expect(section.attributes('role')).toBe('complementary');
6161
expect(section.attributes('aria-label')).toBe('language');
6262
});
6363

6464
it('renders a summary `Title` of "Language"', () => {
65-
const title = wrapper.find(Title);
65+
const title = wrapper.findComponent(Title);
6666
expect(title.exists()).toBe(true);
6767
expect(title.text()).toBe('formats.colon language');
6868
});
6969

7070
it('renders a `LanguageSwitcherLink` for swift and objc', () => {
71-
const links = wrapper.findAll(LanguageSwitcherLink);
71+
const links = wrapper.findAllComponents(LanguageSwitcherLink);
7272
expect(links.length).toBe(2);
7373

74-
expect(links.at(0).classes('language-option')).toBe(true);
75-
expect(links.at(0).classes('swift')).toBe(true);
76-
expect(links.at(0).classes('active')).toBe(true);
74+
expect(links.at(0).classes()).toContain('language-option');
75+
expect(links.at(0).classes()).toContain('swift');
76+
expect(links.at(0).classes()).toContain('active');
7777
expect(links.at(0).props('url')).toBeNull();
7878
expect(links.at(0).text()).toBe(Language.swift.name);
7979

80-
expect(links.at(1).classes('language-option')).toBe(true);
81-
expect(links.at(1).classes('objc')).toBe(true);
82-
expect(links.at(1).classes('active')).toBe(false);
80+
expect(links.at(1).classes()).toContain('language-option');
81+
expect(links.at(1).classes()).toContain('objc');
82+
expect(links.at(1).classes()).not.toContain('active');
8383
expect(links.at(1).props('url').startsWith('/documentation/foo?')).toBe(true);
8484
expect(links.at(1).props('url')).toContain('language=objc');
8585
expect(links.at(1).props('url')).toContain('context=foo');
8686
expect(links.at(1).text()).toBe(Language.objectiveC.name);
8787
});
8888

89-
it('renders the right links when the paths differ', () => {
89+
it('renders the right links when the paths differ', async () => {
9090
wrapper.setProps({
9191
...propsData,
9292
interfaceLanguage: Language.objectiveC.key.api,
9393
objcPath: 'documentation/bar',
9494
});
9595

96-
const links = wrapper.findAll(LanguageSwitcherLink);
96+
await wrapper.vm.$nextTick();
97+
98+
const links = wrapper.findAllComponents(LanguageSwitcherLink);
9799
expect(links.length).toBe(2);
98100

99-
expect(links.at(0).classes('language-option')).toBe(true);
100-
expect(links.at(0).classes('swift')).toBe(true);
101-
expect(links.at(0).classes('active')).toBe(false);
101+
expect(links.at(0).classes()).toContain('language-option');
102+
expect(links.at(0).classes()).toContain('swift');
103+
expect(links.at(0).classes()).not.toContain('active');
102104
expect(links.at(0).props('url')).toBe('/documentation/foo?context=foo');
103105
expect(links.at(0).text()).toBe(Language.swift.name);
104106

105-
expect(links.at(1).classes('language-option')).toBe(true);
106-
expect(links.at(1).classes('objc')).toBe(true);
107-
expect(links.at(1).classes('active')).toBe(true);
107+
expect(links.at(1).classes()).toContain('language-option');
108+
expect(links.at(1).classes()).toContain('objc');
109+
expect(links.at(1).classes()).toContain('active');
108110
expect(links.at(1).props('url')).toBeNull();
109111
expect(links.at(1).text()).toBe(Language.objectiveC.name);
110112
});
@@ -119,7 +121,7 @@ describe('LanguageSwitcher', () => {
119121
},
120122
propsData,
121123
});
122-
const links = wrapper.findAll(LanguageSwitcherLink);
124+
const links = wrapper.findAllComponents(LanguageSwitcherLink);
123125
expect(links.length).toBe(2);
124126

125127
expect(links.at(0).props('url')).toEqual(null);
@@ -134,11 +136,11 @@ describe('LanguageSwitcher', () => {
134136
provide: { store },
135137
});
136138

137-
let link = wrapper.findAll(LanguageSwitcherLink).at(1);
139+
let link = wrapper.findAllComponents(LanguageSwitcherLink).at(1);
138140
link.vm.$emit('click');
139141
expect(store.setPreferredLanguage).toBeCalledWith(Language.objectiveC.key.url);
140142

141-
link = wrapper.findAll(LanguageSwitcherLink).at(0);
143+
link = wrapper.findAllComponents(LanguageSwitcherLink).at(0);
142144
link.vm.$emit('click');
143145
expect(store.setPreferredLanguage).toBeCalledWith(Language.swift.key.url);
144146
});
@@ -154,7 +156,7 @@ describe('LanguageSwitcher', () => {
154156
},
155157
});
156158

157-
wrapper.findAll(LanguageSwitcherLink).at(1).vm.$emit('click');
159+
wrapper.findAllComponents(LanguageSwitcherLink).at(1).vm.$emit('click');
158160
expect(store.setPreferredLanguage).not.toBeCalled();
159161
});
160162
});

tests/unit/components/Tutorial/Hero.spec.js

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,15 @@ describe('Hero', () => {
125125
});
126126
});
127127

128-
it('displays the call-to-action modal when the link is clicked', () => {
128+
it('displays the call-to-action modal when the link is clicked', async () => {
129129
const wrapper = mountWithProps();
130130
const link = wrapper.find('a.call-to-action');
131-
expect(wrapper.find(Asset).isVisible()).toBe(false);
131+
expect(wrapper.find(Asset).exists()).toBe(true);
132+
expect(wrapper.find(GenericModal).props('visible')).toBe(false);
133+
132134
link.trigger('click');
133-
expect(wrapper.find(Asset).isVisible()).toBe(true);
135+
await wrapper.vm.$nextTick();
136+
134137
const modal = wrapper.find(GenericModal);
135138
expect(modal.props()).toHaveProperty('visible', true);
136139
});
@@ -172,21 +175,25 @@ describe('Hero', () => {
172175
global.Element.prototype.querySelector = querySelector;
173176
};
174177

175-
it('does not pause if play returned undefined', (done) => {
176-
withPlayReturning(undefined, async () => {
177-
const link = wrapper.find('a.call-to-action');
178-
link.trigger('click');
179-
expect(wrapper.find(Asset).isVisible()).toBe(true);
178+
it('does not pause if play returned undefined', async () => {
179+
await new Promise((resolve) => {
180+
withPlayReturning(undefined, async () => {
181+
const link = wrapper.find('a.call-to-action');
182+
link.trigger('click');
183+
await wrapper.vm.$nextTick();
184+
185+
expect(wrapper.find(GenericModal).props('visible')).toBe(true);
180186

181-
const asset = wrapper.find(Asset);
182-
asset.vm.$emit('videoEnded');
187+
const asset = wrapper.find(Asset);
188+
asset.vm.$emit('videoEnded');
183189

184-
// Wait for the `playPromise.then` to be executed.
185-
await wrapper.vm.$nextTick();
190+
// Wait for the `playPromise.then` to be executed.
191+
await wrapper.vm.$nextTick();
186192

187-
expect(pauseMock).not.toHaveBeenCalled();
193+
expect(pauseMock).not.toHaveBeenCalled();
188194

189-
done();
195+
resolve();
196+
});
190197
});
191198
});
192199
});

0 commit comments

Comments
 (0)