Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

History

History
History
49 lines (43 loc) 路 2 KB

File metadata and controls

49 lines (43 loc) 路 2 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* @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 {RuntimeError, RuntimeErrorCode} from '../src/errors';
import {ERROR_DETAILS_PAGE_BASE_URL} from '../src/error_details_base_url';
describe('RuntimeError utils', () => {
it('should correctly format an error without an error message', () => {
const error = new RuntimeError<RuntimeErrorCode>(RuntimeErrorCode.EXPORT_NOT_FOUND, '');
expect(error.toString()).toBe(
`Error: NG0301. Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0301`,
);
});
it('should correctly format an error without an error message not adev guide', () => {
const error = new RuntimeError(RuntimeErrorCode.TEMPLATE_STRUCTURE_ERROR, '');
expect(error.toString()).toBe('Error: NG0305');
});
it('should correctly format an error with an error message but without an adev guide', () => {
const error = new RuntimeError(RuntimeErrorCode.TEMPLATE_STRUCTURE_ERROR, 'Some error message');
expect(error.toString()).toBe('Error: NG0305: Some error message');
});
it('should correctly format an error with both an error message and an adev guide', () => {
const error = new RuntimeError(RuntimeErrorCode.EXPORT_NOT_FOUND, 'Some error message');
expect(error.toString()).toBe(
`Error: NG0301: Some error message. Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0301`,
);
});
['.', ',', ';', '!', '?'].forEach((character) =>
it(`should not add a period between the error message and the adev guide suffix if the message ends with '${character}'`, () => {
const errorMessage = `Pipe not found${character}`;
const error = new RuntimeError<RuntimeErrorCode>(
RuntimeErrorCode.PIPE_NOT_FOUND,
errorMessage,
);
expect(error.toString()).toBe(
`Error: NG0302: Pipe not found${character} Find more at ${ERROR_DETAILS_PAGE_BASE_URL}/NG0302`,
);
}),
);
});
Morty Proxy This is a proxified and sanitized view of the page, visit original site.