UNPKG

1.06 kBJavaScriptView Raw
1var assert = require('assert');
2var crypto = require('crypto');
3var tenantFactory = require('..').tenantFactory;
4var fixtures = require('./fixtures');
5
6describe('ac hipchat tenant factory', function () {
7
8 it('should combine an installable payload and capabilities document into a full tenant profile', function *() {
9 var installable = fixtures.load('tenant-installable.json');
10 var capabilities = fixtures.load('tenant-capabilities.json');
11 var webhookToken = crypto.createHash('sha1')
12 .update(installable.oauthId)
13 .update(installable.oauthSecret)
14 .digest('hex');
15 assert.deepEqual(tenantFactory(installable, capabilities), {
16 id: installable.oauthId,
17 secret: installable.oauthSecret,
18 group: installable.groupId,
19 room: installable.roomId,
20 webhookToken: webhookToken,
21 links: {
22 capabilities: capabilities.links.self,
23 base: capabilities.links.homepage,
24 api: capabilities.links.api,
25 token: capabilities.capabilities.oauth2Provider.tokenUrl
26 }
27 });
28 });
29
30});