This repository has been archived by the owner on Apr 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.test.suite.js
59 lines (49 loc) · 2.64 KB
/
app.test.suite.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
56
57
58
59
const chai = require('chai');
const expect = chai.expect;
const request = require('supertest');
describe('github data link suite', function () {
this.timeout(100000);
before('start app', () => {
this.app = require('./app')();
this.get = (config = {}) => request(`http://127.0.0.1:${this.app.address().port}`)
.get(config.path ? config.path : '/')
.set('Authorization', `token ${config.token || process.env.token}`);
});
describe('home page', () => {
it('should render home page', () => this.get().expect(200).expect('Content-Type', /html/));
});
describe('api', () => {
before('verify github token provided', () => {
expect(process.env.token).to.be.a('string');
});
it('should not be authenticated to github with non-valid token', () => this.get({
path: '/me',
token: 'not-valid'
}).expect(401));
it('should retrieve concrete repo stats', () => this.get({path: '/vizydrop/github-data-link'}).expect(200)
.then((res) => {
const stats = res.body;
expect(stats).to.be.a('array');
expect(stats).to.have.length.above(0);
const entry = stats[0];
expect(entry).to.have.property('Code Additions');
expect(entry).to.have.property('Code Deletions');
expect(entry).to.have.property('Code Commits');
expect(entry).to.have.property('Code Commits');
expect(entry).to.have.property('Repository Owner');
expect(entry).to.have.property('Repository');
expect(entry).to.have.property('Repository Created On');
expect(entry).to.have.property('Repository Language');
expect(entry).to.have.property('Repository Size');
expect(entry).to.have.property('Is Private Repository');
expect(entry).to.have.property('Contributor');
expect(entry).to.have.property('Date');
}));
it('should retrieve stats for all repos where user is a member', () => this.get({path: '/me'}).expect(200));
it('should retrieve organization repo stats', () => this.get({path: '/vizydrop'}).expect(200));
it('should fail for incorrect organization repo stats', () => this.get({path: '/vizydrop666'}).expect(404));
it('should fail for incorrect concrete repo stats', () => this.get({path: '/vizydrop/666'}).expect(404));
it('should fail for incorrect team repo stats', () => this.get({path: '/vizydrop/teams/666'}).expect(404));
});
after((done) => this.app.close(done));
});