-
Notifications
You must be signed in to change notification settings - Fork 1
/
translations.ts
52 lines (43 loc) · 1.83 KB
/
translations.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import * as nock from 'nock';
import {expect} from 'chai';
import * as helper from '../helper';
import {LokaliseAPI} from '../../index';
const SCOPE = 'translations';
describe(`api/${SCOPE}`, () => {
let lokaliseAPI;
beforeEach(() => {
lokaliseAPI = new LokaliseAPI({baseUrl: helper.BASE_URL, token: '1234567890'});
});
describe('list', () => {
it('should receive list of all translations', async () => {
nock(helper.BASE_URL)
.get('/projects/abcde.12345/translations')
.query({page: 1, limit: 100})
.reply(200, helper.getResponse(SCOPE, 'list.json'));
const result = await lokaliseAPI.translations.list('abcde.12345', {page: 1, limit: 100});
expect(result).to.eql(helper.getResponse(SCOPE, 'list.json'));
});
});
describe('get', () => {
it('should receive single translation', async () => {
nock(helper.BASE_URL)
.get('/projects/abcde.12345/translations/567')
.reply(200, helper.getResponse(SCOPE, 'get.json'));
const result = await lokaliseAPI.translations.get('abcde.12345', 567);
expect(result).to.eql(helper.getResponse(SCOPE, 'get.json'));
});
});
describe('update', () => {
it('should update translation', async () => {
nock(helper.BASE_URL)
.put(
'/projects/abcde.12345/translations/567',
helper.getRequest(SCOPE, 'update.json')
)
.reply(200, helper.getResponse(SCOPE, 'update.json'));
const result = await lokaliseAPI.translations
.update('abcde.12345', 567, helper.getRequest(SCOPE, 'update.json'));
expect(result).to.eql(helper.getResponse(SCOPE, 'update.json'));
});
});
});