-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathindex.ts
27 lines (24 loc) · 967 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import fs from 'fs';
import { PluginOptions, Mode } from '../../src/@types';
export const readCSSFile = (name: string): Promise<string> => new Promise((resolve) => {
fs.readFile(`${__dirname}/../css/${name}`, 'utf8', (error, data): void => {
if (error) {
resolve('');
} else {
resolve(data);
}
});
});
export const runTests = (options: PluginOptions, callback: (options: PluginOptions) => void): void => {
callback({...options, mode: Mode.combined});
callback({...options, mode: Mode.override});
callback({...options, mode: Mode.diff});
};
export const createSnapshotFileName = (baseFileName: string, testName: string, mode: string | undefined): string => {
const folder = './__snapshots__';
const extension = 'snapshot';
if (mode) {
return `${folder}/${baseFileName}/${mode}/${testName}.${extension}`;
}
return `${folder}/${baseFileName}/${testName}.${extension}`;
};