class/nodejs

21/04/28 mocha module test

tech-lover 2021. 4. 29. 00:19

실습(module) : 30-mocha-module.js, 30-mocha-module-test.js

30-mocha-module.js

module.exports = {
    sum: function (num1, num2) {
        return num1 + num2;
    }
};

30-mocha-module-test.js

var chai = require('chai'),
    moduleSum = require('./30-mocha-module'),
    expect = chai.expect;

describe('#ModuleSum', function () {
    it("sum()", function () {
        expect(moduleSum.sum(1, 2)).to.equal(3);
        expect(moduleSum.sum(3, 2)).to.equal(5);
        expect(moduleSum.sum(5, 0)).to.equal(5);
    })
});

'class > nodejs' 카테고리의 다른 글

21/04/28 (nodejs) mocha test framework install  (0) 2021.04.28