-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Hovhannes Babayan
committed
Dec 30, 2014
1 parent
680c3d0
commit fd875fb
Showing
20 changed files
with
132 additions
and
68 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var chai = require('chai'); | ||
var chaiAsPromised = require("chai-as-promised"); | ||
|
||
chai.use(chaiAsPromised); | ||
|
||
var expect = chai.expect; | ||
|
||
global.chai = chai; | ||
global.expect = expect; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
require('./../common'); | ||
var nock = require('nock'); | ||
|
||
var Api = require('./../../').Api; | ||
|
||
|
||
describe('Api. request() method', function() { | ||
|
||
it('should resolve returned promise with data if everything went ok', function(done) { | ||
var url = 'http://foobar:8080', | ||
path = '/test', | ||
params = { | ||
'foo': 1, | ||
'bar': 'baz' | ||
}, | ||
fields = [ | ||
'*', 'owner:*' | ||
], | ||
method = 'GET'; | ||
|
||
nock(url) | ||
.get('/attask/api' + path + '?foo=1&bar=baz&fields=*%2Cowner%3A*') | ||
.reply(200, { | ||
data: { | ||
'got': 'ok' | ||
} | ||
}); | ||
|
||
var api = new Api({url: url}); | ||
var promise = api.request(path, params, fields, method); | ||
expect(promise).to.eventually.deep.equal({'got': 'ok'}).and.notify(done); | ||
}); | ||
|
||
it('should reject returned promise with error data on error', function(done) { | ||
var url = 'http://foobar:8080', | ||
path = '/test', | ||
params = { | ||
'foo': 1, | ||
'bar': 'baz' | ||
}, | ||
fields = [ | ||
'*', 'owner:*' | ||
], | ||
method = 'GET'; | ||
|
||
nock(url) | ||
.get('/attask/api' + path + '?foo=1&bar=baz&fields=*%2Cowner%3A*') | ||
.reply(500, { | ||
error: { | ||
'message': 'fail' | ||
} | ||
}); | ||
|
||
var api = new Api({url: url}); | ||
var promise = api.request(path, params, fields, method); | ||
expect(promise).to.be.rejectedWith({'message': 'fail'}).and.notify(done); | ||
}); | ||
}); |