UNPKG

1.61 kBJavaScriptView Raw
1/**
2 * Copyright (c) 2019, salesforce.com, inc.
3 * All rights reserved.
4 * Licensed under the BSD 3-Clause license.
5 * For full license text, see LICENSE.txt file in the repo root or
6 * https://opensource.org/licenses/BSD-3-Clause
7 */
8
9const expect = require('chai').expect;
10const rewire = require('rewire');
11const config = { refocusUrl: 'zzz', token: 'dummy' };
12const bdkServer = rewire('../refocus-bdk-server.js');
13const sinon = require('sinon');
14const generic = require('../generic.js');
15
16// Create environment for client code to work
17global.user = '{"email":"test@test.com"}';
18global.window = { document: { }, location: { href: '' } };
19const bdkClient = rewire('../refocus-bdk-client.js');
20
21const ONE = 1;
22
23describe('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
39describe('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});