我来教教你前端自动化单元测试如何做(7)

发表于:2016-09-22来源:segmentfault作者:acrens点击数: 标签:前端
() { var result = []; result.push( typeof null ); result.push( null instanceof Object ); return result;} /** - 检测操作符优先级 - @return {[string]} [返回字符串] */ function checkOperator
() { var result = []; result.push(typeof null); result.push(null instanceof Object); return result; } /** - 检测操作符优先级 - @return {[string]} [返回字符串] */ function checkOperators() { var result = 'autoTest'; result = 'Value is ' + (result === 'autoTest') ? 'Something' : 'Nothing'; return result; }
  • fqa.spec.js 测试代码

/**
 - test index.js checkMap method
 - detail:
 -     parseInt(val, base), base is 2 ~ 36, otherwise value equal NaN.
 */
describe('test map and callback parseInt', function() {
    
    it('a array call map', function() {
        var nums = checkMap();
        console.log(nums);

        expect([1, NaN, NaN]).toEqual(nums);
    });
});

/**
 - test index.js typeofAndInstanceOf method
 - detail:
 -     typeof null qeual 'object', but null instanceof Object equal false, because null Constructor not Object.
 */
describe('test null is object', function 



           

原文转自:https://segmentfault.com/a/1190000006969924