-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increase code coverage in botbuilder library - StatusCodeError class (#…
…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
1 parent
9c56727
commit dd4d5e6
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}); | ||
}); | ||
}); |