Skip to content

Commit 789adff

Browse files
committed
unit test pass for async batch / functional test expression pass
1 parent 5c73a37 commit 789adff

File tree

4 files changed

+74
-49
lines changed

4 files changed

+74
-49
lines changed

src/batch.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
var utils = require('./utils'),
1+
var config = require('./config'),
2+
utils = require('./utils'),
23
queue, has, waiting
34

45
reset()
56

67
exports.queue = function (binding, method) {
8+
if (!config.async) {
9+
binding['_' + method]()
10+
return
11+
}
712
if (!has[binding.id]) {
813
queue.push({
914
binding: binding,

src/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = {
22

33
prefix : 'v',
4+
async : true,
45
debug : false,
56
silent : false,
67
enterClass : 'v-enter',

test/functional/specs/expression.js

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,59 +3,69 @@
33
casper.test.begin('Expression', 19, function (test) {
44

55
casper
6-
.start('./fixtures/expression.html', function () {
7-
6+
.start('./fixtures/expression.html')
7+
.then(function () {
88
test.assertSelectorHasText('#normal p', 'Hello World!')
99
test.assertSelectorHasText('#lazy p', 'Hi Ho!')
1010
test.assertField('one', 'Hello')
1111
test.assertField('two', 'World')
1212
test.assertField('three', 'Hi')
1313
test.assertField('four', 'Ho')
14-
14+
})
15+
.thenEvaluate(function () {
1516
// setting value
16-
this.evaluate(function () {
17-
normal.one = 'Hola'
18-
})
17+
normal.one = 'Hola'
18+
})
19+
.then(function () {
1920
test.assertSelectorHasText('#normal p', 'Hola World!')
20-
test.assertField('one', 'Hola')
21-
21+
test.assertField('one', 'Hola')
22+
})
23+
.thenEvaluate(function () {
2224
// setting nested value
23-
this.evaluate(function () {
24-
normal.two.three = 'Casper'
25-
})
25+
normal.two.three = 'Casper'
26+
})
27+
.then(function () {
2628
test.assertSelectorHasText('#normal p', 'Hola Casper!')
27-
test.assertField('two', 'Casper')
28-
29+
test.assertField('two', 'Casper')
30+
})
31+
.then(function () {
2932
// lazy input
3033
this.fill('#form', {
3134
three: 'three',
3235
four: 'four'
3336
})
37+
})
38+
.then(function () {
3439
test.assertSelectorHasText('#lazy p', 'three four!')
35-
40+
})
41+
.then(function () {
3642
// normal input
3743
this.sendKeys('#one', 'Bye')
44+
})
45+
.then(function () {
3846
test.assertSelectorHasText('#normal p', 'Bye Casper!')
39-
40-
// v-on with expression
41-
this.click('#normal button')
47+
})
48+
// v-on with expression
49+
.thenClick('#normal button', function () {
4250
test.assertField('one', 'clicked')
4351
test.assertSelectorHasText('#normal p', 'clicked Casper!')
44-
45-
// v-on with expression
46-
this.click('#lazy button')
52+
})
53+
// v-on with expression
54+
.thenClick('#lazy button', function () {
4755
test.assertField('four', 'clicked')
4856
test.assertSelectorHasText('#lazy p', 'three clicked!')
49-
50-
// conditional expression
51-
// e.g. ok ? yesMSg : noMsg
52-
// make sure all three are captured as dependency
57+
})
58+
// conditional expression
59+
// e.g. ok ? yesMSg : noMsg
60+
// make sure all three are captured as dependency
61+
.then(function () {
5362
test.assertSelectorHasText('#conditional p', 'YES')
54-
this.click('#conditional .toggle')
63+
})
64+
.thenClick('#conditional .toggle', function () {
5565
test.assertSelectorHasText('#conditional p', 'NO')
56-
this.click('#conditional .change')
66+
})
67+
.thenClick('#conditional .change', function () {
5768
test.assertSelectorHasText('#conditional p', 'Nah')
58-
5969
})
6070
.run(function () {
6171
test.done()

test/unit/specs/api.js

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ describe('UNIT: API', function () {
201201
assert.strictEqual(Vue.transition(testId), transition)
202202
})
203203

204-
it('should work with v-transition', function () {
204+
it('should work with v-transition', function (done) {
205205

206206
var enterCalled = false,
207207
leaveCalled = false
@@ -230,14 +230,17 @@ describe('UNIT: API', function () {
230230
document.body.appendChild(t.$el)
231231

232232
t.show = true
233-
assert.ok(enterCalled)
234-
assert.strictEqual(t.$el.style.display, '')
235-
236-
t.show = false
237-
assert.ok(leaveCalled)
238-
assert.strictEqual(t.$el.style.display, 'none')
239-
240-
t.$destroy()
233+
setTimeout(function () {
234+
assert.ok(enterCalled)
235+
assert.strictEqual(t.$el.style.display, '')
236+
t.show = false
237+
setTimeout(function () {
238+
assert.ok(leaveCalled)
239+
assert.strictEqual(t.$el.style.display, 'none')
240+
t.$destroy()
241+
done()
242+
}, 0)
243+
}, 0)
241244
})
242245

243246
})
@@ -488,7 +491,7 @@ describe('UNIT: API', function () {
488491

489492
describe('directives', function () {
490493

491-
it('should allow the VM to use private directives', function () {
494+
it('should allow the VM to use private directives', function (done) {
492495
var Test = Vue.extend({
493496
directives: {
494497
test: function (value) {
@@ -506,7 +509,10 @@ describe('UNIT: API', function () {
506509
})
507510
assert.strictEqual(t.$el.innerHTML, 'YES')
508511
t.ok = false
509-
assert.strictEqual(t.$el.innerHTML, 'NO')
512+
setTimeout(function () {
513+
assert.strictEqual(t.$el.innerHTML, 'NO')
514+
done()
515+
}, 0)
510516
})
511517

512518
})
@@ -599,7 +605,7 @@ describe('UNIT: API', function () {
599605

600606
describe('transitions', function () {
601607

602-
it('should get called during transitions', function () {
608+
it('should get called during transitions', function (done) {
603609

604610
var enterCalled = false,
605611
leaveCalled = false
@@ -627,16 +633,19 @@ describe('UNIT: API', function () {
627633
})
628634

629635
document.body.appendChild(t.$el)
630-
631-
t.show = true
632-
assert.ok(enterCalled)
633-
assert.strictEqual(t.$el.style.display, '')
634-
635-
t.show = false
636-
assert.ok(leaveCalled)
637-
assert.strictEqual(t.$el.style.display, 'none')
638636

639-
t.$destroy()
637+
t.show = true
638+
setTimeout(function () {
639+
assert.ok(enterCalled)
640+
assert.strictEqual(t.$el.style.display, '')
641+
t.show = false
642+
setTimeout(function () {
643+
assert.ok(leaveCalled)
644+
assert.strictEqual(t.$el.style.display, 'none')
645+
t.$destroy()
646+
done()
647+
}, 0)
648+
}, 0)
640649

641650
})
642651

0 commit comments

Comments
 (0)