52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import {
|
|
FontNetworkError,
|
|
FontResponseError,
|
|
} from './errors';
|
|
|
|
describe('FontNetworkError', () => {
|
|
it('has correct name', () => {
|
|
const err = new FontNetworkError();
|
|
expect(err.name).toBe('FontNetworkError');
|
|
});
|
|
|
|
it('is instance of Error', () => {
|
|
expect(new FontNetworkError()).toBeInstanceOf(Error);
|
|
});
|
|
|
|
it('stores cause', () => {
|
|
const cause = new Error('network down');
|
|
const err = new FontNetworkError(cause);
|
|
expect(err.cause).toBe(cause);
|
|
});
|
|
|
|
it('has default message', () => {
|
|
expect(new FontNetworkError().message).toBe('Failed to fetch fonts from proxy API');
|
|
});
|
|
});
|
|
|
|
describe('FontResponseError', () => {
|
|
it('has correct name', () => {
|
|
const err = new FontResponseError('response', undefined);
|
|
expect(err.name).toBe('FontResponseError');
|
|
});
|
|
|
|
it('is instance of Error', () => {
|
|
expect(new FontResponseError('response.fonts', null)).toBeInstanceOf(Error);
|
|
});
|
|
|
|
it('stores field', () => {
|
|
const err = new FontResponseError('response.fonts', 42);
|
|
expect(err.field).toBe('response.fonts');
|
|
});
|
|
|
|
it('stores received value', () => {
|
|
const err = new FontResponseError('response.fonts', 42);
|
|
expect(err.received).toBe(42);
|
|
});
|
|
|
|
it('message includes field name', () => {
|
|
const err = new FontResponseError('response.fonts', null);
|
|
expect(err.message).toContain('response.fonts');
|
|
});
|
|
});
|