Skip to content

Commit 1d7c0b6

Browse files
authored
factory pattern - example 3 test
2 parents f9fe103 + ac0b6e8 commit 1d7c0b6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

library/creational-patterns/factory/example_3.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class HttpError extends Error {
1+
export class HttpError extends Error {
22
public name: string;
33
public statusCode: number;
44

library/creational-patterns/factory/index.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { HttpError } from './example_3';
12
import { Shape, IShapeFactory, ShapeFactory } from './example_2';
23
import {
34
Asteroid,
@@ -51,4 +52,11 @@ describe('Factory Pattern', () => {
5152
expect(shape.draw()).toBe('Rectangle');
5253
});
5354
});
55+
56+
describe('Example 3 Tests', () => {
57+
it('should throw NotFoundError', () => {
58+
const error: HttpError = HttpError.NotFoundError('The resource you requested is not found.');
59+
expect(error.statusCode).toBe(404);
60+
});
61+
});
5462
});

0 commit comments

Comments
 (0)