Skip to content
This repository was archived by the owner on Feb 4, 2018. It is now read-only.

Commit 07b46b1

Browse files
author
blond
committed
test(EntityTypeError): add tests for EntityTypeError
1 parent ffa5039 commit 07b46b1

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

test/entity-type-error.test.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
const test = require('ava');
2+
3+
const EntityTypeError = require('../lib/entity-type-error');
4+
5+
test('should create type error', t => {
6+
const error = new EntityTypeError();
7+
8+
t.is(error.message, 'the `undefined` is not valid BEM entity');
9+
});
10+
11+
test('should create type error with number', t => {
12+
const error = new EntityTypeError(42);
13+
14+
t.is(error.message, 'the number `42` is not valid BEM entity');
15+
});
16+
17+
test('should create type error with string', t => {
18+
const error = new EntityTypeError('block');
19+
20+
t.is(error.message, 'the string `\'block\'` is not valid BEM entity');
21+
});
22+
23+
test('should create type error with empty object', t => {
24+
const error = new EntityTypeError({});
25+
26+
t.is(error.message, 'the object `{}` is not valid BEM entity');
27+
});
28+
29+
test('should create type error with object', t => {
30+
const error = new EntityTypeError({ key: 'val' });
31+
32+
t.is(error.message, "the object `{ key: 'val' }` is not valid BEM entity");
33+
});
34+
35+
test('should create type error with deep object', t => {
36+
const error = new EntityTypeError({ a: { b: { c: 'd' } } });
37+
38+
t.is(error.message, 'the object `{ a: { b: [Object] } }` is not valid BEM entity');
39+
});
40+
41+
test('should create type error with reason', t => {
42+
const error = new EntityTypeError({ elem: 'elem' }, 'the field `block` is undefined');
43+
44+
t.is(error.message, "the object `{ elem: 'elem' }` is not valid BEM entity, the field `block` is undefined");
45+
});

0 commit comments

Comments
 (0)