Skip to content

Commit

Permalink
Increase code coverage in botbuilder library - StatusCodeError class (#…
Browse files Browse the repository at this point in the history
…2494)

* Add statusCodeError unit tests

* Encapsulate tests in constructor()

Co-authored-by: Joel Mut <[email protected]>
Co-authored-by: Cecilia Avila <[email protected]>
  • Loading branch information
3 people authored Jul 8, 2020
1 parent 9c56727 commit dd4d5e6
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions libraries/botbuilder/tests/statusCodeError.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/

const assert = require('assert');
const { StatusCodeError } = require('../');
const { StatusCodes } = require('botbuilder-core');

describe(`StatusCodeError`, function() {
describe('constructor()', () => {
it(`should work with a message.`, done => {
try {
const message = 'This is an error message';
const error = new StatusCodeError(StatusCodes.NOT_FOUND, message);

assert.strictEqual(error.message, message, `message should be equal to "${message}".`)
assert.strictEqual(error.statusCode, StatusCodes.NOT_FOUND, `statusCode should be the code ${StatusCodes.NOT_FOUND}`)
done();
} catch (error) {
done(error);
}
});

it(`should work without a message.`, done => {
try {
const error = new StatusCodeError(StatusCodes.NOT_FOUND);

assert.strictEqual(error.message, '', 'message should be empty.')
assert.strictEqual(error.statusCode, StatusCodes.NOT_FOUND, `statusCode should be the code ${StatusCodes.NOT_FOUND}`)
done();
} catch (error) {
done(error);
}
});

it(`should statusCode be undefined if not passed as a parameter.`, done => {
try {
const error = new StatusCodeError();

assert.strictEqual(error.statusCode, undefined, 'statusCode should be undefined.')
done();
} catch (error) {
done(error);
}
});
});
});

0 comments on commit dd4d5e6

Please sign in to comment.