So I'm trying to unit test a function I wrote here is the function:
function compareServices(service1, service2) {
if (service1.name != service2.name) {
return false
}
if (service1.port != service2.port) {
return false
}
if (service1.target != service2.target) {
return false
}
if (service1.address != service2.address) {
return false
}
return true
}
it is located inside my main.js file. Now When I try to run the test I get an error saying:
Main #compareServices() should compare if two services match:
TypeError: main.compareServices is not a function
at Context.<anonymous> (test/stelaSpec.js:21:25
And here is my test file:
var expect = require("chai").expect;
var main = require("../src/main.js");
describe("Main", function(){
describe('#compareServices()', function() {
it('should compare if two services match', function() {
var svc1 = {
"name": "test.fg.service",
"port": 8001,
"target": "mac-book",
"address": "192.2.2.2"
}
var svc2 = {
"name": "test.fg.service",
"port": 8001,
"target": "mac-book",
"address": "192.2.2.2"
}
var result = main.compareServices(svc1, svc2);
expect(result).equal(true)
});
});
});
Why is it saying it is not a function when it is?
Aucun commentaire:
Enregistrer un commentaire