Родитель
ed4273c508
Коммит
abafda9723
|
@ -4053,6 +4053,12 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"mock-fs": {
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/mock-fs/-/mock-fs-4.5.0.tgz",
|
||||
"integrity": "sha512-qqudNfOX7ZmX9vm1WIAU+gWlmxVNAnwY6UG3RkFutNywmRCUGP83tujP6IxX2DS1TmcaEZBOhYwDuYEmJYE+3w==",
|
||||
"dev": true
|
||||
},
|
||||
"moment": {
|
||||
"version": "2.22.1",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.22.1.tgz",
|
||||
|
|
|
@ -275,6 +275,7 @@
|
|||
"gulp-sourcemaps": "^2.6.4",
|
||||
"gulp-tslint": "^8.1.3",
|
||||
"gulp-typescript": "^4.0.2",
|
||||
"mock-fs": "^4.5.0",
|
||||
"tslint": "^5.9.1",
|
||||
"tslint-microsoft-contrib": "^5.0.3",
|
||||
"typescript": "^2.8.3",
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
import mock = require('mock-fs');
|
||||
import { FSUtils } from '../src/helpers/utils/fsUtils';
|
||||
|
||||
describe('FsUtils', function () {
|
||||
const pathToCreateEmptyFolder = "test/mock/empty-dir";
|
||||
const pathToNonEmptyDir = "test/mock/non-empty-dir";
|
||||
const dirWithIgnoredFilesPath = "test/mock/empty-dir-with-ignored-files";
|
||||
const dirWithIgnoredVscodePath = "test/mock/empty-dir-with-ignored-vscode";
|
||||
|
||||
before(() => {
|
||||
|
||||
mock({
|
||||
"test/mock/non-empty-dir": {
|
||||
'some-file.txt': 'file content here'
|
||||
},
|
||||
"test/mock/empty-dir-with-ignored-files": {
|
||||
'.vscode': {},
|
||||
'.git': {}
|
||||
},
|
||||
"test/mock/empty-dir-with-ignored-vscode": {
|
||||
'.vscode': {}
|
||||
},
|
||||
"test/mock/empty-dir": {}
|
||||
});
|
||||
});
|
||||
|
||||
after(() => {
|
||||
mock.restore();
|
||||
});
|
||||
|
||||
describe('#IsEmptyDirectoryToStartNewProject', () => {
|
||||
|
||||
it('should recognize an empty directory to start new project', async () => {
|
||||
const isEmpty = FSUtils.IsEmptyDirectoryToStartNewProject(pathToCreateEmptyFolder);
|
||||
isEmpty.should.be.true();
|
||||
});
|
||||
|
||||
it('should recognize a non-empty directory', async () => {
|
||||
const isEmpty = FSUtils.IsEmptyDirectoryToStartNewProject(pathToNonEmptyDir);
|
||||
isEmpty.should.be.false();
|
||||
});
|
||||
|
||||
it('should ignore .vscode and .git', async () => {
|
||||
const isEmpty = FSUtils.IsEmptyDirectoryToStartNewProject(dirWithIgnoredFilesPath);
|
||||
isEmpty.should.be.true();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#IsEmptyDirectory', () => {
|
||||
|
||||
it('should recognize an empty directory', async () => {
|
||||
const isEmpty = FSUtils.IsEmptyDirectory(pathToCreateEmptyFolder);
|
||||
isEmpty.should.be.true();
|
||||
});
|
||||
|
||||
it('should recognize a non-empty directory', async () => {
|
||||
const isEmpty = FSUtils.IsEmptyDirectory(pathToNonEmptyDir);
|
||||
isEmpty.should.be.false();
|
||||
});
|
||||
|
||||
it('should ignore .vscode', async () => {
|
||||
const isEmpty = FSUtils.IsEmptyDirectory(dirWithIgnoredVscodePath);
|
||||
isEmpty.should.be.true();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#exists', () => {
|
||||
const pathToNotExistingFile = "test/mock/file-1.json";
|
||||
|
||||
it('should return true if file exists', async () => {
|
||||
const exists = await FSUtils.exists(pathToNonEmptyDir + "/some-file.txt");
|
||||
exists.should.be.true();
|
||||
});
|
||||
|
||||
it('should return false if file does not exist', async () => {
|
||||
const exists = await FSUtils.exists(pathToNotExistingFile);
|
||||
exists.should.be.false();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -39,8 +39,8 @@
|
|||
"jquery-deferred-must-complete": true,
|
||||
"label-position": true,
|
||||
"match-default-export-name": false,
|
||||
"mocha-avoid-only": true,
|
||||
"mocha-no-side-effect-code": true,
|
||||
"mocha-avoid-only": false, //changed
|
||||
"mocha-no-side-effect-code": false, //changed
|
||||
"no-any": false,
|
||||
"no-arg": true,
|
||||
"no-backbone-get-set-outside-model": false,
|
||||
|
|
Загрузка…
Ссылка в новой задаче