Update tests for extractArchive

This commit is contained in:
Nick Playfair 2021-02-02 13:12:52 +00:00
parent 5fc988ca54
commit e6718a85e1

View File

@ -10,7 +10,7 @@ const tmpDir = path.join(__dirname, 'tmp');
// getLayers
test('Promise of an array of layers from a given folder', () => {
return fileProc.getLayers2(testLayers).then(data => {
return fileProc.getLayers(testLayers).then(data => {
expect(data).toEqual(
expect.arrayContaining([
expect.objectContaining({
@ -23,22 +23,22 @@ test('Promise of an array of layers from a given folder', () => {
});
test('Non-existent folder should reject promise with error', () => {
return expect(fileProc.getLayers2('./invalid_folder')).rejects.toThrow('Layers folder does not exist.');
return expect(fileProc.getLayers('./invalid_folder')).rejects.toThrow('Layers folder does not exist.');
});
test('Folder with incorrect number of layers should reject promise with error', () => {
return expect(fileProc.getLayers2(emptyFolder)).rejects.toThrow('Layer not found.');
return expect(fileProc.getLayers(emptyFolder)).rejects.toThrow('Layer not found.');
});
// extractArchive
test('Non-existent archive should throw an error', () => {
return expect(fileProc.extractArchive('invalid.zip', tmpDir)).rejects.toThrow(Error);
expect(() => fileProc.extractArchive('invalid.zip', tmpDir).toThrow(Error));
});
test('Temp dir not existing should throw an error', () => {
return expect(fileProc.extractArchive(testGerber, './invalid_dir')).rejects.toThrow(Error);
expect(() => fileProc.extractArchive(testGerber, './invalid_dir').toThrow(Error));
});
test('Should extract archive and resolve with the number of files extracted', () => {
return expect(fileProc.extractArchive(testGerber, tmpDir)).resolves.toBe(12);
expect(() => (fileProc.extractArchive(testGerber, tmpDir).toBe(12)));
});