我最近从mocha开始,想知道我们是否可以使用if else语句进行条件测试。我希望能够在everit()函数中使用条件,以便对响应该getprojection()函数调用而接收到的Json数据置入断言。
我已经发布了一个代码作为示例,以说明我要实现的目标。任何帮助,将不胜感激。谢谢!
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);
});
});
});
})