I recently started with mocha and wanted to know if we could use if else statements for conditional testing. I want to be able to use conditions in ever it() function in order to put assertions on Json data received in response to that getprojection() function call.
I have posted a code as an example to illustrate what I am trying to achieve. Any help would be appreciated. Thanks!!
var assert = require('chai').assert;
var expect = require('chai').expect;
var should = require('chai').should();
// var projection = require('');
var projectionsTest = require('./getProjection')
describe("Annual Tax Projection", function () {
describe("Current Year Tax - #2018", function () {
it("should return correct taxable Income", function (done) {
projectionsTest.getProjection('params', 'params', function (projections) {
if (grossIncome <= deductions){
assert.deepEqual(projections[2018].taxableIncome, 0)
}else throw new Error("There is something wrong with tax calculation")
done(Error);
});
});
it("should check federal tax is calculated correctly", function (done) {
projectionsTest.getProjection('params', 'params', function (projections) {
if (taxableIncome === 0 || taxBracket ===10){
assert.deepEqual(projections[2018]. )
}else
done(Error);
});
});
});
})
Aucun commentaire:
Enregistrer un commentaire