Skip to content

Instantly share code, notes, and snippets.

@underwindfall
Created March 1, 2017 09:50
Show Gist options
  • Save underwindfall/bf45e6bb8eefa237411479b206998219 to your computer and use it in GitHub Desktop.
Save underwindfall/bf45e6bb8eefa237411479b206998219 to your computer and use it in GitHub Desktop.
Answers of Es6katas [http://es6katas.org/]
// 2: template strings - multiline
// To do: make all tests pass, leave the asserts unchanged!
describe('template string, can contain multiline content', function() {
it('a normal string can`t span across multiple lines', function() {
var normalString = 'line1' +
'\n' +
'line2';
assert.equal(normalString, 'line1\nline2');
});
it('wrapped in backticks it can span over multiple lines', function() {
var templateString = `line1
line2`;
assert.equal(templateString, 'line1\nline2');
});
it('even over more than two lines', function() {
var multiline = `line 1
line 2
line 3
line 4`;
assert.equal(multiline.split('\n').length, 4);
});
describe('and expressions inside work too', function() {
var x = 42;
it('like simple variables', function() {
var multiline = `line 1
${x}`;
assert.equal(multiline, 'line 1\n 42');
});
it('also here spaces matter', function() {
var multiline = `
${x}`;
assert.equal(multiline, '\n42');
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment