add ember-qunit for ember unit tests

closes CNVS-11294

test plan:
  - enable ember quizzes
  - ensure that existing ember quizzes continue to work
  - all existing ember tests should continue to pass

Change-Id: I4f56b1267504533be8332520ea5f77d2fa566263
Reviewed-on: https://gerrit.instructure.com/33105
Reviewed-by: Derek DeVries <ddevries@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Jason Madsen <jmadsen@instructure.com>
This commit is contained in:
Jason Madsen 2014-04-09 14:41:41 -06:00
parent 5a3ff8ff87
commit 306f1583d8
49 changed files with 2081 additions and 46 deletions

4
.gitignore vendored
View File

@ -50,3 +50,7 @@ Gemfile.lock3
/public/plugins/
/spec/coffeescripts/plugins/
/spec/plugins/
#remove this once we move jqeury into bower
/public/javascripts/bower/jquery/

View File

@ -1,46 +1,49 @@
define [
'../start_app',
'ember',
'ic-ajax',
'../../controllers/quiz_index_row_controller',
'../environment_setup',
], (startApp, Ember, ajax, QuizIndexRowController) ->
'../start_app'
'ember'
'../../controllers/quiz_index_row_controller'
'ember-qunit'
'../environment_setup'
], (startApp, Ember, QuizIndexRowController, emq) ->
App = null
{run} = Ember
module 'quizzes_controller',
App = startApp()
emq.setResolver(Ember.DefaultResolver.create({namespace: App}))
emq.moduleFor('controller:quiz_index_row', 'QuizIndexRowController', {
needs: ['controller:quizzes']
setup: ->
App = startApp()
cont = App.__container__
store = cont.lookup('store:main')
run =>
@qc = QuizIndexRowController.create
controllers:
quizzes: Em.ObjectController
@model = store.createRecord 'quiz',
pointsPossible: 1
title: 'Assignment test'
htmlURL: 'foo/bar'
@qc.set('model', @model)
emq.setResolver(Ember.DefaultResolver.create({namespace: App}))
@model = Ember.Object.create
pointsPossible: 1
title: 'Assignment test'
htmlURL: 'foo/bar'
@qc = this.subject()
@qc.set('model', @model)
teardown: ->
Ember.run App, 'destroy'
run App, 'destroy'
}
)
test 'display singular points possible', ->
emq.test 'sanity', ->
ok(@qc)
emq.test 'display singular points possible', ->
equal(@qc.get('pointsPossible'), '1 pt')
test 'display mulitple points possible', ->
emq.test 'display mulitple points possible', ->
run => @model.set('pointsPossible', 2)
equal(@qc.get('pointsPossible'), '2 pts')
test 'doesnt display when zero points possible', ->
emq.test 'doesnt display when zero points possible', ->
run => @model.set('pointsPossible', 0)
equal(@qc.get('pointsPossible'), '')
test 'doesnt display when undefined points possible', ->
emq.test 'doesnt display when undefined points possible', ->
run => @model.set('pointsPossible', undefined)
equal(@qc.get('pointsPossible'), '')
test 'correctly creates edit url for quiz', ->
emq.test 'correctly creates edit url for quiz', ->
equal(@qc.get('editUrl'), 'foo/bar/edit')

View File

@ -9,7 +9,8 @@
"ic-ajax": "~0.2.0",
"ic-menu": "~0.1.0",
"ic-styled": "~1.1.3",
"color-slicer": "~0.7.0",
"k5uploader": "0.0.2"
"color-slicer": "~0.4.0",
"k5uploader": "0.0.2",
"ember-qunit": "~0.1.7"
}
}

View File

@ -70,6 +70,7 @@ module Canvas
{'name' => 'ic-ajax', 'location' => 'bower/ic-ajax'},
{'name' => 'ic-styled', 'location' => 'bower/ic-styled'},
{'name' => 'ic-menu', 'location' => 'bower/ic-menu'},
{'name' => 'ember-qunit', 'location' => 'bower/ember-qunit/dist/amd'},
].to_json
end

View File

@ -0,0 +1,29 @@
{
"name": "ember-qunit",
"version": "0.1.7",
"authors": [
"Stefan Penner",
"Ryan Florence"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test"
],
"dependencies": {
"ember": "^1.3.0",
"ember-data": "~1.0.0-beta.7"
},
"homepage": "https://github.com/rpflorence/ember-qunit",
"_release": "0.1.7",
"_resolution": {
"type": "version",
"tag": "v0.1.7",
"commit": "2fe2f50b5c0b390c2a146fd2f9bb946bebf37d24"
},
"_source": "git://github.com/rpflorence/ember-qunit.git",
"_target": "~0.1.7",
"_originalSource": "ember-qunit"
}

View File

@ -0,0 +1,12 @@
module.exports = function(broccoli) {
return require('broccoli-dist-es6-module')(broccoli.makeTree('lib'), {
global: 'emq',
packageName: 'ember-qunit',
main: 'main',
shim: {
'ember': 'Ember',
'qunit': 'QUnit'
}
});
};

