Skip to content

Commit

Permalink
unit test pass for async batch / functional test expression pass
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Dec 24, 2013
1 parent 5c73a37 commit 789adff
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 49 deletions.
7 changes: 6 additions & 1 deletion src/batch.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
var utils = require('./utils'),
var config = require('./config'),
utils = require('./utils'),
queue, has, waiting

reset()

exports.queue = function (binding, method) {
if (!config.async) {
binding['_' + method]()
return
}
if (!has[binding.id]) {
queue.push({
binding: binding,
Expand Down
1 change: 1 addition & 0 deletions src/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {

prefix : 'v',
async : true,
debug : false,
silent : false,
enterClass : 'v-enter',
Expand Down
64 changes: 37 additions & 27 deletions test/functional/specs/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,69 @@
casper.test.begin('Expression', 19, function (test) {

casper
.start('./fixtures/expression.html', function () {

.start('./fixtures/expression.html')
.then(function () {
test.assertSelectorHasText('#normal p', 'Hello World!')
test.assertSelectorHasText('#lazy p', 'Hi Ho!')
test.assertField('one', 'Hello')
test.assertField('two', 'World')
test.assertField('three', 'Hi')
test.assertField('four', 'Ho')

})
.thenEvaluate(function () {
// setting value
this.evaluate(function () {
normal.one = 'Hola'
})
normal.one = 'Hola'
})
.then(function () {
test.assertSelectorHasText('#normal p', 'Hola World!')
test.assertField('one', 'Hola')

test.assertField('one', 'Hola')
})
.thenEvaluate(function () {
// setting nested value
this.evaluate(function () {
normal.two.three = 'Casper'
})
normal.two.three = 'Casper'
})
.then(function () {
test.assertSelectorHasText('#normal p', 'Hola Casper!')
test.assertField('two', 'Casper')

test.assertField('two', 'Casper')
})
.then(function () {
// lazy input
this.fill('#form', {
three: 'three',
four: 'four'
})
})
.then(function () {
test.assertSelectorHasText('#lazy p', 'three four!')

})
.then(function () {
// normal input
this.sendKeys('#one', 'Bye')
})
.then(function () {
test.assertSelectorHasText('#normal p', 'Bye Casper!')

// v-on with expression
this.click('#normal button')
})
// v-on with expression
.thenClick('#normal button', function () {
test.assertField('one', 'clicked')
test.assertSelectorHasText('#normal p', 'clicked Casper!')

// v-on with expression
this.click('#lazy button')
})
// v-on with expression
.thenClick('#lazy button', function () {
test.assertField('four', 'clicked')
test.assertSelectorHasText('#lazy p', 'three clicked!')

// conditional expression
// e.g. ok ? yesMSg : noMsg
// make sure all three are captured as dependency
})
// conditional expression
// e.g. ok ? yesMSg : noMsg
// make sure all three are captured as dependency
.then(function () {
test.assertSelectorHasText('#conditional p', 'YES')
this.click('#conditional .toggle')
})
.thenClick('#conditional .toggle', function () {
test.assertSelectorHasText('#conditional p', 'NO')
this.click('#conditional .change')
})
.thenClick('#conditional .change', function () {
test.assertSelectorHasText('#conditional p', 'Nah')

})
.run(function () {
test.done()
Expand Down
51 changes: 30 additions & 21 deletions test/unit/specs/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ describe('UNIT: API', function () {
assert.strictEqual(Vue.transition(testId), transition)
})

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

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

t.show = true
assert.ok(enterCalled)
assert.strictEqual(t.$el.style.display, '')

t.show = false
assert.ok(leaveCalled)
assert.strictEqual(t.$el.style.display, 'none')

t.$destroy()
setTimeout(function () {
assert.ok(enterCalled)
assert.strictEqual(t.$el.style.display, '')
t.show = false
setTimeout(function () {
assert.ok(leaveCalled)
assert.strictEqual(t.$el.style.display, 'none')
t.$destroy()
done()
}, 0)
}, 0)
})

})
Expand Down Expand Up @@ -488,7 +491,7 @@ describe('UNIT: API', function () {

describe('directives', function () {

it('should allow the VM to use private directives', function () {
it('should allow the VM to use private directives', function (done) {
var Test = Vue.extend({
directives: {
test: function (value) {
Expand All @@ -506,7 +509,10 @@ describe('UNIT: API', function () {
})
assert.strictEqual(t.$el.innerHTML, 'YES')
t.ok = false
assert.strictEqual(t.$el.innerHTML, 'NO')
setTimeout(function () {
assert.strictEqual(t.$el.innerHTML, 'NO')
done()
}, 0)
})

})
Expand Down Expand Up @@ -599,7 +605,7 @@ describe('UNIT: API', function () {

describe('transitions', function () {

it('should get called during transitions', function () {
it('should get called during transitions', function (done) {

var enterCalled = false,
leaveCalled = false
Expand Down Expand Up @@ -627,16 +633,19 @@ describe('UNIT: API', function () {
})

document.body.appendChild(t.$el)

t.show = true
assert.ok(enterCalled)
assert.strictEqual(t.$el.style.display, '')

t.show = false
assert.ok(leaveCalled)
assert.strictEqual(t.$el.style.display, 'none')

t.$destroy()
t.show = true
setTimeout(function () {
assert.ok(enterCalled)
assert.strictEqual(t.$el.style.display, '')
t.show = false
setTimeout(function () {
assert.ok(leaveCalled)
assert.strictEqual(t.$el.style.display, 'none')
t.$destroy()
done()
}, 0)
}, 0)

})

Expand Down

0 comments on commit 789adff

Please sign in to comment.