Skip to content

Commit

Permalink
Merge pull request #16023 from rwjblue/work-on-no-jquery
Browse files Browse the repository at this point in the history
Make `ember-application` package tests pass without jQuery.
  • Loading branch information
rwjblue committed Dec 27, 2017
2 parents 0486d07 + 49e6727 commit 28da357
Show file tree
Hide file tree
Showing 16 changed files with 298 additions and 180 deletions.
6 changes: 6 additions & 0 deletions bin/run-tests.js
Expand Up @@ -184,9 +184,15 @@ function generateEachPackageTests() {
testFunctions.push(function() {
return run('package=' + packageName);
});
if (packages[packageName].requiresJQuery === false) {
testFunctions.push(function() {
return run('package=' + packageName + '&jquery=none');
});
}
testFunctions.push(function() {
return run('package=' + packageName + '&enableoptionalfeatures=true');
});

});
}

Expand Down
24 changes: 12 additions & 12 deletions lib/packages.js
@@ -1,14 +1,14 @@
module.exports = function() {
var packages = {
'container': { trees: null, requirements: ['ember-utils'], isTypeScript: true, vendorRequirements: ['@glimmer/di'] },
'ember-environment': { trees: null, requirements: [], skipTests: true },
'ember-utils': { trees: null, requirements: [] },
'ember-console': { trees: null, requirements: [], skipTests: true },
'ember-metal': { trees: null, requirements: ['ember-environment', 'ember-utils'], vendorRequirements: ['backburner'] },
'ember-debug': { trees: null, requirements: [] },
'ember-runtime': { trees: null, vendorRequirements: ['rsvp'], requirements: ['container', 'ember-environment', 'ember-console', 'ember-metal'] },
'container': { trees: null, requirements: ['ember-utils'], isTypeScript: true, vendorRequirements: ['@glimmer/di'], requiresJQuery: false },
'ember-environment': { trees: null, requirements: [], skipTests: true, requiresJQuery: false },
'ember-utils': { trees: null, requirements: [], requiresJQuery: false },
'ember-console': { trees: null, requirements: [], skipTests: true, requiresJQuery: false },
'ember-metal': { trees: null, requirements: ['ember-environment', 'ember-utils'], vendorRequirements: ['backburner'], requiresJQuery: false },
'ember-debug': { trees: null, requirements: [], requiresJQuery: false },
'ember-runtime': { trees: null, vendorRequirements: ['rsvp'], requirements: ['container', 'ember-environment', 'ember-console', 'ember-metal'], requiresJQuery: false },
'ember-views': { trees: null, requirements: ['ember-runtime'], skipTests: true },
'ember-extension-support': { trees: null, requirements: ['ember-application'] },
'ember-extension-support': { trees: null, requirements: ['ember-application'], requiresJQuery: false },
'ember-testing': { trees: null, requirements: ['ember-application', 'ember-routing'], testing: true },
'ember-template-compiler': {
trees: null,
Expand All @@ -27,10 +27,10 @@ module.exports = function() {
]
},
'ember-routing': { trees: null, vendorRequirements: ['router', 'route-recognizer'],
requirements: ['ember-runtime', 'ember-views'] },
'ember-application': { trees: null, vendorRequirements: ['dag-map'], requirements: ['ember-routing'] },
requirements: ['ember-runtime', 'ember-views'], requiresJQuery: false },
'ember-application': { trees: null, vendorRequirements: ['dag-map'], requirements: ['ember-routing'], requiresJQuery: false },
'ember': { trees: null, requirements: ['ember-application'] },
'internal-test-helpers': { trees: null },
'internal-test-helpers': { trees: null, requiresJQuery: false },

'ember-glimmer': {
trees: null,
Expand All @@ -43,7 +43,7 @@ module.exports = function() {
'@glimmer/wire-format',
'@glimmer/node'
],
testingVendorRequirements: []
testingVendorRequirements: [],
}
};

Expand Down
27 changes: 15 additions & 12 deletions packages/ember-application/tests/system/application_test.js
Expand Up @@ -35,14 +35,13 @@ import {
} from 'internal-test-helpers';

