Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaurav0 committed Nov 18, 2019
1 parent f8c9a26 commit 74194e9
Show file tree
Hide file tree
Showing 19 changed files with 254 additions and 54 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { ApplicationTestCase, moduleFor, strip } from 'internal-test-helpers';
import {
ApplicationTestCase,
ModuleBasedTestResolver,
moduleFor,
strip,
} from 'internal-test-helpers';

import { ENV } from '@ember/-internals/environment';
import {
Expand Down Expand Up @@ -292,6 +297,7 @@ if (ENV._DEBUG_RENDER_TREE) {
'engine:foo',
class extends Engine {
isFooEngine = true;
Resolver = ModuleBasedTestResolver;

init() {
super.init(...arguments);
Expand Down Expand Up @@ -327,6 +333,8 @@ if (ENV._DEBUG_RENDER_TREE) {
this.add(
'engine:bar',
class extends Engine {
Resolver = ModuleBasedTestResolver;

init() {
super.init(...arguments);
this.register(
Expand Down Expand Up @@ -670,6 +678,7 @@ if (ENV._DEBUG_RENDER_TREE) {
'engine:foo',
class extends Engine {
isFooEngine = true;
Resolver = ModuleBasedTestResolver;

init() {
super.init(...arguments);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { moduleFor, ApplicationTestCase, strip, runTaskNext } from 'internal-test-helpers';
import {
moduleFor,
ApplicationTestCase,
ModuleBasedTestResolver,
strip,
runTaskNext,
} from 'internal-test-helpers';

import { Component } from '@ember/-internals/glimmer';
import { Route } from '@ember/-internals/routing';
Expand Down Expand Up @@ -80,6 +86,8 @@ moduleFor(
this.add(
'engine:blog',
Engine.extend({
Resolver: ModuleBasedTestResolver,

init() {
this._super(...arguments);
this.register(
Expand Down Expand Up @@ -131,6 +139,8 @@ moduleFor(
this.add(
'engine:chat-engine',
Engine.extend({
Resolver: ModuleBasedTestResolver,

init() {
this._super(...arguments);
this.register('template:application', compile('Engine'));
Expand Down Expand Up @@ -167,6 +177,8 @@ moduleFor(
this.add(
'engine:blog',
Engine.extend({
Resolver: ModuleBasedTestResolver,

init() {
this._super(...arguments);
this.register('template:foo', compile('foo partial'));
Expand Down Expand Up @@ -202,6 +214,8 @@ moduleFor(
this.add(
'engine:chat-engine',
Engine.extend({
Resolver: ModuleBasedTestResolver,

init() {
this._super(...arguments);
this.register('template:foo', compile('foo partial'));
Expand Down Expand Up @@ -230,6 +244,8 @@ moduleFor(
this.add(
'engine:chat-engine',
Engine.extend({
Resolver: ModuleBasedTestResolver,

init() {
this._super(...arguments);
this.register('template:components/foo-bar', compile(`{{partial "troll"}}`));
Expand Down Expand Up @@ -289,6 +305,8 @@ moduleFor(
this.add(
'engine:blog',
Engine.extend({
Resolver: ModuleBasedTestResolver,

init() {
this._super(...arguments);

Expand Down Expand Up @@ -344,6 +362,8 @@ moduleFor(
this.add(
'engine:blog',
Engine.extend({
Resolver: ModuleBasedTestResolver,

init() {
this._super(...arguments);
this.register(
Expand Down Expand Up @@ -486,6 +506,8 @@ moduleFor(
this.add(
'engine:blog',
Engine.extend({
Resolver: ModuleBasedTestResolver,

init() {
this._super(...arguments);
this.register('template:application', compile('Engine{{outlet}}'));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { moduleFor, ApplicationTestCase, RenderingTestCase, runTask } from 'internal-test-helpers';
import {
moduleFor,
ApplicationTestCase,
ModuleBasedTestResolver,
RenderingTestCase,
runTask,
} from 'internal-test-helpers';

import { set } from '@ember/-internals/metal';
import { getOwner } from '@ember/-internals/owner';
Expand Down Expand Up @@ -48,6 +54,7 @@ moduleFor(
'engine:chat',
Engine.extend({
router: null,
Resolver: ModuleBasedTestResolver,

init() {
this._super(...arguments);
Expand Down Expand Up @@ -165,6 +172,8 @@ moduleFor(
'engine:foo',
Engine.extend({
router: null,
Resolver: ModuleBasedTestResolver,

init() {
this._super(...arguments);
this.register(
Expand All @@ -180,6 +189,8 @@ moduleFor(
'engine:bar',
Engine.extend({
router: null,
Resolver: ModuleBasedTestResolver,

init() {
this._super(...arguments);
this.register(
Expand Down Expand Up @@ -244,6 +255,8 @@ moduleFor(
'engine:foo',
Engine.extend({
router: null,
Resolver: ModuleBasedTestResolver,

init() {
this._super(...arguments);
this.register(
Expand Down Expand Up @@ -299,6 +312,8 @@ moduleFor(
'engine:paramEngine',
Engine.extend({
router: null,
Resolver: ModuleBasedTestResolver,

init() {
this._super(...arguments);
this.register(
Expand Down Expand Up @@ -393,6 +408,8 @@ moduleFor(
'engine:componentParamEngine',
Engine.extend({
router: null,
Resolver: ModuleBasedTestResolver,

init() {
this._super(...arguments);
this.register(
Expand Down Expand Up @@ -429,6 +446,8 @@ if (!EMBER_ROUTING_MODEL_ARG) {
'engine:paramEngine',
Engine.extend({
router: null,
Resolver: ModuleBasedTestResolver,

init() {
this._super(...arguments);
this.register(
Expand Down
18 changes: 15 additions & 3 deletions packages/@ember/application/tests/application_instance_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { run } from '@ember/runloop';
import { privatize as P } from '@ember/-internals/container';
import { factory } from 'internal-test-helpers';
import { Object as EmberObject } from '@ember/-internals/runtime';
import { moduleFor, AbstractTestCase as TestCase } from 'internal-test-helpers';
import {
moduleFor,
ModuleBasedTestResolver,
AbstractTestCase as TestCase,
} from 'internal-test-helpers';
import { getDebugFunction, setDebugFunction } from '@ember/debug';

const originalDebug = getDebugFunction('debug');
Expand All @@ -23,7 +27,13 @@ moduleFor(
document.getElementById('qunit-fixture').innerHTML = `
<div id='one'><div id='one-child'>HI</div></div><div id='two'>HI</div>
`;
application = run(() => Application.create({ rootElement: '#one', router: null }));
application = run(() =>
Application.create({
rootElement: '#one',
router: null,
Resolver: ModuleBasedTestResolver,
})
);
}

teardown() {
Expand Down Expand Up @@ -167,7 +177,9 @@ moduleFor(
['@test can build and boot a registered engine'](assert) {
assert.expect(11);

let ChatEngine = Engine.extend();
let ChatEngine = Engine.extend({
Resolver: ModuleBasedTestResolver,
});
let chatEngineInstance;

application.register('engine:chat', ChatEngine);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ moduleFor(
}

[`@test no assertion for routes that extend from Route`](assert) {
assert.test.assertions = []; // clear assertions that occurred in beforeEach
assert.expect(0);
this.application.FooRoute = Route.extend();
this.privateRegistry.resolve(`route:foo`);
Expand All @@ -211,6 +212,7 @@ moduleFor(
}

[`@test no assertion for service factories that extend from Service`](assert) {
assert.test.assertions = []; // clear assertions that occurred in beforeEach
assert.expect(0);
this.application.FooService = Service.extend();
this.privateRegistry.resolve('service:foo');
Expand Down Expand Up @@ -309,6 +311,7 @@ moduleFor(
return;
}

assert.test.assertions = []; // clear assertions that occurred in beforeEach
assert.expect(3);

this.application.LOG_RESOLVER = true;
Expand All @@ -330,6 +333,7 @@ moduleFor(
return;
}

assert.test.assertions = []; // clear assertions that occurred in beforeEach
assert.expect(3);

this.application.LOG_RESOLVER = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ moduleFor(
constructor() {
super();

application = run(Application, 'create');
// Must use default resolver because test resolver does not normalize
run(() => {
expectDeprecation(() => {
application = Application.create();
});
});
registry = application.__registry__;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ moduleFor(
constructor() {
super();

application = run(EmberApplication, 'create');
// Must use default resolver because test resolver does not normalize
run(() => {
expectDeprecation(() => {
application = EmberApplication.create();
});
});

application.Person = EmberObject.extend({});
application.Orange = EmberObject.extend({});
Expand Down
3 changes: 2 additions & 1 deletion packages/@ember/application/tests/readiness_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { moduleFor, ApplicationTestCase } from 'internal-test-helpers';
import { moduleFor, ModuleBasedTestResolver, ApplicationTestCase } from 'internal-test-helpers';
import { run } from '@ember/runloop';
import EmberApplication from '..';

Expand Down Expand Up @@ -45,6 +45,7 @@ moduleFor(

Application = EmberApplication.extend({
$: jQuery,
Resolver: ModuleBasedTestResolver,

ready() {
readyWasCalled++;
Expand Down
17 changes: 15 additions & 2 deletions packages/@ember/application/tests/visit_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { moduleFor, ApplicationTestCase, runTask } from 'internal-test-helpers';
import {
moduleFor,
ModuleBasedTestResolver,
ApplicationTestCase,
runTask,
} from 'internal-test-helpers';
import { inject as injectService } from '@ember/service';
import { Object as EmberObject, RSVP, onerrorDefault } from '@ember/-internals/runtime';
import { later } from '@ember/runloop';
Expand Down Expand Up @@ -465,7 +470,9 @@ moduleFor(
this.addTemplate('application', '<h1>Hello world</h1>');

// Register engine
let BlogEngine = Engine.extend();
let BlogEngine = Engine.extend({
Resolver: ModuleBasedTestResolver,
});
this.add('engine:blog', BlogEngine);

// Register engine route map
Expand Down Expand Up @@ -502,6 +509,8 @@ moduleFor(

// Register engine
let BlogEngine = Engine.extend({
Resolver: ModuleBasedTestResolver,

init(...args) {
this._super.apply(this, args);
this.register('template:application', compile('{{cache-money}}'));
Expand Down Expand Up @@ -544,6 +553,8 @@ moduleFor(

// Register engine
let BlogEngine = Engine.extend({
Resolver: ModuleBasedTestResolver,

init(...args) {
this._super.apply(this, args);
this.register('template:application', compile('{{cache-money}}'));
Expand Down Expand Up @@ -582,6 +593,8 @@ moduleFor(

// Register engine
let BlogEngine = Engine.extend({
Resolver: ModuleBasedTestResolver,

init(...args) {
this._super.apply(this, args);
this.register('template:application', compile('{{swag}}'));
Expand Down
Loading

0 comments on commit 74194e9

Please sign in to comment.