View File

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2014 Ryan Florence
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,141 @@
Ember QUnit
===========
[![Build Status](https://travis-ci.org/rpflorence/ember-qunit.png)](https://travis-ci.org/rpflorence/ember-qunit)
[WIP] Unit test helpers for Ember.
About
-----
Ember QUnit uses your application's resolver to find and automatically
create test subjects for you with the `moduleFor` and `test` helpers.
*This is a work in progress* but its also quite handy already. Feedback
is highly encouraged.
Module Formats
--------------
You will find all the popular formats in `dist/`. If using globals, all
methods are found on `window.emq`.
Examples
--------
### Global build setup:
```js
// inject test helpers onto window
emq.globalize();
```
### Setting the resolver
```js
// if you don't have a custom resolver, do it like this:
setResolver(Ember.DefaultResolver.create({namespace: App}));
// otherwise something like:
import Resolver from './path/to/resolver';
import {setResolver} from 'ember-qunit';
setResolver(Resolver.create());
```
### Simple example:
```js
// tell ember qunit what you are testing, it will find it from the
// resolver
moduleForComponent('x-foo', 'XFooComponent');
// run a test
test('it renders', function() {
expect(2);
// creates the component instance
var component = this.subject();
equal(component.state, 'preRender');
// appends the component to the page
this.append();
equal(component.state, 'inDOM');
});
```
### Complex example
```js
// a more complex example taken from ic-tabs
moduleForComponent('ic-tabs', 'TabsComponent', {
// specify the other units that are required for this test
needs: [
'component:ic-tab',
'component:ic-tab-panel',
'component:ic-tab-list'
]
});
test('selects first tab and shows the panel', function() {
expect(3);
var component = test.subject({
// can provide properties for the subject, like the yielded template
// of a component (not the layout, in this case)
template: Ember.Handlebars.compile(''+
'{{#ic-tab-list}}'+
'{{#ic-tab id="tab1"}}tab1{{/ic-tab}}'+
'{{#ic-tab id="tab2"}}tab2{{/ic-tab}}'+
'{{#ic-tab id="tab3"}}tab3{{/ic-tab}}'+
'{{/ic-tab-list}}'+
'{{#ic-tab-panel id="panel1"}}one{{/ic-tab-panel}}'+
'{{#ic-tab-panel id="panel2"}}two{{/ic-tab-panel}}'+
'{{#ic-tab-panel id="panel3"}}three{{/ic-tab-panel}}'
})
});
this.append();
var tab1 = Ember.View.views['tab1'];
var panel1 = Ember.View.views['panel1'];
ok(component.get('activeTab') === tab1);
ok(tab1.get('active'));
var el = tab1.$();
ok(panel1.$().is(':visible'));
});
```
Helpers
-------
### `moduleFor(fullName [, description [, callbacks]])`
- `fullName`: (String) - The full name of the unit, ie
`controller:application`, `route:index`.
- `description`: (String) optional - The description of the module
- `callbacks`: (Object) optional - Normal QUnit callbacks (setup and
teardown), with addition to `needs`, which allows you specify the
other units the tests will need.
### `moduleForComponent(name, [description, callbacks])`
- `name`: (String) - the short name of the component that you'd use in a
template, ie `x-foo`, `ic-tabs`, etc.
### `moduleForModel(name, [description, callbacks])`
- `name`: (String) - the short name of the model you'd use in `store`
operations ie `user`, `assignmentGroup`, etc.
Contributing
------------
```sh
$ npm install
$ bower install
$ broccoli serve
# new tab
$ karma start
```

View File

@ -0,0 +1,19 @@
{
"name": "ember-qunit",
"version": "0.1.7",
"authors": [
"Stefan Penner",
"Ryan Florence"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test"
],
"dependencies": {
"ember": "^1.3.0",
"ember-data": "~1.0.0-beta.7"
}
}

View File

@ -0,0 +1,22 @@
define(
["./test-resolver","ember","exports"],
function(__dependency1__, __dependency2__, __exports__) {
"use strict";
var testResolver = __dependency1__["default"] || __dependency1__;
var Ember = __dependency2__["default"] || __dependency2__;
__exports__["default"] = function isolatedContainer(fullNames) {
var resolver = testResolver.get();
var container = new Ember.Container();
container.optionsForType('component', { singleton: false });
container.optionsForType('view', { singleton: false });
container.optionsForType('template', { instantiate: false });
container.optionsForType('helper', { instantiate: false });
container.register('component-lookup:main', Ember.ComponentLookup);
for (var i = fullNames.length; i > 0; i--) {
var fullName = fullNames[i - 1];
container.register(fullName, resolver.resolve(fullName));
}
return container;
}
});

View File

@ -0,0 +1,33 @@
define(
["ember","./isolated-container","./module-for","./module-for-component","./module-for-model","./test","./test-resolver","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __exports__) {
"use strict";
var Ember = __dependency1__["default"] || __dependency1__;
var isolatedContainer = __dependency2__["default"] || __dependency2__;
var moduleFor = __dependency3__["default"] || __dependency3__;
var moduleForComponent = __dependency4__["default"] || __dependency4__;
var moduleForModel = __dependency5__["default"] || __dependency5__;
var test = __dependency6__["default"] || __dependency6__;
var testResolver = __dependency7__["default"] || __dependency7__;
Ember.testing = true;
function setResolver(resolver) {
testResolver.set(resolver);
}
function globalize() {
window.moduleFor = moduleFor;
window.moduleForComponent = moduleForComponent;
window.moduleForModel = moduleForModel;
window.test = test;
window.setResolver = setResolver;
}
__exports__.globalize = globalize;
__exports__.moduleFor = moduleFor;
__exports__.moduleForComponent = moduleForComponent;
__exports__.moduleForModel = moduleForModel;
__exports__.test = test;
__exports__.setResolver = setResolver;
});

View File

@ -0,0 +1,40 @@
define(
["./test-resolver","./module-for","ember","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
"use strict";
var testResolver = __dependency1__["default"] || __dependency1__;
var moduleFor = __dependency2__["default"] || __dependency2__;
var Ember = __dependency3__["default"] || __dependency3__;
__exports__["default"] = function moduleForComponent(name, description, callbacks) {
var resolver = testResolver.get();
moduleFor('component:' + name, description, callbacks, function(container, context, defaultSubject) {
var templateName = 'template:components/' + name;
var template = resolver.resolve(templateName);
if (template) {
container.register(templateName, template);
container.injection('component:' + name, 'template', templateName);
}
context.dispatcher = Ember.EventDispatcher.create();
context.dispatcher.setup({}, '#ember-testing');
context.__setup_properties__.append = function(selector) {
var containerView = Ember.ContainerView.create({container: container});
var view = Ember.run(function(){
var subject = context.subject();
containerView.pushObject(subject);
// TODO: destory this somewhere
containerView.appendTo('#ember-testing');
return subject;
});
return view.$();
};
context.__setup_properties__.$ = context.__setup_properties__.append;
});
}
});

View File

@ -0,0 +1,27 @@
define(
["./module-for","ember","exports"],
function(__dependency1__, __dependency2__, __exports__) {
"use strict";
var moduleFor = __dependency1__["default"] || __dependency1__;
var Ember = __dependency2__["default"] || __dependency2__;
__exports__["default"] = function moduleForModel(name, description, callbacks) {
moduleFor('model:' + name, description, callbacks, function(container, context, defaultSubject) {
// custom model specific awesomeness
container.register('store:main', DS.Store);
container.register('adapter:application', DS.FixtureAdapter);
context.__setup_properties__.store = function(){
return container.lookup('store:main');
};
if (context.__setup_properties__.subject === defaultSubject) {
context.__setup_properties__.subject = function(options) {
return Ember.run(function() {
return container.lookup('store:main').createRecord(name, options);
});
};
}
});
}
});

View File

@ -0,0 +1,92 @@
define(
["ember","./test-context","./isolated-container","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
"use strict";
var Ember = __dependency1__["default"] || __dependency1__;
//import QUnit from 'qunit'; // Assumed global in runner
var testContext = __dependency2__["default"] || __dependency2__;
var isolatedContainer = __dependency3__["default"] || __dependency3__;
__exports__["default"] = function moduleFor(fullName, description, callbacks, delegate) {
var container;
var context;
var _callbacks = {
setup: function(){
callbacks = callbacks || { };
var needs = [fullName].concat(callbacks.needs || []);
container = isolatedContainer(needs);
callbacks.subject = callbacks.subject || defaultSubject;
callbacks.setup = callbacks.setup || function() { };
callbacks.teardown = callbacks.teardown || function() { };
function factory() {
return container.lookupFactory(fullName);
}
testContext.set({
container: container,
factory: factory,
dispatcher: null,
__setup_properties__: callbacks
});
context = testContext.get();
if (delegate) {
delegate(container, context, defaultSubject);
}
if (Ember.$('#ember-testing').length === 0) {
Ember.$('<div id="ember-testing"/>').appendTo(document.body);
}
buildContextVariables(context);
callbacks.setup.call(context, container);
},
teardown: function(){
Ember.run(function(){
container.destroy();
if (context.dispatcher) {
context.dispatcher.destroy();
}
});
callbacks.teardown(container);
Ember.$('#ember-testing').empty();
}
};
QUnit.module(description || fullName, _callbacks);
}
function defaultSubject(options, factory) {
return factory.create(options);
}
// allow arbitrary named factories, like rspec let
function buildContextVariables(context) {
var cache = { };
var callbacks = context.__setup_properties__;
var container = context.container;
var factory = context.factory;
Ember.keys(callbacks).filter(function(key){
// ignore the default setup/teardown keys
return key !== 'setup' && key !== 'teardown';
}).forEach(function(key){
context[key] = function(options) {
if (cache[key]) { return cache[key]; }
var result = callbacks[key](options, factory(), container);
cache[key] = result;
return result;
};
});
}
});

View File

@ -0,0 +1,16 @@
define(
["exports"],
function(__exports__) {
"use strict";
var __test_context__;
function set(context) {
__test_context__ = context;
}
__exports__.set = set;function get() {
return __test_context__;
}
__exports__.get = get;
});

View File

@ -0,0 +1,17 @@
define(
["exports"],
function(__exports__) {
"use strict";
var __resolver__;
function set(resolver) {
__resolver__ = resolver;
}
__exports__.set = set;function get() {
if (__resolver__ == null) throw new Error('you must set a resolver with `testResolver.set(resolver)`');
return __resolver__;
}
__exports__.get = get;
});

View File

@ -0,0 +1,33 @@
define(
["ember","./test-context","exports"],
function(__dependency1__, __dependency2__, __exports__) {
"use strict";
var Ember = __dependency1__["default"] || __dependency1__;
//import QUnit from 'qunit'; // Assumed global in runner
var testContext = __dependency2__["default"] || __dependency2__;
function resetViews() {
Ember.View.views = {};
}
__exports__["default"] = function test(testName, callback) {
function wrapper() {
var context = testContext.get();
resetViews();
var result = callback.call(context);
function failTestOnPromiseRejection(reason) {
ok(false, reason);
}
Ember.run(function(){
stop();
Ember.RSVP.Promise.cast(result)['catch'](failTestOnPromiseRejection)['finally'](start);
});
}
QUnit.test(testName, wrapper);
}
});

View File

@ -0,0 +1,18 @@
"use strict";
var testResolver = require("./test-resolver")["default"] || require("./test-resolver");
var Ember = require("ember")["default"] || require("ember");
exports["default"] = function isolatedContainer(fullNames) {
var resolver = testResolver.get();
var container = new Ember.Container();
container.optionsForType('component', { singleton: false });
container.optionsForType('view', { singleton: false });
container.optionsForType('template', { instantiate: false });
container.optionsForType('helper', { instantiate: false });
container.register('component-lookup:main', Ember.ComponentLookup);
for (var i = fullNames.length; i > 0; i--) {
var fullName = fullNames[i - 1];
container.register(fullName, resolver.resolve(fullName));
}
return container;
}

View File

@ -0,0 +1,29 @@
"use strict";
var Ember = require("ember")["default"] || require("ember");
var isolatedContainer = require("./isolated-container")["default"] || require("./isolated-container");
var moduleFor = require("./module-for")["default"] || require("./module-for");
var moduleForComponent = require("./module-for-component")["default"] || require("./module-for-component");
var moduleForModel = require("./module-for-model")["default"] || require("./module-for-model");
var test = require("./test")["default"] || require("./test");
var testResolver = require("./test-resolver")["default"] || require("./test-resolver");
Ember.testing = true;
function setResolver(resolver) {
testResolver.set(resolver);
}
function globalize() {
window.moduleFor = moduleFor;
window.moduleForComponent = moduleForComponent;
window.moduleForModel = moduleForModel;
window.test = test;
window.setResolver = setResolver;
}
exports.globalize = globalize;
exports.moduleFor = moduleFor;
exports.moduleForComponent = moduleForComponent;
exports.moduleForModel = moduleForModel;
exports.test = test;
exports.setResolver = setResolver;

View File

@ -0,0 +1,36 @@
"use strict";
var testResolver = require("./test-resolver")["default"] || require("./test-resolver");
var moduleFor = require("./module-for")["default"] || require("./module-for");
var Ember = require("ember")["default"] || require("ember");
exports["default"] = function moduleForComponent(name, description, callbacks) {
var resolver = testResolver.get();
moduleFor('component:' + name, description, callbacks, function(container, context, defaultSubject) {
var templateName = 'template:components/' + name;
var template = resolver.resolve(templateName);
if (template) {
container.register(templateName, template);
container.injection('component:' + name, 'template', templateName);
}
context.dispatcher = Ember.EventDispatcher.create();
context.dispatcher.setup({}, '#ember-testing');
context.__setup_properties__.append = function(selector) {
var containerView = Ember.ContainerView.create({container: container});
var view = Ember.run(function(){
var subject = context.subject();
containerView.pushObject(subject);
// TODO: destory this somewhere
containerView.appendTo('#ember-testing');
return subject;
});
return view.$();
};
context.__setup_properties__.$ = context.__setup_properties__.append;
});
}

View File

@ -0,0 +1,23 @@
"use strict";
var moduleFor = require("./module-for")["default"] || require("./module-for");
var Ember = require("ember")["default"] || require("ember");
exports["default"] = function moduleForModel(name, description, callbacks) {
moduleFor('model:' + name, description, callbacks, function(container, context, defaultSubject) {
// custom model specific awesomeness
container.register('store:main', DS.Store);
container.register('adapter:application', DS.FixtureAdapter);
context.__setup_properties__.store = function(){
return container.lookup('store:main');
};
if (context.__setup_properties__.subject === defaultSubject) {
context.__setup_properties__.subject = function(options) {
return Ember.run(function() {
return container.lookup('store:main').createRecord(name, options);
});
};
}
});
}

View File

@ -0,0 +1,88 @@
"use strict";
var Ember = require("ember")["default"] || require("ember");
//import QUnit from 'qunit'; // Assumed global in runner
var testContext = require("./test-context")["default"] || require("./test-context");
var isolatedContainer = require("./isolated-container")["default"] || require("./isolated-container");
exports["default"] = function moduleFor(fullName, description, callbacks, delegate) {
var container;
var context;
var _callbacks = {
setup: function(){
callbacks = callbacks || { };
var needs = [fullName].concat(callbacks.needs || []);
container = isolatedContainer(needs);
callbacks.subject = callbacks.subject || defaultSubject;
callbacks.setup = callbacks.setup || function() { };
callbacks.teardown = callbacks.teardown || function() { };
function factory() {
return container.lookupFactory(fullName);
}
testContext.set({
container: container,
factory: factory,
dispatcher: null,
__setup_properties__: callbacks
});
context = testContext.get();
if (delegate) {
delegate(container, context, defaultSubject);
}
if (Ember.$('#ember-testing').length === 0) {
Ember.$('<div id="ember-testing"/>').appendTo(document.body);
}
buildContextVariables(context);
callbacks.setup.call(context, container);
},
teardown: function(){
Ember.run(function(){
container.destroy();
if (context.dispatcher) {
context.dispatcher.destroy();
}
});
callbacks.teardown(container);
Ember.$('#ember-testing').empty();
}
};
QUnit.module(description || fullName, _callbacks);
}
function defaultSubject(options, factory) {
return factory.create(options);
}
// allow arbitrary named factories, like rspec let
function buildContextVariables(context) {
var cache = { };
var callbacks = context.__setup_properties__;
var container = context.container;
var factory = context.factory;
Ember.keys(callbacks).filter(function(key){
// ignore the default setup/teardown keys
return key !== 'setup' && key !== 'teardown';
}).forEach(function(key){
context[key] = function(options) {
if (cache[key]) { return cache[key]; }
var result = callbacks[key](options, factory(), container);
cache[key] = result;
return result;
};
});
}

View File

@ -0,0 +1,12 @@
"use strict";
var __test_context__;
function set(context) {
__test_context__ = context;
}
exports.set = set;function get() {
return __test_context__;
}
exports.get = get;

View File

@ -0,0 +1,13 @@
"use strict";
var __resolver__;
function set(resolver) {
__resolver__ = resolver;
}
exports.set = set;function get() {
if (__resolver__ == null) throw new Error('you must set a resolver with `testResolver.set(resolver)`');
return __resolver__;
}
exports.get = get;

View File

@ -0,0 +1,29 @@
"use strict";
var Ember = require("ember")["default"] || require("ember");
//import QUnit from 'qunit'; // Assumed global in runner
var testContext = require("./test-context")["default"] || require("./test-context");
function resetViews() {
Ember.View.views = {};
}
exports["default"] = function test(testName, callback) {
function wrapper() {
var context = testContext.get();
resetViews();
var result = callback.call(context);
function failTestOnPromiseRejection(reason) {
ok(false, reason);
}
Ember.run(function(){
stop();
Ember.RSVP.Promise.cast(result)['catch'](failTestOnPromiseRejection)['finally'](start);
});
}
QUnit.test(testName, wrapper);
}

View File

@ -0,0 +1,259 @@
!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.emq=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
"use strict";
var testResolver = _dereq_("./test-resolver")["default"] || _dereq_("./test-resolver");
var Ember = window.Ember["default"] || window.Ember;
exports["default"] = function isolatedContainer(fullNames) {
var resolver = testResolver.get();
var container = new Ember.Container();
container.optionsForType('component', { singleton: false });
container.optionsForType('view', { singleton: false });
container.optionsForType('template', { instantiate: false });
container.optionsForType('helper', { instantiate: false });
container.register('component-lookup:main', Ember.ComponentLookup);
for (var i = fullNames.length; i > 0; i--) {
var fullName = fullNames[i - 1];
container.register(fullName, resolver.resolve(fullName));
}
return container;
}
},{"./test-resolver":7}],2:[function(_dereq_,module,exports){
"use strict";
var Ember = window.Ember["default"] || window.Ember;
var isolatedContainer = _dereq_("./isolated-container")["default"] || _dereq_("./isolated-container");
var moduleFor = _dereq_("./module-for")["default"] || _dereq_("./module-for");
var moduleForComponent = _dereq_("./module-for-component")["default"] || _dereq_("./module-for-component");
var moduleForModel = _dereq_("./module-for-model")["default"] || _dereq_("./module-for-model");
var test = _dereq_("./test")["default"] || _dereq_("./test");
var testResolver = _dereq_("./test-resolver")["default"] || _dereq_("./test-resolver");
Ember.testing = true;
function setResolver(resolver) {
testResolver.set(resolver);
}
function globalize() {
window.moduleFor = moduleFor;
window.moduleForComponent = moduleForComponent;
window.moduleForModel = moduleForModel;
window.test = test;
window.setResolver = setResolver;
}
exports.globalize = globalize;
exports.moduleFor = moduleFor;
exports.moduleForComponent = moduleForComponent;
exports.moduleForModel = moduleForModel;
exports.test = test;
exports.setResolver = setResolver;
},{"./isolated-container":1,"./module-for":5,"./module-for-component":3,"./module-for-model":4,"./test":8,"./test-resolver":7}],3:[function(_dereq_,module,exports){
"use strict";
var testResolver = _dereq_("./test-resolver")["default"] || _dereq_("./test-resolver");
var moduleFor = _dereq_("./module-for")["default"] || _dereq_("./module-for");
var Ember = window.Ember["default"] || window.Ember;
exports["default"] = function moduleForComponent(name, description, callbacks) {
var resolver = testResolver.get();
moduleFor('component:' + name, description, callbacks, function(container, context, defaultSubject) {
var templateName = 'template:components/' + name;
var template = resolver.resolve(templateName);
if (template) {
container.register(templateName, template);
container.injection('component:' + name, 'template', templateName);
}
context.dispatcher = Ember.EventDispatcher.create();
context.dispatcher.setup({}, '#ember-testing');
context.__setup_properties__.append = function(selector) {
var containerView = Ember.ContainerView.create({container: container});
var view = Ember.run(function(){
var subject = context.subject();
containerView.pushObject(subject);
// TODO: destory this somewhere
containerView.appendTo('#ember-testing');
return subject;
});
return view.$();
};
context.__setup_properties__.$ = context.__setup_properties__.append;
});
}
},{"./module-for":5,"./test-resolver":7}],4:[function(_dereq_,module,exports){
"use strict";
var moduleFor = _dereq_("./module-for")["default"] || _dereq_("./module-for");
var Ember = window.Ember["default"] || window.Ember;
exports["default"] = function moduleForModel(name, description, callbacks) {
moduleFor('model:' + name, description, callbacks, function(container, context, defaultSubject) {
// custom model specific awesomeness
container.register('store:main', DS.Store);
container.register('adapter:application', DS.FixtureAdapter);
context.__setup_properties__.store = function(){
return container.lookup('store:main');
};
if (context.__setup_properties__.subject === defaultSubject) {
context.__setup_properties__.subject = function(options) {
return Ember.run(function() {
return container.lookup('store:main').createRecord(name, options);
});
};
}
});
}
},{"./module-for":5}],5:[function(_dereq_,module,exports){
"use strict";
var Ember = window.Ember["default"] || window.Ember;
//import QUnit from 'qunit'; // Assumed global in runner
var testContext = _dereq_("./test-context")["default"] || _dereq_("./test-context");
var isolatedContainer = _dereq_("./isolated-container")["default"] || _dereq_("./isolated-container");
exports["default"] = function moduleFor(fullName, description, callbacks, delegate) {
var container;
var context;
var _callbacks = {
setup: function(){
callbacks = callbacks || { };
var needs = [fullName].concat(callbacks.needs || []);
container = isolatedContainer(needs);
callbacks.subject = callbacks.subject || defaultSubject;
callbacks.setup = callbacks.setup || function() { };
callbacks.teardown = callbacks.teardown || function() { };
function factory() {
return container.lookupFactory(fullName);
}
testContext.set({
container: container,
factory: factory,
dispatcher: null,
__setup_properties__: callbacks
});
context = testContext.get();
if (delegate) {
delegate(container, context, defaultSubject);
}
if (Ember.$('#ember-testing').length === 0) {
Ember.$('<div id="ember-testing"/>').appendTo(document.body);
}
buildContextVariables(context);
callbacks.setup.call(context, container);
},
teardown: function(){
Ember.run(function(){
container.destroy();
if (context.dispatcher) {
context.dispatcher.destroy();
}
});
callbacks.teardown(container);
Ember.$('#ember-testing').empty();
}
};
QUnit.module(description || fullName, _callbacks);
}
function defaultSubject(options, factory) {
return factory.create(options);
}
// allow arbitrary named factories, like rspec let
function buildContextVariables(context) {
var cache = { };
var callbacks = context.__setup_properties__;
var container = context.container;
var factory = context.factory;
Ember.keys(callbacks).filter(function(key){
// ignore the default setup/teardown keys
return key !== 'setup' && key !== 'teardown';
}).forEach(function(key){
context[key] = function(options) {
if (cache[key]) { return cache[key]; }
var result = callbacks[key](options, factory(), container);
cache[key] = result;
return result;
};
});
}
},{"./isolated-container":1,"./test-context":6}],6:[function(_dereq_,module,exports){
"use strict";
var __test_context__;
function set(context) {
__test_context__ = context;
}
exports.set = set;function get() {
return __test_context__;
}
exports.get = get;
},{}],7:[function(_dereq_,module,exports){
"use strict";
var __resolver__;
function set(resolver) {
__resolver__ = resolver;
}
exports.set = set;function get() {
if (__resolver__ == null) throw new Error('you must set a resolver with `testResolver.set(resolver)`');
return __resolver__;
}
exports.get = get;
},{}],8:[function(_dereq_,module,exports){
"use strict";
var Ember = window.Ember["default"] || window.Ember;
//import QUnit from 'qunit'; // Assumed global in runner
var testContext = _dereq_("./test-context")["default"] || _dereq_("./test-context");
function resetViews() {
Ember.View.views = {};
}
exports["default"] = function test(testName, callback) {
function wrapper() {
var context = testContext.get();
resetViews();
var result = callback.call(context);
function failTestOnPromiseRejection(reason) {
ok(false, reason);
}
Ember.run(function(){
stop();
Ember.RSVP.Promise.cast(result)['catch'](failTestOnPromiseRejection)['finally'](start);
});
}
QUnit.test(testName, wrapper);
}
},{"./test-context":6}]},{},[2])
(2)
});

