koa-lite/test/context/assert.js

20 lines
398 B
JavaScript
Raw Normal View History

'use strict';
const context = require('../helpers/context');
const assert = require('assert');
describe('ctx.assert(value, status)', () => {
it('should throw an error', () => {
const ctx = context();
try {
ctx.assert(false, 404);
throw new Error('asdf');
} catch (err) {
2017-05-11 03:30:32 +00:00
assert.equal(err.status, 404);
assert.strictEqual(err.expose, true);
}
2015-10-12 20:36:41 +00:00
});
});