Last active
February 13, 2016 18:07
-
-
Save jhartikainen/864e1ed4886f2e3b6977 to your computer and use it in GitHub Desktop.
Vue.js example component unit test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assert = require('assert'); | |
var Vue = require('vue'); | |
var TestComponent = Vue.extend({ | |
data: function() { | |
return { | |
active: false | |
}; | |
}, | |
methods: { | |
close: function() { | |
//this logs true, since we set active to true in the test. otherwise this would be false as default | |
console.log(this.active); | |
this.active = false; | |
} | |
} | |
}); | |
describe('test', function() { | |
it('bar', function() { | |
var comp = new TestComponent(); | |
comp.active = true; | |
console.log(comp.active); // -> true | |
comp.close(); | |
assert.equal(comp.active, false); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment