Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement support for jsx/tsx preview files
- Loading branch information
Showing
3 changed files
with
38 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
addons/storyshots/storyshots-core/src/frameworks/configure.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { getPreviewFile } from './configure'; | ||
|
||
// eslint-disable-next-line global-require, jest/no-mocks-import | ||
jest.mock('fs', () => require('../../../../../__mocks__/fs')); | ||
const setupFiles = (files: Record<string, string>) => { | ||
// eslint-disable-next-line no-underscore-dangle, global-require | ||
require('fs').__setMockFiles(files); | ||
}; | ||
|
||
it.each` | ||
filepath | ||
${'preview.ts'} | ||
${'preview.tsx'} | ||
${'preview.js'} | ||
${'preview.jsx'} | ||
`('resolves a valid preview file from $filepath', ({ filepath }) => { | ||
setupFiles({ [`test/${filepath}`]: 'true' }); | ||
|
||
expect(getPreviewFile('test/')).toEqual(`test/${filepath}`); | ||
}); | ||
|
||
it('returns false when none of the paths exist', () => { | ||
setupFiles(Object.create(null)); | ||
|
||
expect(getPreviewFile('test/')).toEqual(false); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters