Lab BDD Setup
// Lab setup | |
var Code = require('code'); | |
var Lab = require('lab'); | |
var lab = exports.lab = Lab.script(); | |
var describe = lab.describe; | |
var it = lab.it; | |
var before = lab.before; | |
var after = lab.after; | |
var expect = Code.expect; | |
exports.run = function(tests) { | |
tests(describe, it, before, after, expect); | |
}; |
// String interpolation in ES6 | |
var runner = require('./setup'); | |
runner.run(function(describe, it, before, after, expect) { | |
describe('template strings, are wrapped in backticks', function () { | |
it('prints x into a string using ${x}', function (done) { | |
var x = 42; | |
expect(`x=${x}`).to.equal('x=' + x); | |
done(); | |
}); | |
it('add two numbers inside the ${...}', function (done) { | |
var x = 42; | |
var y = 23; | |
expect(`${ x + y}`).to.equal((x + y).toString()); | |
done(); | |
}); | |
it('get a function call result inside ${...}', function (done) { | |
function getDomain() { | |
return 'tddbin.com'; | |
} | |
expect(`${ getDomain() }`).to.equal('tddbin.com'); | |
done(); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment