Extensions to the Mocha test framework for use with Flight
flight-mocha is based on flight-jasmine but assertion and Test Double libraries aren't included.
Recommend using Bower
% bower install --save-dev flight-mocha
flight-mocha depends on mocha
In this examples, assertion library uses the expect.js
describeComponent('path/to/component', function() {
beforeEach(function() {
setupComponent();
});
it("should do x", function() {
// a component instance is now accessible as this.component
// the component root node is attached to the DOM
// the component root node is also available as this.$node
});
});
describeMixin('path/to/mixin', function() {
// initialize the component and attach it to the DOM
beforeEach(function() {
setupComponent();
});
it("should do x", function() {
expect(this.component.doSomething()).to.be(expected);
});
});
Please use the sinon.js or other similar library.
setupComponent(optionalFixture, optionalOptions);
Calling setupComponent
twice will create an instance, tear it down and create a new one.
describeComponent('ui/twitter_profile', function() {
// is the component attached to the fixture?
it("this.component.$node has class 'foo'", function() {
setupComponent('<span class="foo">Test</span>');
expect(this.component.$node.find('span').hasClass('foo')).to.be.ok();
});
});
describeComponent('data/twitter_profile', function() {
// is the option set correctly?
it("this.component.attr.baseUrl is set", function() {
setupComponent({
baseUrl: 'http://twitter.com/1.1/'
});
expect(this.component.attr.baseUrl).to.be('http://twitter.com/1.1/');
});
});
Components are automatically torn down after each test.
Copyright (c) 2013 Naoya Inada naoina@kuune.org
Licensed under the MIT License