-
Notifications
You must be signed in to change notification settings - Fork 0
/
solution.js
45 lines (35 loc) · 1.14 KB
/
solution.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// 2: template strings - multiline (solution)
// 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');
});
});
});