View File

@ -0,0 +1,273 @@
define("ember-qunit/isolated-container",
["./test-resolver","ember","exports"],
function(__dependency1__, __dependency2__, __exports__) {
"use strict";
var testResolver = __dependency1__["default"] || __dependency1__;
var Ember = __dependency2__["default"] || __dependency2__;
__exports__["default"] = function isolatedContainer(fullNames) {
var resolver = testResolver.get();
var container = new Ember.Container();
container.optionsForType('component', { singleton: false });
container.optionsForType('view', { singleton: false });
container.optionsForType('template', { instantiate: false });
container.optionsForType('helper', { instantiate: false });
container.register('component-lookup:main', Ember.ComponentLookup);
for (var i = fullNames.length; i > 0; i--) {
var fullName = fullNames[i - 1];
container.register(fullName, resolver.resolve(fullName));
}
return container;
}
});define("ember-qunit",
["ember","./isolated-container","./module-for","./module-for-component","./module-for-model","./test","./test-resolver","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __exports__) {
"use strict";
var Ember = __dependency1__["default"] || __dependency1__;
var isolatedContainer = __dependency2__["default"] || __dependency2__;
var moduleFor = __dependency3__["default"] || __dependency3__;
var moduleForComponent = __dependency4__["default"] || __dependency4__;
var moduleForModel = __dependency5__["default"] || __dependency5__;
var test = __dependency6__["default"] || __dependency6__;
var testResolver = __dependency7__["default"] || __dependency7__;
Ember.testing = true;
function setResolver(resolver) {
testResolver.set(resolver);
}
function globalize() {
window.moduleFor = moduleFor;
window.moduleForComponent = moduleForComponent;
window.moduleForModel = moduleForModel;
window.test = test;
window.setResolver = setResolver;
}
__exports__.globalize = globalize;
__exports__.moduleFor = moduleFor;
__exports__.moduleForComponent = moduleForComponent;
__exports__.moduleForModel = moduleForModel;
__exports__.test = test;
__exports__.setResolver = setResolver;
});define("ember-qunit/module-for-component",
["./test-resolver","./module-for","ember","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
"use strict";
var testResolver = __dependency1__["default"] || __dependency1__;
var moduleFor = __dependency2__["default"] || __dependency2__;
var Ember = __dependency3__["default"] || __dependency3__;
__exports__["default"] = function moduleForComponent(name, description, callbacks) {
var resolver = testResolver.get();
moduleFor('component:' + name, description, callbacks, function(container, context, defaultSubject) {
var templateName = 'template:components/' + name;
var template = resolver.resolve(templateName);
if (template) {
container.register(templateName, template);
container.injection('component:' + name, 'template', templateName);
}
context.dispatcher = Ember.EventDispatcher.create();
context.dispatcher.setup({}, '#ember-testing');
context.__setup_properties__.append = function(selector) {
var containerView = Ember.ContainerView.create({container: container});
var view = Ember.run(function(){
var subject = context.subject();
containerView.pushObject(subject);
// TODO: destory this somewhere
containerView.appendTo('#ember-testing');
return subject;
});
return view.$();
};
context.__setup_properties__.$ = context.__setup_properties__.append;
});
}
});define("ember-qunit/module-for-model",
["./module-for","ember","exports"],
function(__dependency1__, __dependency2__, __exports__) {
"use strict";
var moduleFor = __dependency1__["default"] || __dependency1__;
var Ember = __dependency2__["default"] || __dependency2__;
__exports__["default"] = function moduleForModel(name, description, callbacks) {
moduleFor('model:' + name, description, callbacks, function(container, context, defaultSubject) {
// custom model specific awesomeness
container.register('store:main', DS.Store);
container.register('adapter:application', DS.FixtureAdapter);
context.__setup_properties__.store = function(){
return container.lookup('store:main');
};
if (context.__setup_properties__.subject === defaultSubject) {
context.__setup_properties__.subject = function(options) {
return Ember.run(function() {
return container.lookup('store:main').createRecord(name, options);
});
};
}
});
}
});define("ember-qunit/module-for",
["ember","./test-context","./isolated-container","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
"use strict";
var Ember = __dependency1__["default"] || __dependency1__;
//import QUnit from 'qunit'; // Assumed global in runner
var testContext = __dependency2__["default"] || __dependency2__;
var isolatedContainer = __dependency3__["default"] || __dependency3__;
__exports__["default"] = function moduleFor(fullName, description, callbacks, delegate) {
var container;
var context;
var _callbacks = {
setup: function(){
callbacks = callbacks || { };
var needs = [fullName].concat(callbacks.needs || []);
container = isolatedContainer(needs);
callbacks.subject = callbacks.subject || defaultSubject;
callbacks.setup = callbacks.setup || function() { };
callbacks.teardown = callbacks.teardown || function() { };
function factory() {
return container.lookupFactory(fullName);
}
testContext.set({
container: container,
factory: factory,
dispatcher: null,
__setup_properties__: callbacks
});
context = testContext.get();
if (delegate) {
delegate(container, context, defaultSubject);
}
if (Ember.$('#ember-testing').length === 0) {
Ember.$('<div id="ember-testing"/>').appendTo(document.body);
}
buildContextVariables(context);
callbacks.setup.call(context, container);
},
teardown: function(){
Ember.run(function(){
container.destroy();
if (context.dispatcher) {
context.dispatcher.destroy();
}
});
callbacks.teardown(container);
Ember.$('#ember-testing').empty();
}
};
QUnit.module(description || fullName, _callbacks);
}
function defaultSubject(options, factory) {
return factory.create(options);
}
// allow arbitrary named factories, like rspec let
function buildContextVariables(context) {
var cache = { };
var callbacks = context.__setup_properties__;
var container = context.container;
var factory = context.factory;
Ember.keys(callbacks).filter(function(key){
// ignore the default setup/teardown keys
return key !== 'setup' && key !== 'teardown';
}).forEach(function(key){
context[key] = function(options) {
if (cache[key]) { return cache[key]; }
var result = callbacks[key](options, factory(), container);
cache[key] = result;
return result;
};
});
}
});define("ember-qunit/test-context",
["exports"],
function(__exports__) {
"use strict";
var __test_context__;
function set(context) {
__test_context__ = context;
}
__exports__.set = set;function get() {
return __test_context__;
}
__exports__.get = get;
});define("ember-qunit/test-resolver",
["exports"],
function(__exports__) {
"use strict";
var __resolver__;
function set(resolver) {
__resolver__ = resolver;
}
__exports__.set = set;function get() {
if (__resolver__ == null) throw new Error('you must set a resolver with `testResolver.set(resolver)`');
return __resolver__;
}
__exports__.get = get;
});define("ember-qunit/test",
["ember","./test-context","exports"],
function(__dependency1__, __dependency2__, __exports__) {
"use strict";
var Ember = __dependency1__["default"] || __dependency1__;
//import QUnit from 'qunit'; // Assumed global in runner
var testContext = __dependency2__["default"] || __dependency2__;
function resetViews() {
Ember.View.views = {};
}
__exports__["default"] = function test(testName, callback) {
function wrapper() {
var context = testContext.get();
resetViews();
var result = callback.call(context);
function failTestOnPromiseRejection(reason) {
ok(false, reason);
}
Ember.run(function(){
stop();
Ember.RSVP.Promise.cast(result)['catch'](failTestOnPromiseRejection)['finally'](start);
});
}
QUnit.test(testName, wrapper);
}
});

