test(techdocs-common): cover getStaleFiles helper
Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
@@ -17,6 +17,7 @@ import mockFs from 'mock-fs';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import {
|
||||
getStaleFiles,
|
||||
getFileTreeRecursively,
|
||||
getHeadersForFileExtension,
|
||||
lowerCaseEntityTripletInStoragePath,
|
||||
@@ -99,3 +100,27 @@ describe('lowerCaseEntityTripletInStoragePath', () => {
|
||||
).toThrowError(error);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getStaleFiles', () => {
|
||||
const defaultFiles = [
|
||||
'default/Component/backstage/index.html',
|
||||
'default/Component/backstage/techdocs_metadata.json',
|
||||
'default/Component/backstage/assests/javascripts/bundle.7f4f3c92.min.js',
|
||||
'default/Component/backstage/assets/stylesheets/main.fe0cca5b.min.css',
|
||||
];
|
||||
|
||||
it('should return empty array if there is no stale file', () => {
|
||||
const oldFiles = [...defaultFiles];
|
||||
const newFiles = [...defaultFiles];
|
||||
const staleFiles = getStaleFiles(newFiles, oldFiles);
|
||||
expect(staleFiles).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('should return all stale files when they exists', () => {
|
||||
const oldFiles = [...defaultFiles, 'stale_file.png'];
|
||||
const newFiles = [...defaultFiles];
|
||||
const staleFiles = getStaleFiles(newFiles, oldFiles);
|
||||
expect(staleFiles).toHaveLength(1);
|
||||
expect(staleFiles).toEqual(expect.arrayContaining(['stale_file.png']));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user