From 10f52e3211c3fd9af8ea6e2d7fb5ef6bb00e3f8e Mon Sep 17 00:00:00 2001 From: milesillsley Date: Mon, 18 Jun 2018 14:18:08 +0100 Subject: [PATCH] Test: clearDirectory --- src/comparisonActions.test.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/comparisonActions.test.js b/src/comparisonActions.test.js index 6147c4f..528f21a 100644 --- a/src/comparisonActions.test.js +++ b/src/comparisonActions.test.js @@ -2,7 +2,8 @@ import { createDirectories, - fetchRemoteComparisonImages + fetchRemoteComparisonImages, + clearDirectory } from './comparisonActions'; import { deleteRemote, fetchRemote } from './remoteActions'; @@ -71,4 +72,20 @@ describe('The comparions actions', () => { expect(deleteRemote.mock.calls.length).toBe(1); expect(fetchRemote.mock.calls.length).toBe(2); }); + + it('clears the generated diffs directory', async () => { + mockFs = { + readdirSync: () => ['1', '2', '3', '4', '5', '6'], + unlinkSync: jest.fn() + }; + + const config = { + baseline: './baselineTest', + latest: './latestTest', + generatedDiffs: './generatedDiffsTest' + }; + + await clearDirectory(mockFs, config); + expect(mockFs.unlinkSync.mock.calls.length).toBe(6); + }); });