tests need to use the 'new' keyword
This commit is contained in:
parent
730252e529
commit
e5fce06c9a
1 changed files with 9 additions and 30 deletions
39
test/one.js
39
test/one.js
|
|
@ -5,13 +5,13 @@ process.env.NODE_ENV = 'test';
|
||||||
|
|
||||||
describe('NPR One', function() {
|
describe('NPR One', function() {
|
||||||
|
|
||||||
this.timeout(10000);
|
|
||||||
|
|
||||||
describe('Init', function() {
|
describe('Init', function() {
|
||||||
|
|
||||||
|
this.timeout(15000);
|
||||||
|
|
||||||
it('should create a client', function(done) {
|
it('should create a client', function(done) {
|
||||||
|
|
||||||
npr = NPR();
|
npr = new NPR();
|
||||||
|
|
||||||
npr.one.init()
|
npr.one.init()
|
||||||
.then(function() { done(); })
|
.then(function() { done(); })
|
||||||
|
|
@ -23,38 +23,19 @@ describe('NPR One', function() {
|
||||||
|
|
||||||
describe('Authorization', function() {
|
describe('Authorization', function() {
|
||||||
|
|
||||||
it('should get an access token using password grant type', function(done) {
|
it('should set access token without error', function(done) {
|
||||||
|
npr.one.setAccessToken(process.env.NPR_ACCESS_TOKEN).then(function() { return done(); }).catch(done);
|
||||||
npr.one.authorization
|
|
||||||
.createToken({
|
|
||||||
grant_type: 'password',
|
|
||||||
client_id: process.env.CLIENT_ID,
|
|
||||||
client_secret: process.env.CLIENT_SECRET,
|
|
||||||
username: process.env.NPR_USERNAME,
|
|
||||||
password: process.env.NPR_PASSWORD
|
|
||||||
})
|
|
||||||
.then(function(res) {
|
|
||||||
|
|
||||||
if(! res.access_token)
|
|
||||||
return done('missing access token');
|
|
||||||
|
|
||||||
npr.one.setAccessToken(res.access_token);
|
|
||||||
|
|
||||||
done();
|
|
||||||
|
|
||||||
}).catch(done);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Listening', function() {
|
describe('Listening', function() {
|
||||||
|
|
||||||
|
this.timeout(15000);
|
||||||
|
|
||||||
it('should get channels', function(done) {
|
it('should get channels', function(done) {
|
||||||
|
|
||||||
npr.one.listening
|
npr.one.listening.getChannels().then(function(res) {
|
||||||
.getChannels()
|
|
||||||
.then(function(res) {
|
|
||||||
|
|
||||||
if(! res.items.length)
|
if(! res.items.length)
|
||||||
return done('missing channels');
|
return done('missing channels');
|
||||||
|
|
@ -67,9 +48,7 @@ describe('NPR One', function() {
|
||||||
|
|
||||||
it('should get history', function(done) {
|
it('should get history', function(done) {
|
||||||
|
|
||||||
npr.one.listening
|
npr.one.listening.getHistory().then(function(res) {
|
||||||
.getHistory()
|
|
||||||
.then(function(res) {
|
|
||||||
|
|
||||||
if(! res.items.length)
|
if(! res.items.length)
|
||||||
return done('missing history');
|
return done('missing history');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue