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