2022-01-31 21:15:44 +00:00
|
|
|
import initStoryshots, { Stories2SnapsConverter } from '@storybook/addon-storyshots';
|
|
|
|
import { render } from '@testing-library/react-native';
|
2017-08-23 00:27:25 +00:00
|
|
|
|
2021-11-16 15:59:58 +00:00
|
|
|
jest.mock('rn-fetch-blob', () => ({
|
|
|
|
fs: {
|
|
|
|
dirs: {
|
|
|
|
DocumentDir: '/data/com.rocket.chat/documents',
|
|
|
|
DownloadDir: '/data/com.rocket.chat/downloads'
|
|
|
|
},
|
|
|
|
exists: jest.fn(() => null)
|
|
|
|
},
|
|
|
|
fetch: jest.fn(() => null),
|
|
|
|
config: jest.fn(() => null)
|
|
|
|
}));
|
|
|
|
|
|
|
|
jest.mock('react-native-file-viewer', () => ({
|
|
|
|
open: jest.fn(() => null)
|
|
|
|
}));
|
|
|
|
|
2020-11-04 16:53:44 +00:00
|
|
|
jest.mock('../app/lib/database', () => jest.fn(() => null));
|
|
|
|
global.Date.now = jest.fn(() => new Date('2019-10-10').getTime());
|
|
|
|
|
2022-01-31 21:15:44 +00:00
|
|
|
const converter = new Stories2SnapsConverter();
|
|
|
|
|
|
|
|
initStoryshots({
|
2022-02-01 13:29:16 +00:00
|
|
|
test: ({ story, context }) => {
|
2022-01-31 21:15:44 +00:00
|
|
|
const snapshotFilename = converter.getSnapshotFileName(context);
|
|
|
|
const storyElement = story.render();
|
|
|
|
const { update, toJSON } = render(storyElement);
|
|
|
|
update(storyElement);
|
2022-02-01 13:29:16 +00:00
|
|
|
const json = toJSON();
|
|
|
|
expect(JSON.stringify(json)).toMatchSpecificSnapshot(snapshotFilename);
|
2022-01-31 21:15:44 +00:00
|
|
|
}
|
|
|
|
});
|