forked from github-tools/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorganization.spec.js
More file actions
105 lines (86 loc) · 3.31 KB
/
organization.spec.js
File metadata and controls
105 lines (86 loc) · 3.31 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import expect from 'must';
import Github from '../lib/GitHub';
import testUser from './fixtures/user.json';
import {assertSuccessful, assertArray} from './helpers/callbacks';
import getTestRepoName from './helpers/getTestRepoName';
describe('Organization', function() {
let github;
const ORG_NAME = 'github-tools';
const MEMBER_NAME = 'clayreimann';
before(function() {
github = new Github({
username: testUser.USERNAME,
password: testUser.PASSWORD,
auth: 'basic'
});
});
describe('reading', function() {
let organization;
before(function() {
organization = github.getOrganization(ORG_NAME);
});
it('should show user\'s organisation repos', function(done) {
organization.getRepos(assertArray(done));
});
it('should list the users in the organization', function(done) {
organization.listMembers()
.then(function({data: members}) {
expect(members).to.be.an.array();
let hasClayReimann = members.reduce((found, member) => member.login === MEMBER_NAME || found, false);
expect(hasClayReimann).to.be.true();
done();
}).catch(done);
});
it('should test for membership', function() {
return organization.isMember(MEMBER_NAME)
.then(function(isMember) {
expect(isMember).to.be.true();
});
});
});
describe('creating/updating', function() {
let organization;
const testRepoName = getTestRepoName();
before(function() {
organization = github.getOrganization(testUser.ORGANIZATION);
});
it('should create an organization repo', function(done) {
const options = {
name: testRepoName,
description: 'test create organization repo',
homepage: 'https://github.com/',
private: false,
has_issues: true, // eslint-disable-line
has_wiki: true, // eslint-disable-line
has_downloads: true // eslint-disable-line
};
organization.createRepo(options, assertSuccessful(done, function(err, repo) {
expect(repo.name).to.equal(testRepoName);
expect(repo.full_name).to.equal(`${testUser.ORGANIZATION}/${testRepoName}`); // eslint-disable-line
done();
}));
});
// TODO: The longer this is in place the slower it will get if we don't cleanup random test teams
it('should list the teams in the organization', function() {
return organization.getTeams()
.then(({data}) => {
const hasTeam = data.reduce(
(found, member) => member.slug === 'fixed-test-team-1' || found,
false);
expect(hasTeam).to.be.true();
});
});
it('should create an organization team', function(done) {
const options = {
name: testRepoName,
description: 'Created by unit tests',
privacy: 'secret'
};
organization.createTeam(options, assertSuccessful(done, function(err, team) {
expect(team.name).to.equal(testRepoName);
expect(team.organization.login).to.equal(testUser.ORGANIZATION); // jscs:ignore
done();
}));
});
});
});