Skip to content

Commit

Permalink
Test: clearDirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
milesillsley committed Jun 18, 2018
1 parent 398b842 commit 10f52e3
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/comparisonActions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import {
createDirectories,
fetchRemoteComparisonImages
fetchRemoteComparisonImages,
clearDirectory
} from './comparisonActions';
import { deleteRemote, fetchRemote } from './remoteActions';

Expand Down Expand Up @@ -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);
});
});

0 comments on commit 10f52e3

Please sign in to comment.