Created
December 31, 2020 09:56
-
-
Save corocoto/617a6bbe24e47b3c54753fb79337b09f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| //correct test for https://ru.hexlet.io/courses/js-advanced-testing/lessons/files/exercise_unit task | |
| import os from 'os'; | |
| import path from 'path'; | |
| import { promises as fs } from 'fs'; | |
| import getFunction from '../functions.js'; | |
| const prettifyHTMLFile = getFunction(); | |
| // BEGIN (write your solution here) | |
| let expected; | |
| const getFixturePath = filename => path.join('__fixtures__', filename); | |
| const src = getFixturePath('before.html'); | |
| const dest = path.join(os.tmpdir(), 'before.html'); | |
| beforeAll(async () => expected = await fs.readFile(getFixturePath('after.html'), 'utf-8')); | |
| beforeEach(async () => await fs.copyFile(src, dest)); | |
| test('prettifyHTMLFile', async () => { | |
| await prettifyHTMLFile(dest); | |
| const actual = await fs.readFile(dest, 'utf-8'); | |
| expect(actual).toBe(expected); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment