Skip to content

Commit 28da357

Browse files
authored
Merge pull request #16023 from rwjblue/work-on-no-jquery
Make `ember-application` package tests pass without jQuery.
2 parents 0486d07 + 49e6727 commit 28da357

File tree

16 files changed

+298
-180
lines changed

16 files changed

+298
-180
lines changed

bin/run-tests.js

+6
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,15 @@ function generateEachPackageTests() {
184184
testFunctions.push(function() {
185185
return run('package=' + packageName);
186186
});
187+
if (packages[packageName].requiresJQuery === false) {
188+
testFunctions.push(function() {
189+
return run('package=' + packageName + '&jquery=none');
190+
});
191+
}
187192
testFunctions.push(function() {
188193
return run('package=' + packageName + '&enableoptionalfeatures=true');
189194
});
195+
190196
});
191197
}
192198

lib/packages.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
module.exports = function() {
22
var packages = {
3-
'container': { trees: null, requirements: ['ember-utils'], isTypeScript: true, vendorRequirements: ['@glimmer/di'] },
4-
'ember-environment': { trees: null, requirements: [], skipTests: true },
5-
'ember-utils': { trees: null, requirements: [] },
6-
'ember-console': { trees: null, requirements: [], skipTests: true },
7-
'ember-metal': { trees: null, requirements: ['ember-environment', 'ember-utils'], vendorRequirements: ['backburner'] },
8-
'ember-debug': { trees: null, requirements: [] },
9-
'ember-runtime': { trees: null, vendorRequirements: ['rsvp'], requirements: ['container', 'ember-environment', 'ember-console', 'ember-metal'] },
3+
'container': { trees: null, requirements: ['ember-utils'], isTypeScript: true, vendorRequirements: ['@glimmer/di'], requiresJQuery: false },
4+
'ember-environment': { trees: null, requirements: [], skipTests: true, requiresJQuery: false },
5+
'ember-utils': { trees: null, requirements: [], requiresJQuery: false },
6+
'ember-console': { trees: null, requirements: [], skipTests: true, requiresJQuery: false },
7+
'ember-metal': { trees: null, requirements: ['ember-environment', 'ember-utils'], vendorRequirements: ['backburner'], requiresJQuery: false },
8+
'ember-debug': { trees: null, requirements: [], requiresJQuery: false },
9+
'ember-runtime': { trees: null, vendorRequirements: ['rsvp'], requirements: ['container', 'ember-environment', 'ember-console', 'ember-metal'], requiresJQuery: false },
1010
'ember-views': { trees: null, requirements: ['ember-runtime'], skipTests: true },
11-
'ember-extension-support': { trees: null, requirements: ['ember-application'] },
11+
'ember-extension-support': { trees: null, requirements: ['ember-application'], requiresJQuery: false },
1212
'ember-testing': { trees: null, requirements: ['ember-application', 'ember-routing'], testing: true },
1313
'ember-template-compiler': {
1414
trees: null,
@@ -27,10 +27,10 @@ module.exports = function() {
2727
]
2828
},
2929
'ember-routing': { trees: null, vendorRequirements: ['router', 'route-recognizer'],
30-
requirements: ['ember-runtime', 'ember-views'] },
31-
'ember-application': { trees: null, vendorRequirements: ['dag-map'], requirements: ['ember-routing'] },
30+
requirements: ['ember-runtime', 'ember-views'], requiresJQuery: false },
31+
'ember-application': { trees: null, vendorRequirements: ['dag-map'], requirements: ['ember-routing'], requiresJQuery: false },
3232
'ember': { trees: null, requirements: ['ember-application'] },
33-
'internal-test-helpers': { trees: null },
33+
'internal-test-helpers': { trees: null, requiresJQuery: false },
3434

3535
'ember-glimmer': {
3636
trees: null,
@@ -43,7 +43,7 @@ module.exports = function() {
4343
'@glimmer/wire-format',
4444
'@glimmer/node'
4545
],
46-
testingVendorRequirements: []
46+
testingVendorRequirements: [],
4747
}
4848
};
4949

packages/ember-application/tests/system/application_test.js

+15-12
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,13 @@ import {
3535
} from 'internal-test-helpers';
3636

