1 | ;
|
2 |
|
3 | /**
|
4 | * Chai assert library
|
5 | * @external chai
|
6 | * @see {@link http://chaijs.com/}
|
7 | */
|
8 |
|
9 | /**
|
10 | * Chai promise assert library
|
11 | * @external chai-as-promised
|
12 | * @see {@link https://github.com/domenic/chai-as-promised}
|
13 | */
|
14 |
|
15 | /**
|
16 | * Standalone and test framework agnostic JavaScript test spies, stubs and mocks
|
17 | * @external sinon
|
18 | * @see {@link https://github.com/sinonjs/sinon}
|
19 | */
|
20 |
|
21 | const chaiLibrary = require('chai');
|
22 | const chaiAsPromisedLib = require('chai-as-promised');
|
23 | const sinonLibrary = require('sinon');
|
24 | const sinonTest = require('sinon-test');
|
25 |
|
26 | sinonLibrary.test = sinonTest.configureTest(sinonLibrary);
|
27 | sinonLibrary.testCase = sinonTest.configureTestCase(sinonLibrary);
|
28 |
|
29 | /**
|
30 | * Sinon stubs/mocks/spies etc.
|
31 | * @returns {external:sinon} sinon object for mocking/stubing/spying
|
32 | */
|
33 | const getSinon = () => sinonLibrary;
|
34 |
|
35 | /**
|
36 | * Sinon sandbox
|
37 | * @returns {external:sinon.sandbox} sinon sandbox object for mocking/stubing/spying
|
38 | */
|
39 | const getSinonSandbox = () => sinonLibrary.sandbox.create();
|
40 | /**
|
41 | * Chai with promise support library
|
42 | * @returns {external:chai-as-promised} chai with support library
|
43 | */
|
44 | const getChai = () => {
|
45 | chaiLibrary.use(chaiAsPromisedLib);
|
46 | chaiLibrary.should();
|
47 | return chaiLibrary;
|
48 | };
|
49 |
|
50 | module.exports = {
|
51 | getExpect: () => getChai().expect,
|
52 | getChai,
|
53 | getSinon,
|
54 | getSinonSandbox,
|
55 | };
|