View File

@ -0,0 +1,38 @@
module.exports = function(config) {
config.set({
frameworks: ['qunit'],
files: [
'bower_components/jquery/dist/jquery.js',
'bower_components/handlebars/handlebars.js',
'bower_components/ember/ember.js',
'bower_components/ember-data/ember-data.js',
'dist/globals/main.js',
// when running broccoli serve, we use this instead
'http://localhost:4200/globals/main.js',
'test/support/setup.js',
'test/**/*.spec.js'
],
basePath: '',
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
captureTimeout: 60000,
singleRun: false
});
};

View File

@ -0,0 +1,17 @@
import testResolver from './test-resolver';
import Ember from 'ember';
export default function isolatedContainer(fullNames) {
var resolver = testResolver.get();
var container = new Ember.Container();
container.optionsForType('component', { singleton: false });
container.optionsForType('view', { singleton: false });
container.optionsForType('template', { instantiate: false });
container.optionsForType('helper', { instantiate: false });
container.register('component-lookup:main', Ember.ComponentLookup);
for (var i = fullNames.length; i > 0; i--) {
var fullName = fullNames[i - 1];
container.register(fullName, resolver.resolve(fullName));
}
return container;
}

View File

@ -0,0 +1,31 @@
import Ember from 'ember';
import isolatedContainer from './isolated-container';
import moduleFor from './module-for';
import moduleForComponent from './module-for-component';
import moduleForModel from './module-for-model';
import test from './test';
import testResolver from './test-resolver';
Ember.testing = true;
function setResolver(resolver) {
testResolver.set(resolver);
}
function globalize() {
window.moduleFor = moduleFor;
window.moduleForComponent = moduleForComponent;
window.moduleForModel = moduleForModel;
window.test = test;
window.setResolver = setResolver;
}
export {
globalize,
moduleFor,
moduleForComponent,
moduleForModel,
test,
setResolver
};

