|
2 | 2 |
|
3 | 3 | var Github = require('../src/github.js'); |
4 | 4 | var testUser = require('./user.json'); |
5 | | -var github, repo, user, imageB64, imageBlob; |
| 5 | +var RELEASE_TAG = 'foo'; |
| 6 | +var RELEASE_NAME = 'My awesome release'; |
| 7 | +var RELEASE_BODY = 'Foo bar bazzy baz'; |
| 8 | +var STATUS_URL = 'https://api.github.com/repos/michael/github/statuses/20fcff9129005d14cc97b9d59b8a3d37f4fb633b'; |
| 9 | +var github, repo, user, imageB64, imageBlob, sha, releaseId; |
6 | 10 |
|
7 | 11 | if (typeof window === 'undefined') { // We're in NodeJS |
8 | 12 | var fs = require('fs'); |
@@ -33,6 +37,7 @@ if (typeof window === 'undefined') { // We're in NodeJS |
33 | 37 | // jscs:disable |
34 | 38 | imageB64 = 'iVBORw0KGgoAAAANSUhEUgAAACsAAAAmCAAAAAB4qD3CAAABgElEQVQ4y9XUsUocURQGYN/pAyMWBhGtrEIMiFiooGuVIoYsSBAsRSQvYGFWC4uFhUBYsilXLERQsDA20YAguIbo5PQp3F3inVFTheSvZoavGO79z+mJP0/Pv2nPtlfLpfLq9tljNquO62S8mj1kmy/8nrHm/Xaz1930bt5n1+SzVmyrilItsod9ON0td1V59xR9hwV2HsMRsbfROLo4amzsRcQw5vO2CZPJEU5CM2cXYTCxg7CY2mwIVhK7AkNZYg9g4CqxVwNwkNg6zOTKMQP1xFZgKWeXoJLYdSjl7BysJ7YBIzk7Ap8TewLOE3oOTtIz6y/64bfQn55ZTIAPd2gNTOTurcbzp7z50v1y/Pq2Q7Wczca8vFjG6LvbMo92hiPL96xO+eYVPkVExMdONetFXZ+l+eP9cuV7RER8a9PZwrloTXv2tfv285ZOt4rnrTXlydxCu9sZmGrdN8eXC3ATERHXsHD5wC7ZL3HdsaX9R3bUzlb7YWvn/9ipf93+An8cHsx3W3WHAAAAAElFTkSuQmCC'; |
35 | 39 | imageBlob = new Blob(); |
| 40 | + |
36 | 41 | // jscs:enable |
37 | 42 | } |
38 | 43 | } |
@@ -207,7 +212,7 @@ describe('Github.Repository', function() { |
207 | 212 | xhr.should.be.instanceof(XMLHttpRequest); |
208 | 213 | statuses.length.should.equal(6); |
209 | 214 | statuses.every(function(status) { |
210 | | - return status.url === 'https://api.github.com/repos/michael/github/statuses/20fcff9129005d14cc97b9d59b8a3d37f4fb633b'; |
| 215 | + return status.url === STATUS_URL; |
211 | 216 | }).should.equal(true); |
212 | 217 |
|
213 | 218 | done(); |
@@ -534,6 +539,7 @@ describe('Creating new Github.Repository', function() { |
534 | 539 | }, function(err, res, xhr) { |
535 | 540 | should.not.exist(err); |
536 | 541 | xhr.should.be.instanceof(XMLHttpRequest); |
| 542 | + sha = res.commit.sha; |
537 | 543 |
|
538 | 544 | done(); |
539 | 545 | }); |
@@ -578,6 +584,54 @@ describe('Creating new Github.Repository', function() { |
578 | 584 | }); |
579 | 585 | }); |
580 | 586 | }); |
| 587 | + |
| 588 | + it('should create a release', function(done) { |
| 589 | + var options = { |
| 590 | + tag_name: RELEASE_TAG, |
| 591 | + target_commitish: sha |
| 592 | + }; |
| 593 | + |
| 594 | + repo.createRelease(options, function(err, res, xhr) { |
| 595 | + should.not.exist(err); |
| 596 | + xhr.should.be.instanceof(XMLHttpRequest); |
| 597 | + |
| 598 | + releaseId = res.id; |
| 599 | + done(); |
| 600 | + }); |
| 601 | + }); |
| 602 | + |
| 603 | + it('should edit a release', function(done) { |
| 604 | + var options = { |
| 605 | + name: RELEASE_NAME, |
| 606 | + body: RELEASE_BODY |
| 607 | + }; |
| 608 | + |
| 609 | + repo.editRelease(releaseId, options, function(err, res, xhr) { |
| 610 | + should.not.exist(err); |
| 611 | + res.name.should.equal(RELEASE_NAME); |
| 612 | + res.body.should.equal(RELEASE_BODY); |
| 613 | + xhr.should.be.instanceof(XMLHttpRequest); |
| 614 | + |
| 615 | + done(); |
| 616 | + }); |
| 617 | + }); |
| 618 | + |
| 619 | + it('should read a release', function(done) { |
| 620 | + repo.getRelease(releaseId, function(err, res, xhr) { |
| 621 | + should.not.exist(err); |
| 622 | + res.name.should.equal(RELEASE_NAME); |
| 623 | + xhr.should.be.instanceof(XMLHttpRequest); |
| 624 | + done(); |
| 625 | + }); |
| 626 | + }); |
| 627 | + |
| 628 | + it('should delete a release', function(done) { |
| 629 | + repo.deleteRelease(releaseId, function(err, res, xhr) { |
| 630 | + should.not.exist(err); |
| 631 | + xhr.should.be.instanceof(XMLHttpRequest); |
| 632 | + done(); |
| 633 | + }); |
| 634 | + }); |
581 | 635 | }); |
582 | 636 |
|
583 | 637 | describe('deleting a Github.Repository', function() { |
|
0 commit comments