Ash Ramirez 434a3740f0 refactor(@angular/cli): update aio links -> adev links
Updates for all angular.io links to the new angular.dev domain. Additionally, adjustment to new resources where the equivalent does not exist on the new site (e.g. Tour of Heroes tutorial)
2024-06-06 11:12:06 +02: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.dev/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');
});
});