obf-connector
Version:
An API connector for Open Badge Factory
39 lines (37 loc) • 1.58 kB
JavaScript
const assert = require('chai').assert;
const ConnectorResponse = require('../lib/Response');
describe('ConnectorResponse', function() {
describe('new', function() {
it('Should throw with no status provided', function() {
assert.throws(()=>{ new ConnectorResponse(); }, Error);
});
it('Should throw with invalid status provided', function() {
assert.throws(()=>{ new ConnectorResponse('invalid'); }, Error);
});
it('Should not throw with valid states provided', function() {
assert.doesNotThrow(()=>{ new ConnectorResponse('complete'); }, Error);
assert.doesNotThrow(()=>{ new ConnectorResponse('incomplete'); }, Error);
assert.doesNotThrow(()=>{ new ConnectorResponse('error'); }, Error);
});
it('Should have a status', function() {
const status = 'complete';
const response = new ConnectorResponse(status);
assert.equal(response.status, status);
});
it('Should have data', function() {
const data = {a: {aa: 0}, b: 1};
const response = new ConnectorResponse('complete', data);
assert.deepEqual(response.data, data);
});
it('Should have a message', function() {
const message = 'This is a message.';
const response = new ConnectorResponse('complete', {}, message);
assert.equal(response.message, message);
});
it('Should have a targetURL', function() {
const targetURL = 'http://thue.systems';
const response = new ConnectorResponse('complete', {}, '', targetURL);
assert.equal(response.targetURL, targetURL);
});
});
});