Total Complexity | 6 |
Complexity/F | 1.2 |
Lines of Code | 56 |
Function Count | 5 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | 'use strict' |
||
2 | |||
3 | import mongoose from 'mongoose' |
||
4 | import chai from 'chai' |
||
5 | import chaiHttp from 'chai-http' |
||
6 | import dirtyChai from 'dirty-chai' |
||
7 | import sinon from 'sinon' |
||
8 | import sinonChai from 'sinon-chai' |
||
9 | import winston from 'winston' |
||
10 | import { before, beforeEach, after, afterEach } from 'mocha' |
||
11 | |||
12 | chai.use(chaiHttp) |
||
13 | chai.use(dirtyChai) |
||
14 | chai.use(sinonChai) |
||
15 | |||
16 | before(() => { |
||
17 | // we want to have logger.test() without flooding the console with other levels' messages |
||
18 | winston.setLevels({ |
||
19 | debug: 5, |
||
20 | info: 4, |
||
21 | warn: 3, |
||
22 | error: 2, |
||
23 | critical: 1, |
||
24 | test: 0 |
||
25 | }) |
||
26 | winston.addColors({ |
||
27 | debug: 'green', |
||
28 | info: 'cyan', |
||
29 | warn: 'yellow', |
||
30 | error: 'red', |
||
31 | critical: 'red', |
||
32 | test: 'blue' |
||
33 | }) |
||
34 | winston.remove(winston.transports.Console) |
||
35 | winston.add(winston.transports.Console, { level: 'test', colorize: true }) |
||
36 | winston.add(winston.transports.File, { name: 'test', filename: 'log/test.log' }) |
||
37 | |||
38 | // prepares a clean bank |
||
39 | mongoose.connect('mongodb://localhost/accounts', (err) => { |
||
40 | if (err) { |
||
41 | throw err |
||
42 | } |
||
43 | }) |
||
44 | }) |
||
45 | |||
46 | beforeEach(function beforeEach () { |
||
47 | this.sandbox = sinon.sandbox.create() |
||
48 | }) |
||
49 | |||
50 | afterEach(function afterEach () { |
||
51 | this.sandbox.restore() |
||
52 | }) |
||
53 | |||
54 | after(() => { |
||
55 | mongoose.connection.dropDatabase() |
||
56 | }) |
||
57 |