Skip to content

Commit 39b78fe

Browse files
committed
Tests: Added tests for Gist API
1 parent 56c0c52 commit 39b78fe

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

test/test.gist.js

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
'use strict';
2+
3+
var Github = require('../src/github.js');
4+
var testUser = require('./user.json');
5+
var github = new Github({
6+
username: testUser.USERNAME,
7+
password: testUser.PASSWORD,
8+
auth: 'basic'
9+
});
10+
11+
describe('Github.Gist', function() {
12+
var gist;
13+
14+
before(function() {
15+
gist = github.getGist('f1c0f84e53aa6b98ec03');
16+
});
17+
18+
it('should read gist', function(done) {
19+
gist.read(function(err, res) {
20+
should.not.exist(err);
21+
res.should.have.property('description', 'This is a test gist');
22+
res.files["README.md"].should.have.property('content', 'Hello World');
23+
24+
done();
25+
});
26+
});
27+
28+
it('should star', function(done) {
29+
gist.star(function(err) {
30+
should.not.exist(err);
31+
32+
gist.isStarred(function(err) {
33+
should.not.exist(err);
34+
35+
done();
36+
});
37+
});
38+
});
39+
});
40+
41+
describe('Creating new Github.Gist', function() {
42+
var gist;
43+
44+
before(function() {
45+
gist = github.getGist();
46+
});
47+
48+
it('should create gist', function(done) {
49+
var gistData = {
50+
description: 'This is a test gist',
51+
public: true,
52+
files: {
53+
'README.md': {
54+
content: 'Hello World'
55+
}
56+
}
57+
};
58+
59+
gist.create(gistData, function(err, res) {
60+
should.not.exist(err);
61+
res.should.have.property('description', gistData.description);
62+
res.should.have.property('public', gistData.public);
63+
res.should.have.property('id').to.be.a('string');
64+
done();
65+
});
66+
});
67+
});
68+
69+
describe('deleting a Github.Gist', function() {
70+
var gist;
71+
72+
before(function(done) {
73+
var gistData = {
74+
description: 'This is a test gist',
75+
public: true,
76+
files: {
77+
'README.md': {
78+
content: 'Hello World'
79+
}
80+
}
81+
};
82+
83+
github.getGist().create(gistData, function(err, res) {
84+
gist = github.getGist(res.id);
85+
86+
done();
87+
});
88+
});
89+
90+
it('should delete gist', function(done) {
91+
gist.delete(function(err) {
92+
should.not.exist(err);
93+
94+
done();
95+
});
96+
});
97+
});

0 commit comments

Comments
 (0)