Completed
Pull Request — master (#29)
by Jean
01:16
created

test-configure.js ➔ describe   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
cc 1
c 4
b 0
f 0
nc 1
nop 0
dl 0
loc 31
rs 8.8571

1 Function

Rating   Name   Duplication   Size   Complexity  
B test-configure.js ➔ ... ➔ describe 0 29 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