3737
moduleFor('Ember.Application, autobooting multiple apps', class extends ApplicationTestCase {
38-
constructor() {
39-
jQuery('#qunit-fixture').html(`
38+
get fixture() {
39+
return `
4040
<div id="one">
4141
<div id="one-child">HI</div>
4242
</div>
4343
<div id="two">HI</div>
44-
`);
45-
super();
44+
`;
4645
}
4746

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

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

238-
[`@test initialized application goes to initial route`](assert) {
237+
[`@test initialized application goes to initial route`]() {
239238
this.runTask(() => {
240239
this.createApplication();
241240
this.addTemplate('application', '{{outlet}}');
242241
this.addTemplate('index', '<h1>Hi from index</h1>');
243242
});
244243

245-
assert.equal(this.$('h1').text(), 'Hi from index');
244+
this.assertText('Hi from index');
246245
}
247246

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

295-
[`@test Application Controller backs the appplication template`](assert) {
294+
[`@test Application Controller backs the appplication template`]() {
296295
this.runTask(() => {
297296
this.createApplication();
298297
this.addTemplate('application', '<h1>{{greeting}}</h1>');
299298
this.add('controller:application', Controller.extend({
300299
greeting: 'Hello!'
301300
}));
302301
});
303-
assert.equal(this.$('h1').text(), 'Hello!');
302+
this.assertText('Hello!');
304303
}
305304

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

322321
assert.equal(messages[1], 'Ember : ' + VERSION);
323-
assert.equal(messages[2], 'jQuery : ' + jQuery().jquery);
324-
assert.equal(messages[3], 'my-lib : ' + '2.0.0a');
322+
if (jQuery) {
323+
assert.equal(messages[2], 'jQuery : ' + jQuery().jquery);
324+
assert.equal(messages[3], 'my-lib : ' + '2.0.0a');
325+
} else {
326+
assert.equal(messages[2], 'my-lib : ' + '2.0.0a');
327+
}
325328

326329
libraries.deRegister('my-lib');
327330
}
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
import { assign } from 'ember-utils';
2-
import { jQuery } from 'ember-views';
32
import {
43
moduleFor,
54
DefaultResolverApplicationTestCase
65
} from 'internal-test-helpers';
76

87
moduleFor('Ember.Application with default resolver and autoboot', class extends DefaultResolverApplicationTestCase {
9-
constructor() {
10-
jQuery('#qunit-fixture').html(`
8+
get fixture() {
9+
return `
1110
<div id="app"></div>
1211
1312
<script type="text/x-handlebars">Hello {{outlet}}</script>
1413
<script type="text/x-handlebars" id="index">World!</script>
15-
`);
16-
super();
14+
`;
1715
}
1816

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

2624
['@test templates in script tags are extracted at application creation'](assert) {
2725
this.runTask(() => this.createApplication());
28-
assert.equal(this.$('#app').text(), 'Hello World!');
26+
assert.equal(document.getElementById('app').textContent, 'Hello World!');
2927
}
3028
});

packages/ember-application/tests/system/dependency_injection/custom_resolver_test.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ moduleFor('Ember.Application with extended default resolver and autoboot', class
2626
});
2727
}
2828

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

packages/ember-application/tests/system/initializers_test.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import { assign } from 'ember-utils';
22
import { moduleFor, AutobootApplicationTestCase } from 'internal-test-helpers';
33
import { Application } from 'ember-application';
4-
import { jQuery } from 'ember-views';
54

65
moduleFor('Ember.Application initializers', class extends AutobootApplicationTestCase {
7-
constructor() {
8-
jQuery('#qunit-fixture').html(`
9-
<div id="one">ONE</div>
6+
get fixture() {
7+
return `<div id="one">ONE</div>
108
<div id="two">TWO</div>
11-
`);
12-
super();
9+
`;
1310
}
1411

1512
get applicationOptions() {

packages/ember-application/tests/system/instance_initializers_test.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import { assign } from 'ember-utils';
22
import { moduleFor, AutobootApplicationTestCase } from 'internal-test-helpers';
33
import { Application, ApplicationInstance } from 'ember-application';
4-
import { jQuery } from 'ember-views';
54

65
moduleFor('Ember.Application instance initializers', class extends AutobootApplicationTestCase {
7-
constructor() {
8-
jQuery('#qunit-fixture').html(`
9-
<div id="one">ONE</div>
6+
get fixture() {
7+
return `<div id="one">ONE</div>
108
<div id="two">TWO</div>
11-
`);
12-
super();
9+
`;
1310
}
1411

1512
get applicationOptions() {

0 commit comments

Comments
 (0)