lundi 30 mars 2015

Mocha/Chai Test linkTo Function Returning AssertionError

I'm trying to find & correct the Javascript code in challenge.js so that it passes the Mocha & Chai tests as specified in spec.js.... Nothing I try will get it to pass the tests when I run the command $ mocha spec.js in the Terminal.... To provide more information, the resulting error message that is continually returned in the Terminal regardless of any changes I make to challenge.js is shown underneath.


Challenge.js



module.exports.linkTo = function(text, address) {
return "<a href='" + text + "'>" + address + "</a>"
};


Spec.js



var expect = require("chai").expect;
var challenge = require("./challenge.js");

describe("linkTo", function() {
it("should be defined", function() {
expect(challenge.linkTo).to.exist;
});

it("should return a valid link for Bloc", function() {
expect(challenge.linkTo("Bloc", "http://www.bloc.io")).to.eql("<a href='http://www.bloc.io'>Bloc</a>");
});
});


Error Message as returned in Terminal



linkTo
✓ should be defined
1) should return a valid link for Bloc


1 passing (11ms)
1 failing

1) linkTo should return a valid link for Bloc:

AssertionError: expected '<a href=\'Bloc\'>http://ift.tt/1bILdnv;' to deeply equal '<a href=\'http://www.bloc.io\'>Bloc</a>'
+ expected - actual

+<a href='http://www.bloc.io'>Bloc</a>
-<a href='Bloc'>http://ift.tt/1bILdnv;

at Context.<anonymous> (/home/vagrant/frontend-javascript-exercises/02-reading-mocha-tests/00-a-tested-function/spec.js:10:63)
at callFn (/usr/local/lib/node_modules/mocha/lib/runnable.js:266:21)
at Test.Runnable.run (/usr/local/lib/node_modules/mocha/lib/runnable.js:259:7)
at Runner.runTest (/usr/local/lib/node_modules/mocha/lib/runner.js:387:10)
at /usr/local/lib/node_modules/mocha/lib/runner.js:470:12
at next (/usr/local/lib/node_modules/mocha/lib/runner.js:312:14)
at /usr/local/lib/node_modules/mocha/lib/runner.js:322:7
at next (/usr/local/lib/node_modules/mocha/lib/runner.js:257:23)
at Object._onImmediate (/usr/local/lib/node_modules/mocha/lib/runner.js:289:5)
at processImmediate [as _immediateCallback] (timers.js:336:15)


Can anyone PLEASE point out the correction(s) needed in challenge.js in order for the tests to pass when I run $ mocha spec.js in the Terminal???


Thanks in advance Lex


Aucun commentaire:

Enregistrer un commentaire