Skip to content

Commit 4fa2a7d

Browse files
committed
test(snapshot): add basic tooltip snapshot
1 parent 6566baf commit 4fa2a7d

File tree

3 files changed

+56
-16
lines changed

3 files changed

+56
-16
lines changed

jest.config.json

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,20 @@
22
"rootDir": "./",
33
"verbose": true,
44
"snapshotResolver": "<rootDir>/snapshot-resolver.js",
5-
"restoreMocks": true,
65
"transform": {
7-
"^.+\\.test.js$": "babel-jest",
6+
"^.+\\.(test.js|js)$": "babel-jest",
87
"^.+\\.svelte$": "jest-transform-svelte"
98
},
10-
"collectCoverageFrom": [
11-
"src/**/*.svelte",
12-
"!<rootDir>/src/*.test.svelte"
13-
],
9+
"testMatch": ["<rootDir>/src/**/*.test.js"],
10+
"collectCoverage": true,
11+
"coverageReporters": ["lcov", "json-summary", "text-summary"],
12+
"collectCoverageFrom": ["<rootDir>/src/**/*.svelte", "!<rootDir>/src/*.test.svelte"],
1413
"moduleNameMapper": {
1514
"^tests/(.*)$": "<rootDir>/tests/$1"
1615
},
17-
"modulePathIgnorePatterns": [
18-
"<rootDir>/tests"
19-
],
20-
"moduleFileExtensions": [
21-
"js",
22-
"svelte"
23-
],
24-
"setupFilesAfterEnv": [
25-
"@testing-library/jest-dom/extend-expect"
26-
]
16+
"moduleFileExtensions": ["js", "svelte"],
17+
"transformIgnorePatterns": ["/node_modules/"],
18+
"setupFilesAfterEnv": ["@testing-library/jest-dom/extend-expect"],
19+
"reporters": ["default"],
20+
"testTimeout": 30000
2721
}

src/tooltip.snap.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Components: Tooltip should render the component 1`] = `
4+
<body>
5+
<div>
6+
<span
7+
class="tooltip-container"
8+
>
9+
10+
<div
11+
class="tooltip animation- top"
12+
style="min-width: NaNpx; max-width: 200px; text-align: left;"
13+
>
14+
Hello World!
15+
16+
</div>
17+
</span>
18+
</div>
19+
</body>
20+
`;

src/tooltip.test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { render } from '@testing-library/svelte';
2+
import Tooltip from './tooltip.svelte';
3+
4+
describe('Components: Tooltip', () => {
5+
let TestHarness;
6+
7+
beforeEach(() => {
8+
TestHarness = () =>
9+
render(Tooltip, {
10+
content: 'Hello World!',
11+
align: 'left',
12+
position: 'top',
13+
maxWidth: 200,
14+
style: null,
15+
theme: '',
16+
animation: '',
17+
arrow: true,
18+
autoPosition: false
19+
});
20+
});
21+
22+
it('should render the component', () => {
23+
const { container } = TestHarness();
24+
expect(container).toMatchSnapshot();
25+
});
26+
});

0 commit comments

Comments
 (0)