View File

@ -0,0 +1,35 @@
import testResolver from './test-resolver';
import moduleFor from './module-for';
import Ember from 'ember';
export default function moduleForComponent(name, description, callbacks) {
var resolver = testResolver.get();
moduleFor('component:' + name, description, callbacks, function(container, context, defaultSubject) {
var templateName = 'template:components/' + name;
var template = resolver.resolve(templateName);
if (template) {
container.register(templateName, template);
container.injection('component:' + name, 'template', templateName);
}
context.dispatcher = Ember.EventDispatcher.create();
context.dispatcher.setup({}, '#ember-testing');
context.__setup_properties__.append = function(selector) {
var containerView = Ember.ContainerView.create({container: container});
var view = Ember.run(function(){
var subject = context.subject();
containerView.pushObject(subject);
// TODO: destory this somewhere
containerView.appendTo('#ember-testing');
return subject;
});
return view.$();
};
context.__setup_properties__.$ = context.__setup_properties__.append;
});
}

View File

@ -0,0 +1,23 @@
import moduleFor from './module-for';
import Ember from 'ember';
export default function moduleForModel(name, description, callbacks) {
moduleFor('model:' + name, description, callbacks, function(container, context, defaultSubject) {
// custom model specific awesomeness
container.register('store:main', DS.Store);
container.register('adapter:application', DS.FixtureAdapter);
context.__setup_properties__.store = function(){
return container.lookup('store:main');
};
if (context.__setup_properties__.subject === defaultSubject) {
context.__setup_properties__.subject = function(options) {
return Ember.run(function() {
return container.lookup('store:main').createRecord(name, options);
});
};
}
});
}

