deno.land / x / rambda@v9.1.1 / source / interpolate.spec.js

interpolate.spec.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { interpolate } from './interpolate.js'
test('within bracets', () => { const input = 'foo is { {{bar}} } even {{a}} more' const templateInput = { bar : 'BAR', a : 1, }
const result = interpolate(input, templateInput) const expectedResult = 'foo is { BAR } even 1 more'
expect(result).toEqual(expectedResult)})
test('happy', () => { const input = 'foo is {{bar}} even {{a}} more' const templateInput = { bar : 'BAR', a : 1, }
const result = interpolate(input, templateInput) const expectedResult = 'foo is BAR even 1 more'
expect(result).toEqual(expectedResult)})
test('no interpolation + curry', () => { const input = 'foo is bar even more' const templateInput = { bar : 'BAR' }
const result = interpolate(input)(templateInput) const expectedResult = 'foo is bar even more'
expect(result).toEqual(expectedResult)})
test('with missing template input', () => { const input = 'foo is {{bar}} even {{a}} more' const templateInput = { baz : 'BAR', a : 1, }
const result = interpolate(input, templateInput) const expectedResult = 'foo is undefined even 1 more'
expect(result).toEqual(expectedResult)})
test('with arbitrary expression', () => { const input = '1 + 2 = {{ 1 + 2 }}' const templateInput = {}
const result = interpolate(input, templateInput)
expect(result).toEqual(input)})
rambda

Version Info

Tagged at
2 months ago