1 | import path from 'path'
|
2 | import fs from 'fs'
|
3 |
|
4 | export function expectedFixture (fixtureFolder: string, fixtureName: string) {
|
5 | const fixturePath = path.join(fixtureFolder, fixtureName)
|
6 | const expectedPath = path.join(fixtureFolder, `${fixtureName}.expected`)
|
7 |
|
8 | expect(fs.readFileSync(fixturePath, 'utf8')).toEqual(fs.readFileSync(expectedPath, 'utf8'))
|
9 | }
|
10 |
|
11 | export function cleanup (fixturePaths: Array<string>) {
|
12 | for (let fixturePath of fixturePaths) {
|
13 | let fullPath = fixture(fixturePath)
|
14 | if (fs.existsSync(fullPath)) {
|
15 | fs.unlinkSync(fullPath)
|
16 | }
|
17 | }
|
18 | }
|
19 |
|
20 | export function fixture (folder: string): string {
|
21 | return path.join(__dirname, 'fixtures', folder)
|
22 | }
|