forked from kaiwood/pnut-butter
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Kai Wood
committed
Mar 25, 2017
1 parent
5d17d62
commit 8473f08
Showing
4 changed files
with
60 additions
and
35 deletions.
There are no files selected for viewing
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,24 @@ | ||
'use strict'; | ||
|
||
/** | ||
* System | ||
*/ | ||
module.exports = (api) => { | ||
return { | ||
/** | ||
* Retrieve a list of parameters for interacting with the API. | ||
* @returns {Promise} | ||
*/ | ||
config() { | ||
return api.request('/sys/config'); | ||
}, | ||
|
||
/** | ||
* Retrieve basic statistics for the network. | ||
* @returns {Promise} | ||
*/ | ||
stats() { | ||
return api.request('/sys/stats'); | ||
} | ||
}; | ||
}; |
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,33 @@ | ||
const chai = require('chai'); | ||
const chaiAsPromised = require('chai-as-promised'); | ||
const nock = require('nock'); | ||
chai.use(chaiAsPromised); | ||
chai.should(); | ||
|
||
const pnut = require('../lib/pnut'); | ||
|
||
before(function () { | ||
let base = 'https://api.pnut.io/v0'; | ||
|
||
nock(base) | ||
.get('/sys/config') | ||
.reply(200, {}); | ||
|
||
nock(base) | ||
.get('/sys/stats') | ||
.reply(200, {}); | ||
}); | ||
|
||
after(function () { | ||
nock.cleanAll(); | ||
}); | ||
|
||
describe('System', () => { | ||
it('should be able to fetch sys/config', () => { | ||
return pnut.config().should.become({}); | ||
}); | ||
|
||
it('should be able to fetch sys/stats', () => { | ||
return pnut.stats().should.become({}); | ||
}); | ||
}); |