portals
Version:
An XHR/Ajax library with sugar for single page applications.
35 lines (28 loc) • 658 B
JavaScript
describe('Portal#onCatch()', function () {
// test instance
var web;
/**
* @beforeEach
*/
beforeEach(function () {
// instantiate a new portal instance
web = new portals.Portal();
});
/**
* @test
*/
it('throws an error if given value is not a function', function () {
expect(function () {
web.onCatch(true);
}).to.throw('Interceptor must be a function!');
});
/**
* @test
*/
it('successfully adds an interceptor', function () {
var fn = function () {};
web.onCatch(fn);
var last = web._catchInterceptors.length - 1;
expect(web._catchInterceptors[last]).to.equal(fn)
});
});