1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | const expect = require('chai').expect;
|
10 | const rewire = require('rewire');
|
11 | const config = { refocusUrl: 'zzz', token: 'dummy' };
|
12 | const bdkServer = rewire('../refocus-bdk-server.js');
|
13 | const sinon = require('sinon');
|
14 | const generic = require('../generic.js');
|
15 |
|
16 |
|
17 | global.user = '{"email":"test@test.com"}';
|
18 | global.window = { document: { }, location: { href: '' } };
|
19 | const bdkClient = rewire('../refocus-bdk-client.js');
|
20 |
|
21 | const ONE = 1;
|
22 |
|
23 | describe('BDK Client roomTypes: ', () => {
|
24 | beforeEach(() => {
|
25 | bdkClient.__set__('localStorage', { 'Name': 'User' });
|
26 | });
|
27 |
|
28 | it('Ok, get roomTypes', (done) => {
|
29 | sinon.stub(generic, 'get').resolves({ body:
|
30 | [{ id: 'abcdefg', name: 'RoomTypeName' }] });
|
31 | bdkClient.__get__('module.exports')(config).getRoomTypes()
|
32 | .then((res) => {
|
33 | expect(res.body.length).to.equal(ONE);
|
34 | }).then(() => generic.get.restore())
|
35 | .then(() => done());
|
36 | });
|
37 | });
|
38 |
|
39 | describe('BDK Server roomTypes: ', () => {
|
40 | it('Ok, getRoomTypes', (done) => {
|
41 | sinon.stub(generic, 'get').resolves({ body:
|
42 | [{ id: 'abcdefg', name: 'RoomTypeName' }] });
|
43 | bdkServer.__get__('module.exports')(config).getRoomTypes()
|
44 | .then((res) => {
|
45 | expect(res.body.length).to.equal(ONE);
|
46 | }).then(() => generic.get.restore())
|
47 | .then(() => done());
|
48 | });
|
49 | });
|