Completed
Pull Request — master (#32)
by Jean
55s
created

test/codingame/error.test.js   A

Complexity

Total Complexity 7
Complexity/F 1

Size

Lines of Code 35
Function Count 7

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 1
dl 0
loc 35
rs 10
wmc 7
mnd 0
bc 7
fnc 7
bpm 1
cpm 1
noi 1

1 Function

Rating   Name   Duplication   Size   Complexity  
B error.test.js ➔ describe 0 29 1
1
import chai from 'chai';
2
3
import CodingameError from '../../src/codingame/error.js';
4
5
let expect = chai.expect;
6
7
describe(`[module] codingame/error`, function() {
8
	describe(`[method] constructor`, function() {
9
		it(`should create a default CodingameError with empty message`, function() {
10
			let error = new CodingameError();
11
			expect(error).to.be.an.instanceof(CodingameError).and.has.a.property(`message`).empty;
0 ignored issues
show
introduced by
The result of the property access to expect(error).to.be.an.i...operty(`message`).empty is not used.
Loading history...
12
		});
13
		it(`should create a CodingameError with the specified message`, function() {
14
			let message = `Specified message`;
15
			let error = new CodingameError(message);
16
			expect(error).to.be.an.instanceof(CodingameError).and.has.a.property(`message`, message);
17
		});
18
		it(`should create a CodingameError from an Error`, function() {
19
			let message = `Some error`;
20
			let error = new Error(message);
21
			let cgerror = new CodingameError(error);
22
			expect(cgerror).to.be.an.instanceof(CodingameError).and.has.a.property(`message`, message);
23
		});
24
	});
25
	describe(`[method] metadata`, function() {
26
		it(`should attach metadatas to the CodingameError`, function() {
27
			let value = `42`;
28
			let meta = { "property": value };
29
			let error = new CodingameError();
30
			error.attach(meta);
31
			expect(error).to.have.a.property(`metadata`)
32
				.with.a.property(`property`, value);
33
		});
34
	});
35
});
36