Charles Lyding 37a06a7c37 build: format all files
All files are now formatted using the ng-dev tools via prettier.
2021-04-28 16:05:49 -07:00

46 lines
1.3 KiB
TypeScript

/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { parseName } from './parse-name';
describe('parse-name', () => {
it('should handle just the name', () => {
const result = parseName('src/app', 'foo');
expect(result.name).toEqual('foo');
expect(result.path).toEqual('/src/app');
});
it('should handle no path', () => {
const result = parseName('', 'foo');
expect(result.name).toEqual('foo');
expect(result.path).toEqual('/');
});
it('should handle name has a path (sub-dir)', () => {
const result = parseName('src/app', 'bar/foo');
expect(result.name).toEqual('foo');
expect(result.path).toEqual('/src/app/bar');
});
it('should handle name has a higher path', () => {
const result = parseName('src/app', '../foo');
expect(result.name).toEqual('foo');
expect(result.path).toEqual('/src');
});
it('should handle name has a higher path above root', () => {
expect(() => parseName('src/app', '../../../foo')).toThrow();
});
it('should handle Windows paths', () => {
const result = parseName('', 'foo\\bar\\baz');
expect(result.name).toEqual('baz');
expect(result.path).toEqual('/foo/bar');
});
});