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
132 lines (109 loc) · 4.06 KB
/
organization.spec.js
File metadata and controls
132 lines (109 loc) · 4.06 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import expect from 'must';
import Github from '../lib/GitHub';
import testUser from './fixtures/user.js';
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';
let createdProject;
before(function() {
github = new Github({
username: testUser.USERNAME,
password: testUser.PASSWORD,
auth: 'basic',
});
createdProject = undefined;
});
after(function() {
if (createdProject) {
return github.getProject(createdProject.id).deleteProject();
}
});
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();
const hasClayReimann = members.some((member) => member.login === MEMBER_NAME);
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();
}));
});
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();
}));
});
it('should list the teams in the organization', function() {
return organization.getTeams()
.then(({data}) => {
const hasTeam = data.some((member) => member.slug === testRepoName);
expect(hasTeam).to.be.true();
});
});
it('should create a project', function(done) {
organization.createProject({
name: testRepoName,
body: 'body',
}, assertSuccessful(done, function(err, project) {
createdProject = project;
expect(project).to.own('name', testRepoName);
expect(project).to.own('body', 'body');
done();
}));
});
it('should list repo projects', function(done) {
organization.listProjects(assertSuccessful(done, function(err, projects) {
expect(projects).to.be.an.array();
const hasProject = projects.some((project) => project.name === testRepoName);
expect(hasProject).to.be.true();
done();
}));
});
});
});