Created
August 28, 2015 18:33
-
-
Save 58bits/a000bd4a9a4b7b73c606 to your computer and use it in GitHub Desktop.
Lab BDD Setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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