1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-23 01:27:14 +02:00
pigallery2/test/common/unit/UserDTO.ts
2019-12-10 10:44:35 +01:00

27 lines
1.3 KiB
TypeScript

import {expect} from 'chai';
import {UserDTO} from '../../../src/common/entities/UserDTO';
describe('UserDTO', () => {
it('should check available path', () => {
expect(UserDTO.isDirectoryPathAvailable('/', ['/'])).to.be.equals(true);
expect(UserDTO.isDirectoryPathAvailable('/', ['/subfolder', '/'])).to.be.equals(true);
expect(UserDTO.isDirectoryPathAvailable('/abc', ['/subfolder', '/'])).to.be.equals(false);
expect(UserDTO.isDirectoryPathAvailable('/abc', ['/subfolder', '/*'])).to.be.equals(true);
expect(UserDTO.isDirectoryPathAvailable('/abc', ['/subfolder'])).to.be.equals(false);
expect(UserDTO.isDirectoryPathAvailable('/abc/two', ['/subfolder'])).to.be.equals(false);
expect(UserDTO.isDirectoryPathAvailable('/abc/two', ['/'])).to.be.equals(false);
expect(UserDTO.isDirectoryPathAvailable('/abc/two', ['/*'])).to.be.equals(true);
});
it('should check directory', () => {
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);
});
});