moduleFor('Ember.Application, autobooting multiple apps', class extends ApplicationTestCase {
constructor() {
jQuery('#qunit-fixture').html(`
get fixture() {
return `
<div id="one">
<div id="one-child">HI</div>
</div>
<div id="two">HI</div>
`);
super();
`;
}

get applicationOptions() {
Expand Down Expand Up @@ -212,7 +211,7 @@ moduleFor('Ember.Application, default resolver with autoboot', class extends Def
}

[`@test Minimal Application initialized with just an application template`]() {
jQuery('#qunit-fixture').html('<script type="text/x-handlebars">Hello World</script>');
this.setupFixture('<script type="text/x-handlebars">Hello World</script>');
this.runTask(() => this.createApplication());
this.assertInnerHTML('Hello World');
}
Expand All @@ -235,14 +234,14 @@ moduleFor('Ember.Application, autobooting', class extends AutobootApplicationTes
super.teardown();
}

[`@test initialized application goes to initial route`](assert) {
[`@test initialized application goes to initial route`]() {
this.runTask(() => {
this.createApplication();
this.addTemplate('application', '{{outlet}}');
this.addTemplate('index', '<h1>Hi from index</h1>');
});

assert.equal(this.$('h1').text(), 'Hi from index');
this.assertText('Hi from index');
}

[`@test ready hook is called before routing begins`](assert) {
Expand Down Expand Up @@ -289,18 +288,18 @@ moduleFor('Ember.Application, autobooting', class extends AutobootApplicationTes
// need to make some assertions about the created router
let router = this.application.__deprecatedInstance__.lookup('router:main');
assert.equal(router instanceof Router, true, 'Router was set from initialize call');
assert.equal(this.$('h1').text(), 'Hello!');
this.assertText('Hello!');
}

[`@test Application Controller backs the appplication template`](assert) {
[`@test Application Controller backs the appplication template`]() {
this.runTask(() => {
this.createApplication();
this.addTemplate('application', '<h1>{{greeting}}</h1>');
this.add('controller:application', Controller.extend({
greeting: 'Hello!'
}));
});
assert.equal(this.$('h1').text(), 'Hello!');
this.assertText('Hello!');
}

[`@test enable log of libraries with an ENV var`](assert) {
Expand All @@ -320,8 +319,12 @@ moduleFor('Ember.Application, autobooting', class extends AutobootApplicationTes
this.runTask(() => this.createApplication());

assert.equal(messages[1], 'Ember : ' + VERSION);
assert.equal(messages[2], 'jQuery : ' + jQuery().jquery);
assert.equal(messages[3], 'my-lib : ' + '2.0.0a');
if (jQuery) {
assert.equal(messages[2], 'jQuery : ' + jQuery().jquery);
assert.equal(messages[3], 'my-lib : ' + '2.0.0a');
} else {
assert.equal(messages[2], 'my-lib : ' + '2.0.0a');
}

libraries.deRegister('my-lib');
}
Expand Down
10 changes: 4 additions & 6 deletions packages/ember-application/tests/system/bootstrap-test.js
@@ -1,19 +1,17 @@
import { assign } from 'ember-utils';
import { jQuery } from 'ember-views';
import {
moduleFor,
DefaultResolverApplicationTestCase
} from 'internal-test-helpers';

moduleFor('Ember.Application with default resolver and autoboot', class extends DefaultResolverApplicationTestCase {
constructor() {
jQuery('#qunit-fixture').html(`
get fixture() {
return `
<div id="app"></div>
<script type="text/x-handlebars">Hello {{outlet}}</script>
<script type="text/x-handlebars" id="index">World!</script>
`);
super();
`;
}

get applicationOptions() {
Expand All @@ -25,6 +23,6 @@ moduleFor('Ember.Application with default resolver and autoboot', class extends

['@test templates in script tags are extracted at application creation'](assert) {
this.runTask(() => this.createApplication());
assert.equal(this.$('#app').text(), 'Hello World!');
assert.equal(document.getElementById('app').textContent, 'Hello World!');
}
});
Expand Up @@ -26,9 +26,8 @@ moduleFor('Ember.Application with extended default resolver and autoboot', class
});
}

[`@test a resolver can be supplied to application`](assert) {
[`@test a resolver can be supplied to application`]() {
this.runTask(() => this.createApplication());
assert.equal(this.$('h1').text(), 'Fallback');
this.assertText('Fallback');
}

});
9 changes: 3 additions & 6 deletions packages/ember-application/tests/system/initializers_test.js
@@ -1,15 +1,12 @@
import { assign } from 'ember-utils';
import { moduleFor, AutobootApplicationTestCase } from 'internal-test-helpers';
import { Application } from 'ember-application';
import { jQuery } from 'ember-views';

moduleFor('Ember.Application initializers', class extends AutobootApplicationTestCase {
constructor() {
jQuery('#qunit-fixture').html(`
<div id="one">ONE</div>
get fixture() {
return `<div id="one">ONE</div>
<div id="two">TWO</div>
`);
super();
`;
}

get applicationOptions() {
Expand Down
@@ -1,15 +1,12 @@
import { assign } from 'ember-utils';
import { moduleFor, AutobootApplicationTestCase } from 'internal-test-helpers';
import { Application, ApplicationInstance } from 'ember-application';
import { jQuery } from 'ember-views';

moduleFor('Ember.Application instance initializers', class extends AutobootApplicationTestCase {
constructor() {
jQuery('#qunit-fixture').html(`
<div id="one">ONE</div>
get fixture() {
return `<div id="one">ONE</div>
<div id="two">TWO</div>
`);
super();
`;
}

get applicationOptions() {
Expand Down

0 comments on commit 28da357

Please sign in to comment.