Completed
Push — master ( 73fdbe...e1a05e )
by Jean
01:06
created

test/test-configure.js   A

Complexity

Total Complexity 6
Complexity/F 1

Size

Lines of Code 40
Function Count 6

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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

1 Function

Rating   Name   Duplication   Size   Complexity  
B test-configure.js ➔ describe 0 31 1
1
import chai from 'chai';
2
import chaiaspromised from 'chai-as-promised';
3
import mockfs from 'mock-fs';
4
5
import configure from '../src/configure.js';
6
7
let expect = chai.expect;
8
chai.use(chaiaspromised);
9
10
describe(`[module] configure`, function() {
11
	describe(`[method] load`, function() {
12
		let defaultconfpath = `.codingamerc`;
13
		let defaultconf = {
14
			"username": `me`,
15
			"password": `somepass`,
16
			"exercise": `5711567e959cf54dd2dd79c1b4c259560d6ba46`,
17
			"tests": [1, 2],
18
			"language": `Python`,
19
			"bundle": `bundle.py`
20
		};
21
		before(function () {
22
			mockfs({
23
				[defaultconfpath]: JSON.stringify(defaultconf)
24
			});
25
		});
26
		after(function () {
27
			mockfs.restore();
28
		});
29
30
		it(`should return the content of file parsed as JSON`, function() {
31
			let conf = configure.load(defaultconfpath);
32
			return expect(conf).to.eventually.be.deep.equal(defaultconf);
33
		});
34
35
		it(`should return options if path is incorrect and options is defined`, function() {
36
			let conf = configure.load(undefined, defaultconf);
37
			return expect(conf).to.eventually.be.deep.equal(defaultconf);
38
		});
39
	});
40
});
41