Skip to content

Instantly share code, notes, and snippets.

@jhartikainen
Last active February 13, 2016 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhartikainen/864e1ed4886f2e3b6977 to your computer and use it in GitHub Desktop.
Save jhartikainen/864e1ed4886f2e3b6977 to your computer and use it in GitHub Desktop.
Vue.js example component unit test
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