Skip to content

Instantly share code, notes, and snippets.

@Oliver-ke
Created May 29, 2019 09:38
Show Gist options
  • Save Oliver-ke/8b71f38f183d79649c90b884a5dec880 to your computer and use it in GitHub Desktop.
Save Oliver-ke/8b71f38f183d79649c90b884a5dec880 to your computer and use it in GitHub Desktop.
const { assert } = require('chai');
const computeResult = require('../challange/computeResult');
describe('return sum', () => {
it('Must be a function', () => {
assert.isFunction(computeResult, 'must be a function');
});
it('Return the result', () => {
const answers = [ 'a', 'b', 'a', 'c' ];
const studentAns = [ 'a', 'c', 'd', 'c' ];
const sum = computeResult(answers, studentAns);
assert.equal(sum, 6);
});
it('Account for empty answers', () => {
const answers = [ 'a', 'b', 'a', 'c' ];
const studentAns = [ 'a', 'c', 'd', ' ' ];
const sum = computeResult(answers, studentAns);
assert.equal(sum, 2);
});
it('Return 0 if result is less than zero', () => {
const answers = [ 'a', 'b', 'a', 'c' ];
const studentAns = [ 'c', 'c', 'd', 'm' ];
const sum = computeResult(answers, studentAns);
assert.equal(sum, 0);
});
});
@Oliver-ke
Copy link
Author

Test for computing result function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment