Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 59816a6

Browse files
committed
tests: update
1 parent 38174b7 commit 59816a6

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

jest.config.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
2-
"roots": ["<rootDir>/src"],
2+
"roots": [
3+
"<rootDir>/src"
4+
],
35
"transform": {
46
"^.+\\.tsx?$": "ts-jest"
57
},
@@ -14,7 +16,7 @@
1416
},
1517
"globals": {
1618
"ts-jest": {
17-
"tsConfig": "tsconfig.base.json"
19+
"tsconfig": "tsconfig.base.json"
1820
}
1921
}
2022
}

src/index.spec.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable jest/no-mocks-import */
12
import { mount, config } from '@vue/test-utils';
23
import Transitiona11y from './index';
34
import Child, { TEXT } from './__mocks__/ChildComponent';
@@ -24,7 +25,7 @@ describe('Without reduced motion', () => {
2425
});
2526

2627
expect(wrapper.is(Child)).toBe(false);
27-
expect(wrapper.contains(Child)).toBe(true);
28+
expect(wrapper.findComponent(Child).exists()).toBe(true);
2829
expect(wrapper.props().name).toBe('fade');
2930
expect(wrapper.text()).toBe(TEXT);
3031
});
@@ -48,7 +49,7 @@ describe('With reduced motion', () => {
4849
});
4950

5051
expect(wrapper.props().name).not.toBe('fade');
51-
expect(wrapper.is(Child)).toBe(true);
52+
expect(wrapper.element.tagName).toBe('SPAN');
5253
expect(wrapper.text()).toBe(TEXT);
5354
});
5455
});

src/index.ssr.spec.ts

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable jest/no-mocks-import */
12
/**
23
* @jest-environment node
34
*/
@@ -10,7 +11,18 @@ import Child, { TEXT } from './__mocks__/ChildComponent';
1011
// @ts-ignore
1112
config.stubs.transition = false;
1213

14+
let windowSpy;
15+
1316
describe('SSR', () => {
17+
beforeEach(() => {
18+
windowSpy = jest.spyOn(window, 'window', 'get');
19+
windowSpy.mockImplementation(() => undefined);
20+
});
21+
22+
afterEach(() => {
23+
windowSpy.mockRestore();
24+
});
25+
1426
test('It renders transition component', async () => {
1527
const wrapper = await renderToString(Transitiona11y, {
1628
context: {

0 commit comments

Comments
 (0)