View File

@ -0,0 +1,87 @@
import Ember from 'ember';
//import QUnit from 'qunit'; // Assumed global in runner
import testContext from './test-context';
import isolatedContainer from './isolated-container';
export default function moduleFor(fullName, description, callbacks, delegate) {
var container;
var context;
var _callbacks = {
setup: function(){
callbacks = callbacks || { };
var needs = [fullName].concat(callbacks.needs || []);
container = isolatedContainer(needs);
callbacks.subject = callbacks.subject || defaultSubject;
callbacks.setup = callbacks.setup || function() { };
callbacks.teardown = callbacks.teardown || function() { };
function factory() {
return container.lookupFactory(fullName);
}
testContext.set({
container: container,
factory: factory,
dispatcher: null,
__setup_properties__: callbacks
});
context = testContext.get();
if (delegate) {
delegate(container, context, defaultSubject);
}
if (Ember.$('#ember-testing').length === 0) {
Ember.$('<div id="ember-testing"/>').appendTo(document.body);
}
buildContextVariables(context);
callbacks.setup.call(context, container);
},
teardown: function(){
Ember.run(function(){
container.destroy();
if (context.dispatcher) {
context.dispatcher.destroy();
}
});
callbacks.teardown(container);
Ember.$('#ember-testing').empty();
}
};
QUnit.module(description || fullName, _callbacks);
}
function defaultSubject(options, factory) {
return factory.create(options);
}
// allow arbitrary named factories, like rspec let
function buildContextVariables(context) {
var cache = { };
var callbacks = context.__setup_properties__;
var container = context.container;
var factory = context.factory;
Ember.keys(callbacks).filter(function(key){
// ignore the default setup/teardown keys
return key !== 'setup' && key !== 'teardown';
}).forEach(function(key){
context[key] = function(options) {
if (cache[key]) { return cache[key]; }
var result = callbacks[key](options, factory(), container);
cache[key] = result;
return result;
};
});
}

View File

@ -0,0 +1,10 @@
var __test_context__;
export function set(context) {
__test_context__ = context;
}
export function get() {
return __test_context__;
}

View File

@ -0,0 +1,11 @@
var __resolver__;
export function set(resolver) {
__resolver__ = resolver;
}
export function get() {
if (__resolver__ == null) throw new Error('you must set a resolver with `testResolver.set(resolver)`');
return __resolver__;
}

View File

@ -0,0 +1,29 @@
import Ember from 'ember';
//import QUnit from 'qunit'; // Assumed global in runner
import testContext from './test-context';
function resetViews() {
Ember.View.views = {};
}
export default function test(testName, callback) {
function wrapper() {
var context = testContext.get();
resetViews();
var result = callback.call(context);
function failTestOnPromiseRejection(reason) {
ok(false, reason);
}
Ember.run(function(){
stop();
Ember.RSVP.Promise.cast(result)['catch'](failTestOnPromiseRejection)['finally'](start);
});
}
QUnit.test(testName, wrapper);
}

View File

