Skip to content

Instantly share code, notes, and snippets.

@58bits
Created August 28, 2015 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save 58bits/a000bd4a9a4b7b73c606 to your computer and use it in GitHub Desktop.
Save 58bits/a000bd4a9a4b7b73c606 to your computer and use it in GitHub Desktop.
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