1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const Stories2SnapsConverter_1 = require("./Stories2SnapsConverter");
|
4 | const target = new Stories2SnapsConverter_1.Stories2SnapsConverter();
|
5 | describe('getSnapshotFileName', () => {
|
6 | it('fileName is provided - snapshot is stored in __snapshots__ dir', () => {
|
7 | const context = { fileName: 'foo.js', kind: 'kind' };
|
8 | const result = target.getSnapshotFileName(context);
|
9 | const platformAgnosticResult = result?.replace(/\\|\//g, '/');
|
10 |
|
11 | expect(platformAgnosticResult).toContain('__snapshots__/foo.storyshot');
|
12 | });
|
13 | it('fileName with multiple extensions is provided - only the last extension is replaced', () => {
|
14 | const context = { fileName: 'foo.web.stories.js', kind: 'kind' };
|
15 | const result = target.getSnapshotFileName(context);
|
16 | const platformAgnosticResult = result?.replace(/\\|\//g, '/');
|
17 |
|
18 | expect(platformAgnosticResult).toContain('__snapshots__/foo.web.stories.storyshot');
|
19 | });
|
20 | it('fileName with dir is provided - __snapshots__ dir is created inside another dir', () => {
|
21 | const context = { fileName: 'test/foo.js', kind: 'kind' };
|
22 | const result = target.getSnapshotFileName(context);
|
23 | const platformAgnosticResult = result?.replace(/\\|\//g, '/');
|
24 |
|
25 | expect(platformAgnosticResult).toContain('test/__snapshots__/foo.storyshot');
|
26 | });
|
27 | });
|
28 | describe('getPossibleStoriesFiles', () => {
|
29 | it('storyshots is provided and all the posible stories file names are returned', () => {
|
30 | const storyshots = 'test/__snapshots__/foo.web.stories.storyshot';
|
31 | const result = target.getPossibleStoriesFiles(storyshots);
|
32 | const platformAgnosticResult = result.map((path) => path.replace(/\\|\//g, '/'));
|
33 | expect(platformAgnosticResult).toEqual([
|
34 | 'test/foo.web.stories.js',
|
35 | 'test/foo.web.stories.jsx',
|
36 | 'test/foo.web.stories.ts',
|
37 | 'test/foo.web.stories.tsx',
|
38 | 'test/foo.web.stories.mdx',
|
39 | ]);
|
40 | });
|
41 | });
|