@ -0,0 +1,32 @@
{
"name": "ember-qunit",
"version": "0.1.7",
"description": "unit test helpers for ember",
"main": "dist/cjs/main.js",
"scripts": {
"test": "bower install && rm -rf dist && broccoli build dist && karma start --browsers Firefox --single-run"
},
"authors": [
"Stefan Penner",
"Ryan Florence"
],
"license": "MIT",
"devDependencies": {
"broccoli": "~0.2.0",
"broccoli-dist-es6-module": "^0.1.8",
"karma-script-launcher": "~0.1.0",
"karma-chrome-launcher": "~0.1.2",
"karma-firefox-launcher": "~0.1.3",
"karma-html2js-preprocessor": "~0.1.0",
"karma-jasmine": "~0.1.5",
"karma-coffee-preprocessor": "~0.1.3",
"requirejs": "~2.1.11",
"karma-requirejs": "~0.2.1",
"karma-phantomjs-launcher": "~0.1.2",
"karma": "~0.10.9",
"qunitjs": "~1.12.0",
"karma-qunit": "~0.1.1",
"bower": "^1.2.8",
"broccoli-cli": "0.0.1"
}
}

View File

@ -8,14 +8,14 @@
],
"main": "jquery.js",
"license": "MIT",
"homepage": "https://github.com/components/jquery",
"homepage": "https://github.com/jquery/jquery",
"_release": "2.0.3",
"_resolution": {
"type": "version",
"tag": "2.0.3",
"commit": "452a56b52b8f4a032256cdb8b6838f25f0bdb3d2"
"commit": "f852e631ba85af7da4ad7594785e122504e7b233"
},
"_source": "git://github.com/components/jquery.git",
"_target": ">= 1.7 < 2.1",
"_source": "git://github.com/jquery/jquery.git",
"_target": "2.0.3",
"_originalSource": "jquery"
}

View File

