angular/adev/shared-docs/pipes/relative-link.pipe.spec.ts
Joey Perrott 2d8635d29d refactor(docs-infra): migrate @angular/docs from dev-infra into adev directory (#57132)
To increase the ease of development we are moving @angular/docs into the adev directory within this repo. While
we are doing this to improve our development experience in the short term, efforts are also in place
to maintain a division between this @angular/docs (shared) code and adev itself, so that it can be extracted
back out in the future when components is ready to leverage it as well.

PR Close #57132
2024-07-30 15:51:26 +00:00

41 lines
1.1 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 {RelativeLink} from './relative-link.pipe';
describe('RelativeLink', () => {
let pipe: RelativeLink;
beforeEach(() => {
pipe = new RelativeLink();
});
it('should transform absolute url to relative', () => {
const absoluteUrl = 'https://angular.dev/guide/directives#test';
const result = pipe.transform(absoluteUrl);
expect(result).toBe('guide/directives#test');
});
it('should return fragment once result param is equal to `hash`', () => {
const absoluteUrl = 'https://angular.dev/guide/directives#test';
const result = pipe.transform(absoluteUrl, 'hash');
expect(result).toBe('test');
});
it('should return relative url without fragment once result param is equal to `pathname`', () => {
const absoluteUrl = 'https://angular.dev/guide/directives#test';
const result = pipe.transform(absoluteUrl, 'pathname');
expect(result).toBe('guide/directives');
});
});