-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.spec.js
74 lines (64 loc) · 1.66 KB
/
example.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* global
$j
beforeEach
describe
it
expect
jasmine
*/
import App from '../resources/assets/js/app.js'
function setUpHTMLFixture () {
jasmine.getFixtures().set(require('./fixture.html'))
}
function getApp (state, opts = {}) {
let options = Object.assign({}, {
el: '#vue-app'
}, opts)
let initialState = Object.assign({}, {
message: 'Hello'
}, state || {})
return App.init(options, initialState)
}
describe('MortgageCalculator', function () {
beforeEach(function () {
setUpHTMLFixture()
})
it('Should initialize', function () {
const app = getApp()
expect('Hello').toEqual(app.message)
})
it('Should allow deep data object', function () {
const app = getApp({
messages: [
{
message: {
en: 'Hello World',
es: 'Hola Mundo'
}
}
]
})
expect('Hello World').toEqual(app.messages[0].message.en)
expect('Hola Mundo').toEqual(app.messages[0].message.es)
})
it('Should render data to view', function (done) {
const app = getApp()
expect($j('#message').val()).toEqual(app.message)
// update message requires nextTick
app.message = 'New message'
app.$nextTick(function () {
expect($j('#message').val()).toEqual(app.message)
done()
})
})
it('Should update model when input value changes', function (done) {
const app = getApp()
expect($j('#message').val()).toEqual(app.message)
// update message requires nextTick
$j('#message').val('New message').trigger('change')
app.$nextTick(function () {
expect(app.message).toEqual('New message')
done()
})
})
})