@ -1 +1,14 @@
build
src/selector-sizzle.js
src/selector.js
dist
.project
.settings
*~
*.diff
*.patch
/*.html
.DS_Store
dist/.destination.json
dist/.sizecache.json
build/.sizecache.json
node_modules

View File

@ -1,11 +1,399 @@
jQuery Component
================
[jQuery](http://jquery.com/) - New Wave JavaScript
==================================================
Shim repository for the [jQuery](http://jquery.com).
Contribution Guides
--------------------------------------
Package Managers
----------------
In the spirit of open source software development, jQuery always encourages community code contribution. To help you get started and before you jump into writing code, be sure to read these important contribution guidelines thoroughly:
* [Bower](http://bower.io/): `jquery`
* [Component](https://github.com/component/component): `components/jquery`
* [Composer](http://packagist.org/packages/components/jquery): `components/jquery`
1. [Getting Involved](http://docs.jquery.com/Getting_Involved)
2. [Core Style Guide](http://docs.jquery.com/JQuery_Core_Style_Guidelines)
3. [Tips For Bug Patching](http://docs.jquery.com/Tips_for_jQuery_Bug_Patching)
What you need to build your own jQuery
--------------------------------------
In order to build jQuery, you need to have Node.js/npm latest and git 1.7 or later.
(Earlier versions might work OK, but are not tested.)
Windows users have two options:
1. Install [msysgit](https://code.google.com/p/msysgit/) (Full installer for official Git) and a
[binary version of Node.js](http://nodejs.org). Make sure all two packages are installed to the same
location (by default, this is C:\Program Files\Git).
2. Install [Cygwin](http://cygwin.com/) (make sure you install the git and which packages), and
a [binary version of Node.js](http://nodejs.org/).
Mac OS users should install Xcode (comes on your Mac OS install DVD, or downloadable from
[Apple's Xcode site](http://developer.apple.com/technologies/xcode.html)) and
[Homebrew](http://mxcl.github.com/homebrew/). Once Homebrew is installed, run `brew install git` to install git,
and `brew install node` to install Node.js.
Linux/BSD users should use their appropriate package managers to install git and Node.js, or build from source
if you swing that way. Easy-peasy.
How to build your own jQuery
----------------------------
First, clone a copy of the main jQuery git repo by running:
```bash
git clone git://github.com/jquery/jquery.git
```
Install the grunt-cli package so that you will have the correct version of grunt available from any project that needs it. This should be done as a global install:
```bash
npm install -g grunt-cli
```
Enter the jquery directory and install the Node dependencies, this time *without* specifying a global install:
```bash
cd jquery && npm install
```
Make sure you have `grunt` installed by testing:
```bash
grunt -version
```
Then, to get a complete, minified (w/ Uglify.js), linted (w/ JSHint) version of jQuery, type the following:
```bash
grunt
```
The built version of jQuery will be put in the `dist/` subdirectory, along with the minified copy and associated map file.
### Modules
Special builds can be created that exclude subsets of jQuery functionality.
This allows for smaller custom builds when the builder is certain that those parts of jQuery are not being used.
For example, an app that only used JSONP for `$.ajax()` and did not need to calculate offsets or positions of elements could exclude the offset and ajax/xhr modules. The current modules that can be excluded are:
- **ajax**: All AJAX functionality: `$.ajax()`, `$.get()`, `$.post()`, `$.ajaxSetup()`, `.load()`, transports, and ajax event shorthands such as `.ajaxStart()`.
- **ajax/xhr**: The XMLHTTPRequest AJAX transport only.
- **ajax/script**: The `<script>` AJAX transport only; used to retrieve scripts.
- **ajax/jsonp**: The JSONP AJAX transport only; depends on the ajax/script transport.
- **css**: The `.css()` method plus non-animated `.show()`, `.hide()` and `.toggle()`.
- **deprecated**: Methods documented as deprecated but not yet removed; currently only `.andSelf()`.
- **dimensions**: The `.width()` and `.height()` methods, including `inner-` and `outer-` variations.
- **effects**: The `.animate()` method and its shorthands such as `.slideUp()` or `.hide("slow")`.
- **event-alias**: All event attaching/triggering shorthands like `.click()` or `.mouseover()`.
- **offset**: The `.offset()`, `.position()`, `.offsetParent()`, `.scrollLeft()`, and `.scrollTop()` methods.
- **wrap**: The `.wrap()`, `.wrapAll()`, `.wrapInner()`, and `.unwrap()` methods.
- **sizzle**: The Sizzle selector engine. When this module is excluded, it is replaced by a rudimentary selector engine based on the browser's `querySelectorAll` method that does not support jQuery selector extensions or enhanced semantics. See the selector-native.js file for details.
The grunt build process is aware of dependencies across modules. If you explicitly remove a module, its dependent modules will be removed as well. For example, excluding the css module also excludes effects, since the effects module uses `.css()` to animate CSS properties. These dependencies are listed in Gruntfile.js and the build process shows a message for each dependent module it excludes.
To create a custom build of the latest stable version, first check out the version:
```bash
git pull; git checkout $(git describe --abbrev=0 --tags)
```
Then, make sure all Node dependencies are installed and all Git submodules are checked out:
```bash
npm install && grunt
```
Create the custom build, use the `grunt custom` option, listing the modules to be excluded. Examples:
Exclude all **ajax** functionality:
```bash
grunt custom:-ajax
```
Exclude **css**, **effects**, **offset**, **dimensions**, and **position**. Excluding **css** automatically excludes its dependent modules:
```bash
grunt custom:-css,-position
```
Exclude **all** optional modules and use the `querySelectorAll`-based selector engine:
```bash
grunt custom:-ajax,-css,-deprecated,-dimensions,-effects,-event-alias,-offset,-wrap,-sizzle
```
For questions or requests regarding custom builds, please start a thread on the [Developing jQuery Core](https://forum.jquery.com/developing-jquery-core) section of the forum. Due to the combinatorics and custom nature of these builds, they are not regularly tested in jQuery's unit test process. The non-Sizzle selector engine currently does not pass unit tests because it is missing too much essential functionality.
Running the Unit Tests
--------------------------------------
Start grunt to auto-build jQuery as you work:
```bash
cd jquery && grunt watch
```
Run the unit tests with a local server that supports PHP. Ensure that you run the site from the root directory, not the "test" directory. No database is required. Pre-configured php local servers are available for Windows and Mac. Here are some options:
- Windows: [WAMP download](http://www.wampserver.com/en/)
- Mac: [MAMP download](http://www.mamp.info/en/index.html)
- Linux: [Setting up LAMP](https://www.linux.com/learn/tutorials/288158-easy-lamp-server-installation)
- [Mongoose (most platforms)](http://code.google.com/p/mongoose/)
Building to a different directory
---------------------------------
To copy the built jQuery files from `/dist` to another directory:
```bash
grunt && grunt dist:/path/to/special/location/
```
With this example, the output files would be:
```bash
/path/to/special/location/jquery.js
/path/to/special/location/jquery.min.js
```
To add a permanent copy destination, create a file in `dist/` called ".destination.json". Inside the file, paste and customize the following:
```json
{
"/Absolute/path/to/other/destination": true
}
```
Additionally, both methods can be combined.
Updating Submodules
-------------------
Update the submodules to what is probably the latest upstream code.
```bash
grunt update_submodules
```
Note: This task will also be run any time the default `grunt` command is used.
Essential Git
-------------
As the source code is handled by the version control system Git, it's useful to know some features used.
### Submodules ###
The repository uses submodules, which normally are handled directly by the `grunt update_submodules` command, but sometimes you want to
be able to work with them manually.
Following are the steps to manually get the submodules:
```bash
git clone https://github.com/jquery/jquery.git
cd jquery
git submodule init
git submodule update
```
Or:
```bash
git clone https://github.com/jquery/jquery.git
cd jquery
git submodule update --init
```
Or:
```bash
git clone --recursive https://github.com/jquery/jquery.git
cd jquery
```
If you want to work inside a submodule, it is possible, but first you need to checkout a branch:
```bash
cd src/sizzle
git checkout master
```
After you've committed your changes to the submodule, you'll update the jquery project to point to the new commit,
but remember to push the submodule changes before pushing the new jquery commit:
```bash
cd src/sizzle
git push origin master
cd ..
git add src/sizzle
git commit
```
### cleaning ###
If you want to purge your working directory back to the status of upstream, following commands can be used (remember everything you've worked on is gone after these):
```bash
git reset --hard upstream/master
git clean -fdx
```
### rebasing ###
For feature/topic branches, you should always used the `--rebase` flag to `git pull`, or if you are usually handling many temporary "to be in a github pull request" branches, run following to automate this:
```bash
git config branch.autosetuprebase local
```
(see `man git-config` for more information)
### handling merge conflicts ###
If you're getting merge conflicts when merging, instead of editing the conflicted files manually, you can use the feature
`git mergetool`. Even though the default tool `xxdiff` looks awful/old, it's rather useful.
Following are some commands that can be used there:
* `Ctrl + Alt + M` - automerge as much as possible
* `b` - jump to next merge conflict
* `s` - change the order of the conflicted lines
* `u` - undo an merge
* `left mouse button` - mark a block to be the winner
* `middle mouse button` - mark a line to be the winner
* `Ctrl + S` - save
* `Ctrl + Q` - quit
[QUnit](http://docs.jquery.com/QUnit) Reference
-----------------
### Test methods ###
```js
expect( numAssertions );
stop();
start();
```
note: QUnit's eventual addition of an argument to stop/start is ignored in this test suite so that start and stop can be passed as callbacks without worrying about their parameters
### Test assertions ###
```js
ok( value, [message] );
equal( actual, expected, [message] );
notEqual( actual, expected, [message] );
deepEqual( actual, expected, [message] );
notDeepEqual( actual, expected, [message] );
strictEqual( actual, expected, [message] );
notStrictEqual( actual, expected, [message] );
raises( block, [expected], [message] );
```
Test Suite Convenience Methods Reference (See [test/data/testinit.js](https://github.com/jquery/jquery/blob/master/test/data/testinit.js))
------------------------------
### Returns an array of elements with the given IDs ###
```js
q( ... );
```
Example:
```js
q("main", "foo", "bar");
=> [ div#main, span#foo, input#bar ]
```
### Asserts that a selection matches the given IDs ###
```js
t( testName, selector, [ "array", "of", "ids" ] );
```
Example:
```js
t("Check for something", "//[a]", ["foo", "baar"]);
```
### Fires a native DOM event without going through jQuery ###
```js
fireNative( node, eventType )
```
Example:
```js
fireNative( jQuery("#elem")[0], "click" );
```
### Add random number to url to stop caching ###
```js
url( "some/url.php" );
```
Example:
```js
url("data/test.html");
=> "data/test.html?10538358428943"
url("data/test.php?foo=bar");
=> "data/test.php?foo=bar&10538358345554"
```
### Load tests in an iframe ###
Loads a given page constructing a url with fileName: `"./data/" + fileName + ".html"`
and fires the given callback on jQuery ready (using the jQuery loading from that page)
and passes the iFrame's jQuery to the callback.
```js
testIframe( fileName, testName, callback );
```
Callback arguments:
```js
callback( jQueryFromIFrame, iFrameWindow, iFrameDocument );
```
### Load tests in an iframe (window.iframeCallback) ###
Loads a given page constructing a url with fileName: `"./data/" + fileName + ".html"`
The given callback is fired when window.iframeCallback is called by the page
The arguments passed to the callback are the same as the
arguments passed to window.iframeCallback, whatever that may be
```js
testIframeWithCallback( testName, fileName, callback );
```
Questions?
----------
If you have any questions, please feel free to ask on the
[Developing jQuery Core forum](http://forum.jquery.com/developing-jquery-core) or in #jquery on irc.freenode.net.

0
public/javascripts/bower/jquery/bower.json Normal file → Executable file
View File

0
public/javascripts/bower/jquery/component.json Normal file → Executable file
View File

0
public/javascripts/bower/jquery/composer.json Normal file → Executable file
View File

0
public/javascripts/bower/jquery/jquery-migrate.js vendored Normal file → Executable file
View File

0
public/javascripts/bower/jquery/jquery-migrate.min.js vendored Normal file → Executable file
View File

0
public/javascripts/bower/jquery/jquery.js vendored Normal file → Executable file
View File

0
public/javascripts/bower/jquery/jquery.min.js vendored Normal file → Executable file
View File

0
public/javascripts/bower/jquery/jquery.min.map Normal file → Executable file
View File

View File

@ -1,7 +1,38 @@
{
"name": "components-jquery",
"version": "2.0.3",
"description": "jQuery component",
"keywords": ["jquery"],
"main": "./jquery.js"
"name": "jquery",
"title": "jQuery",
"description": "JavaScript library for DOM operations",
"version": "2.0.3",
"homepage": "http://jquery.com",
"author": {
"name": "jQuery Foundation and other contributors",
"url": "https://github.com/jquery/jquery/blob/master/AUTHORS.txt"
},
"repository": {
"type": "git",
"url": "https://github.com/jquery/jquery.git"
},
"bugs": {
"url": "http://bugs.jquery.com"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt"
}
],
"dependencies": {},
"devDependencies": {
"grunt-compare-size": "~0.4.0",
"grunt-git-authors": "1.2.0",
"grunt-update-submodules": "0.2.0",
"grunt-contrib-watch": "0.3.1",
"grunt-contrib-jshint": "0.3.0",
"grunt-contrib-uglify": "0.2.0",
"grunt": "0.4.1",
"gzip-js": "0.3.1",
"testswarm": "~1.1.0",
"archiver": "~0.4.2"
},
"keywords": []
}