-
Notifications
You must be signed in to change notification settings - Fork 3
/
renderHtml.spec.js
51 lines (45 loc) · 1.36 KB
/
renderHtml.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
'use strict'
const { renderHtml } = require('../src')
const { expect } = require('chai')
describe('renderHtml' , () => {
it('works with elements', () => {
const $el = renderHtml({ template: '<div>Hello World!</div>' })
expect($el).to.exist
expect($el.html()).equals('Hello World!')
})
it('works with text nodes', () => {
const $el = renderHtml({ template: 'Hello World!' })
expect($el).to.exist
expect($el.html()).contains('Hello World!')
})
it('works with viewModel object', () => {
const $el = renderHtml({
template: '<div data-bind="text: greeting"></div>',
viewModel: { greeting: 'Hello Text Binding' }
})
expect($el).to.exist
expect($el.html()).equals('Hello Text Binding')
})
it('works with viewModel function', () => {
const $el = renderHtml({
template: '<div data-bind="text: greeting"></div>',
viewModel() {
this.greeting = 'Hello Text Binding'
}
})
expect($el).to.exist
expect($el.html()).equals('Hello Text Binding')
})
it('works with viewModel es6 class', () => {
const $el = renderHtml({
template: '<div data-bind="text: greeting"></div>',
viewModel: class ViewModel {
constructor() {
this.greeting = 'Hello Text Binding'
}
}
})
expect($el).to.exist
expect($el.html()).equals('Hello Text Binding')
})
})