-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
example: commonjs/node based approach #44
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,9 @@ | |
"jQuery", | ||
"$", | ||
"describe", | ||
"ddescribe", | ||
"it", | ||
"iit", | ||
"expect", | ||
"beforeEach", | ||
"afterEach", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,12 @@ | |
* Licensed under the MIT License | ||
*/ | ||
|
||
(function (root) { | ||
|
||
(function (root, jasmine) { | ||
'use strict'; | ||
|
||
var flight = require('flightjs'); | ||
|
||
jasmine.flight = {}; | ||
|
||
/** | ||
|
@@ -49,13 +52,9 @@ | |
this.component = (new this.Component()).initialize(this.$node, options); | ||
}; | ||
|
||
var requireCallback = function (registry, Component) { | ||
registry.reset(); | ||
this.Component = Component; | ||
flight.registry.reset(); | ||
this.Component = require(componentPath); | ||
done(); | ||
}.bind(this); | ||
|
||
require(['flight/lib/registry', componentPath], requireCallback); | ||
}); | ||
|
||
afterEach(function (done) { | ||
|
@@ -64,17 +63,14 @@ | |
this.$node = null; | ||
} | ||
|
||
var requireCallback = function (defineComponent) { | ||
|
||
if (this.component) { | ||
this.component = null; | ||
} | ||
|
||
this.Component = null; | ||
defineComponent.teardownAll(); | ||
require('flightjs').component.teardownAll(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
done(); | ||
}.bind(this); | ||
|
||
require(['flight/lib/component'], requireCallback); | ||
}); | ||
|
||
specDefinitions.apply(this); | ||
|
@@ -130,13 +126,9 @@ | |
this.component = (new this.Component()).initialize(this.$node, options); | ||
}; | ||
|
||
var requireCallback = function (registry, defineComponent, Mixin) { | ||
registry.reset(); | ||
this.Component = defineComponent(function () {}, Mixin); | ||
flight.registry.reset(); | ||
this.Component = flight.component(function () {}, require(mixinPath)); | ||
done(); | ||
}.bind(this); | ||
|
||
require(['flight/lib/registry', 'flight/lib/component', mixinPath], requireCallback); | ||
}); | ||
|
||
afterEach(function (done) { | ||
|
@@ -145,17 +137,13 @@ | |
this.$node = null; | ||
} | ||
|
||
var requireCallback = function (defineComponent) { | ||
if (this.component) { | ||
this.component = null; | ||
} | ||
|
||
this.Component = null; | ||
defineComponent.teardownAll(); | ||
flight.component.teardownAll(); | ||
done(); | ||
}.bind(this); | ||
|
||
require(['flight/lib/component'], requireCallback); | ||
}); | ||
|
||
specDefinitions.apply(this); | ||
|
@@ -186,12 +174,8 @@ | |
beforeEach(function (done) { | ||
this.module = null; | ||
|
||
var requireCallback = function (module) { | ||
this.module = module; | ||
this.module = require(modulePath); | ||
done(); | ||
}.bind(this); | ||
|
||
require([modulePath], requireCallback); | ||
}); | ||
|
||
specDefinitions.apply(this); | ||
|
@@ -363,7 +347,7 @@ | |
pass: wasTriggeredWithData | ||
}; | ||
|
||
result.message = function () { | ||
result.message = (function () { | ||
var $pp = function (obj) { | ||
var description; | ||
var attr; | ||
|
@@ -397,7 +381,7 @@ | |
'Expected event ' + eventName + ' not to have been triggered on ' + $pp(selector) | ||
]; | ||
} | ||
}(); | ||
}()); | ||
|
||
return result; | ||
|
||
|
@@ -415,7 +399,7 @@ | |
pass: wasTriggered | ||
}; | ||
|
||
result.message = function () { | ||
result.message = (function () { | ||
var $pp = function (obj) { | ||
var description; | ||
var attr; | ||
|
@@ -448,7 +432,7 @@ | |
'Expected event ' + eventName + ' not to have been triggered on ' + $pp(selector) | ||
]; | ||
} | ||
}(); | ||
}()); | ||
|
||
return result; | ||
} | ||
|
@@ -505,4 +489,4 @@ | |
jasmine.flight.events.cleanUp(); | ||
}); | ||
|
||
}(this)); | ||
}(this, this.jasmine)); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
{ | ||
"name": "jasmine-flight", | ||
"version": "3.0.0", | ||
"dependencies": { | ||
"flightjs": "git://github.com/flightjs/flight.git#0e390c8900567a4b14f8f81316a7fbab218a7847", | ||
"jasmine-jquery": "git://github.com/velesin/jasmine-jquery.git" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lock down to fixed point |
||
}, | ||
"devDependencies": { | ||
"karma": "~0.12.6", | ||
"karma-cli": "~0.0.4", | ||
"karma-jasmine": "~0.2.0", | ||
"requirejs": "^2.1.14", | ||
"karma-requirejs": "~0.2.2", | ||
"karma-chrome-launcher": "~0.1.4", | ||
"karma-firefox-launcher": "~0.1.3" | ||
"karma-firefox-launcher": "~0.1.3", | ||
"karma-commonjs": "0.0.10" | ||
}, | ||
"scripts": { | ||
"test": "./node_modules/.bin/karma start --browsers Firefox --single-run" | ||
"test": "./node_modules/.bin/karma start --single-run", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should be able to use
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, commented on the same thing. fyi, karma doesn't export their binary – karma-runner/karma#1078 – but when you install |
||
"watch": "./node_modules/.bin/karma start" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
define(function (require) { | ||
'use strict'; | ||
var flight = require('flightjs'); | ||
|
||
var defineComponent = require('flight/lib/component'); | ||
module.exports = flight.component(Example); | ||
|
||
function Example() { | ||
this.defaultAttrs({ | ||
param: 'defaultParam' | ||
}); | ||
} | ||
|
||
return defineComponent(Example); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
define(function () { | ||
return function Mixin() { | ||
module.exports = function Mixin() { | ||
this.defaultAttrs({ | ||
param: 'defaultParam' | ||
}); | ||
} | ||
}); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanthat