Skip to content

Commit 4280af2

Browse files
committed
added some tests
1 parent 3b12fe3 commit 4280af2

File tree

4 files changed

+163
-1
lines changed

4 files changed

+163
-1
lines changed

bitmovin/account/organizations/tenants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import urljoin from 'url-join';
22
import http from '../../http';
33

4-
export const permissions = (configuration, organizationId, groupId, http) => {
4+
export const tenants = (configuration, organizationId, groupId, http) => {
55
const { get, post, delete_ } = http;
66
const tenantsBaseUrl = urljoin(configuration.apiBaseUrl, 'account', 'organizations', organizationId, 'groups', groupId, 'tenants');
77

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import urljoin from 'url-join';
2+
import { groups } from '../../../bitmovin/account/organizations/groups';
3+
4+
import {
5+
mockGet,
6+
mockPost,
7+
mockDelete,
8+
mockHttp,
9+
assertItReturnsUnderlyingPromise,
10+
assertItCallsCorrectUrl,
11+
testSetup,
12+
} from '../../assertions';
13+
14+
import {getConfiguration} from '../../utils';
15+
16+
let testConfiguration = getConfiguration();
17+
18+
describe('account', () => {
19+
beforeEach(testSetup);
20+
describe('organizations', () => {
21+
describe('groups', () => {
22+
const testOrgId = '123';
23+
const client = groups(testConfiguration, testOrgId, mockHttp);
24+
25+
describe('list', () => {
26+
assertItCallsCorrectUrl('GET', urljoin('/v1/account/organizations', testOrgId, 'groups'), client.list);
27+
assertItReturnsUnderlyingPromise(mockGet, client.list);
28+
});
29+
30+
describe('add', () => {
31+
assertItCallsCorrectUrl('POST', urljoin('/v1/account/organizations', testOrgId, 'groups'), client.add);
32+
assertItReturnsUnderlyingPromise(mockPost, client.add);
33+
});
34+
35+
describe('group', () => {
36+
const testGroupId = '123';
37+
38+
describe('details', () => {
39+
assertItCallsCorrectUrl('GET', urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId), client(testGroupId).details);
40+
assertItReturnsUnderlyingPromise(mockGet, client(testOrgId).details);
41+
});
42+
describe('delete', () => {
43+
assertItCallsCorrectUrl('DELETE', urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId), client(testGroupId).delete);
44+
assertItReturnsUnderlyingPromise(mockDelete, client(testOrgId).delete);
45+
});
46+
});
47+
});
48+
});
49+
});
50+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import urljoin from 'url-join';
2+
import { permissions } from '../../../bitmovin/account/organizations/permissions';
3+
4+
import {
5+
mockGet,
6+
mockPost,
7+
mockDelete,
8+
mockHttp,
9+
assertItReturnsUnderlyingPromise,
10+
assertItCallsCorrectUrl,
11+
testSetup,
12+
} from '../../assertions';
13+
14+
import {getConfiguration} from '../../utils';
15+
16+
let testConfiguration = getConfiguration();
17+
18+
describe('account', () => {
19+
beforeEach(testSetup);
20+
describe('organizations', () => {
21+
describe('groups', () => {
22+
describe('permissions', () => {
23+
const testOrgId = '123';
24+
const testGroupId = '123';
25+
26+
const client = permissions(testConfiguration, testOrgId, testGroupId, mockHttp);
27+
28+
describe('list', () => {
29+
assertItCallsCorrectUrl('GET', urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'permissions'), client.list);
30+
assertItReturnsUnderlyingPromise(mockGet, client.list);
31+
});
32+
33+
describe('add', () => {
34+
assertItCallsCorrectUrl('POST', urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'permissions'), client.add);
35+
assertItReturnsUnderlyingPromise(mockPost, client.add);
36+
});
37+
38+
describe('permission', () => {
39+
const testPermissionId = '123';
40+
41+
describe('details', () => {
42+
assertItCallsCorrectUrl('GET', urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'permissions', testPermissionId),
43+
client(testGroupId).details);
44+
assertItReturnsUnderlyingPromise(mockGet, client(testOrgId).details);
45+
});
46+
describe('delete', () => {
47+
assertItCallsCorrectUrl('DELETE', urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'permissions', testPermissionId),
48+
client(testGroupId).delete);
49+
assertItReturnsUnderlyingPromise(mockDelete, client(testOrgId).delete);
50+
});
51+
});
52+
});
53+
});
54+
});
55+
});
56+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import urljoin from 'url-join';
2+
import { tenants } from '../../../bitmovin/account/organizations/tenants';
3+
4+
import {
5+
mockGet,
6+
mockPost,
7+
mockDelete,
8+
mockHttp,
9+
assertItReturnsUnderlyingPromise,
10+
assertItCallsCorrectUrl,
11+
testSetup,
12+
} from '../../assertions';
13+
14+
import {getConfiguration} from '../../utils';
15+
16+
let testConfiguration = getConfiguration();
17+
18+
describe('account', () => {
19+
beforeEach(testSetup);
20+
describe('organizations', () => {
21+
describe('groups', () => {
22+
describe('tenants', () => {
23+
const testOrgId = '123';
24+
const testGroupId = '123';
25+
26+
const client = tenants(testConfiguration, testOrgId, testGroupId, mockHttp);
27+
28+
describe('list', () => {
29+
assertItCallsCorrectUrl('GET', urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'tenants'), client.list);
30+
assertItReturnsUnderlyingPromise(mockGet, client.list);
31+
});
32+
33+
describe('add', () => {
34+
assertItCallsCorrectUrl('POST', urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'tenants'), client.add);
35+
assertItReturnsUnderlyingPromise(mockPost, client.add);
36+
});
37+
38+
describe('tenant', () => {
39+
const testTenantId = '123';
40+
41+
describe('details', () => {
42+
assertItCallsCorrectUrl('GET', urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'tenants', testTenantId),
43+
client(testGroupId).details);
44+
assertItReturnsUnderlyingPromise(mockGet, client(testOrgId).details);
45+
});
46+
describe('delete', () => {
47+
assertItCallsCorrectUrl('DELETE', urljoin('/v1/account/organizations', testOrgId, 'groups', testGroupId, 'tenants', testTenantId),
48+
client(testGroupId).delete);
49+
assertItReturnsUnderlyingPromise(mockDelete, client(testOrgId).delete);
50+
});
51+
});
52+
});
53+
});
54+
});
55+
});
56+

0 commit comments

Comments
 (0)