Skip to content

Commit

Permalink
Add tests for core/errors module. #546
Browse files Browse the repository at this point in the history
Signed-off-by: Quan Nguyen <[email protected]>
  • Loading branch information
qnswirlds committed Nov 17, 2023
1 parent 27fda90 commit 9c6dbcd
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions fullstack-network-manager/test/unit/core/errors.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import {describe, expect, it} from '@jest/globals';

Check notice on line 1 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L1

A space is required after '{'.

Check notice on line 1 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L1

Extra semicolon.
import {
FullstackTestingError,
ResourceNotFoundError,
MissingArgumentError,
IllegalArgumentError,
DataValidationError
} from '../../../src/core/errors.mjs';

Check notice on line 8 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L8

Extra semicolon.

describe('Errors', () => {
const message = 'errorMessage';

Check notice on line 11 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L11

Extra semicolon.
const cause = 'cause';

Check notice on line 12 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L12

Extra semicolon.

it('should construct correct FullstackTestingError', () => {
const error = new FullstackTestingError(message, cause);
expect(error).toBeInstanceOf(Error);

Check notice on line 16 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L16

Extra semicolon.
expect(error.name).toBe('FullstackTestingError');

Check notice on line 17 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L17

Extra semicolon.
expect(error.message).toBe(message);

Check notice on line 18 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L18

Extra semicolon.
expect(error.cause).toBe(cause);

Check notice on line 19 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L19

Extra semicolon.
expect(error.meta).toStrictEqual({})
})

it('should construct correct ResourceNotFoundError', () => {
const resource = 'resource';
const error = new ResourceNotFoundError(message, resource);

Check notice on line 25 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L25

Extra semicolon.
expect(error).toBeInstanceOf(FullstackTestingError);

Check notice on line 26 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L26

Extra semicolon.
expect(error.name).toBe('ResourceNotFoundError');

Check notice on line 27 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L27

Extra semicolon.
expect(error.message).toBe(message);
expect(error.cause).toStrictEqual({})
expect(error.meta).toStrictEqual({ resource });

Check notice on line 30 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L30

Extra semicolon.
})

it('should construct correct MissingArgumentError', () => {
const error = new MissingArgumentError(message);

Check notice on line 34 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L34

Extra semicolon.
expect(error).toBeInstanceOf(FullstackTestingError);
expect(error.name).toBe('MissingArgumentError');

Check notice on line 36 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L36

Extra semicolon.
expect(error.message).toBe(message);
expect(error.cause).toStrictEqual({})
expect(error.meta).toStrictEqual({});

Check notice on line 39 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L39

Extra semicolon.
})

it('should construct correct IllegalArgumentError', () => {
const value = 'invalid argument';

Check notice on line 43 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L43

Extra semicolon.
const error = new IllegalArgumentError(message, value);

Check notice on line 44 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L44

Extra semicolon.
expect(error).toBeInstanceOf(FullstackTestingError);
expect(error.name).toBe('IllegalArgumentError');

Check notice on line 46 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L46

Extra semicolon.
expect(error.message).toBe(message);
expect(error.cause).toStrictEqual({})
expect(error.meta).toStrictEqual({ value });

Check notice on line 49 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L49

Extra semicolon.
})

it('should construct correct DataValidationError', () => {
const expected = 'expected';

Check notice on line 53 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L53

Extra semicolon.
const found = 'found';

Check notice on line 54 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L54

Extra semicolon.
const error = new DataValidationError(message, expected, found);

Check notice on line 55 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L55

Extra semicolon.
expect(error).toBeInstanceOf(FullstackTestingError);
expect(error.name).toBe('DataValidationError');

Check notice on line 57 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L57

Extra semicolon.
expect(error.message).toBe(message);
expect(error.cause).toStrictEqual({})
expect(error.meta).toStrictEqual({ expected, found });

Check notice on line 60 in fullstack-network-manager/test/unit/core/errors.test.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fullstack-network-manager/test/unit/core/errors.test.mjs#L60

Extra semicolon.
})
})

0 comments on commit 9c6dbcd

Please sign in to comment.