mirror of
https://github.com/ferrous-systems/embedded-trainings-2020.git
synced 2025-02-05 12:22:26 +00:00
a4ee38540d
We bundle markdown-it-kroki, which can add mermaid diagrams to marp slides using https://kroki.io.
35 lines
No EOL
1.2 KiB
JavaScript
35 lines
No EOL
1.2 KiB
JavaScript
const expect = require('chai').expect;
|
|
const contract = require('../../lib/contract');
|
|
|
|
describe('# [unit test]: contract.js', () => {
|
|
describe('## toNonEmptyString()', () => {
|
|
['abc', ' ', ' abc '].forEach((test) => {
|
|
it(`* normal cases. { testcase: ${test} }`, () => {
|
|
expect(() => {
|
|
contract.toNonEmptyString(test);
|
|
}).not.to.throw();
|
|
})
|
|
});
|
|
['', null, undefined, 123, 0.123, true, { test: 123 }].forEach((test) => {
|
|
it(`* abnormal cases. { testcase: ${test} }`, () => {
|
|
expect(() => {
|
|
contract.toNonEmptyString(test);
|
|
}).to.throw();
|
|
})
|
|
});
|
|
});
|
|
describe('## toTrue', () => {
|
|
it('* normal case. {test case: true}', () => {
|
|
expect(() => {
|
|
contract.toTrue(true);
|
|
}).not.to.throw();
|
|
});
|
|
['', null, undefined, 123, 0.123, false, { test: 123 }].forEach((test) => {
|
|
it(`* abnormal cases. { testcase: ${test} }`, () => {
|
|
expect(() => {
|
|
contract.toTrue(test);
|
|
}).to.throw();
|
|
})
|
|
});
|
|
});
|
|
}) |