forked from dajk/hltv-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
55 lines (43 loc) · 1.47 KB
/
index.test.js
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
53
54
55
/* global describe, it */
import { assert, expect } from 'chai';
import { getNews, getResults } from './index';
import { CONFIG } from './config';
describe('hltv-api', () => {
describe('get appropriate responses', () => {
it('callback length should be a number', (done) => {
getNews((response) => {
assert.isNumber(response.length);
expect(response.length).is.equal(10);
done();
});
});
it('callback news should be an array', (done) => {
getNews((response) => {
assert.isArray(response);
done();
});
});
it('should have all details when we call `getNews`', (done) => {
getNews((response) => {
const news = response[0];
expect(news.title).to.have.length.above(3);
expect(news.description).to.have.length.above(3);
expect(news.link).to.contain(CONFIG.BASE);
expect(news.date).to.have.length.above(10);
done();
})
});
it('should have all details when we call `getResults`', (done) => {
getResults((response) => {
expect(response.length).is.equal(100);
const result = response[0];
expect(result.team1.name).to.have.length.above(0);
expect(result.team1.crest).to.contain(CONFIG.STATIC);
expect(result.team2.name).to.have.length.above(0);
expect(result.team2.crest).to.contain(CONFIG.STATIC);
expect(result.matchId).to.have.length.above(10);
done();
});
});
});
});