2018-03-31 03:30:30 +08:00
|
|
|
import {expect} from 'chai';
|
2021-04-18 21:48:35 +08:00
|
|
|
import {UserDTO, UserDTOUtils} from '../../../src/common/entities/UserDTO';
|
2018-02-04 08:50:42 +08:00
|
|
|
|
|
|
|
describe('UserDTO', () => {
|
|
|
|
|
|
|
|
|
|
|
|
it('should check available path', () => {
|
2021-04-18 21:48:35 +08:00
|
|
|
expect(UserDTOUtils.isDirectoryPathAvailable('/', ['/'])).to.be.equals(true);
|
|
|
|
expect(UserDTOUtils.isDirectoryPathAvailable('/', ['/subfolder', '/'])).to.be.equals(true);
|
|
|
|
expect(UserDTOUtils.isDirectoryPathAvailable('/abc', ['/subfolder', '/'])).to.be.equals(false);
|
|
|
|
expect(UserDTOUtils.isDirectoryPathAvailable('/abc', ['/subfolder', '/*'])).to.be.equals(true);
|
|
|
|
expect(UserDTOUtils.isDirectoryPathAvailable('/abc', ['/subfolder'])).to.be.equals(false);
|
|
|
|
expect(UserDTOUtils.isDirectoryPathAvailable('/abc/two', ['/subfolder'])).to.be.equals(false);
|
|
|
|
expect(UserDTOUtils.isDirectoryPathAvailable('/abc/two', ['/'])).to.be.equals(false);
|
|
|
|
expect(UserDTOUtils.isDirectoryPathAvailable('/abc/two', ['/*'])).to.be.equals(true);
|
2018-02-04 08:50:42 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should check directory', () => {
|
2021-04-18 21:48:35 +08:00
|
|
|
expect(UserDTOUtils.isDirectoryAvailable({path: '/', name: 'abc'} as any, ['/*'])).to.be.equals(true);
|
|
|
|
expect(UserDTOUtils.isDirectoryAvailable({path: '/', name: 'abc'} as any, ['/'])).to.be.equals(false);
|
|
|
|
expect(UserDTOUtils.isDirectoryAvailable({path: '.\\', name: '.'} as any, ['/'])).to.be.equals(true);
|
|
|
|
expect(UserDTOUtils.isDirectoryAvailable({path: '/', name: 'abc'} as any, ['/*', '/asdad'])).to.be.equals(true);
|
2018-02-04 08:50:42 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
});
|