Skip to content

Commit

Permalink
try to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaurav0 committed Oct 27, 2019
1 parent cce25a0 commit 2f49f5f
Show file tree
Hide file tree
Showing 21 changed files with 128 additions and 56 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApplicationTestCase, moduleFor, strip } from 'internal-test-helpers';
import { ApplicationTestCase, Engine, moduleFor, strip } from 'internal-test-helpers';

import { ENV } from '@ember/-internals/environment';
import {
Expand All @@ -13,7 +13,6 @@ import { Route } from '@ember/-internals/routing';
import templateOnly from '@ember/component/template-only';
import Controller from '@ember/controller';
import { captureRenderTree } from '@ember/debug';
import Engine from '@ember/engine';
import EngineInstance from '@ember/engine/instance';
import { Simple } from '@glimmer/interfaces';
import { expect } from '@glimmer/util';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ moduleFor(
'engine:blog',
Engine.extend({
init() {
this._super(...arguments);
ignoreDeprecation(() => {
this._super(...arguments);
}, /Using the globals resolver is deprecated/);
this.register(
'controller:application',
Controller.extend({
Expand Down Expand Up @@ -132,7 +134,9 @@ moduleFor(
'engine:chat-engine',
Engine.extend({
init() {
this._super(...arguments);
ignoreDeprecation(() => {
this._super(...arguments);
}, /Using the globals resolver is deprecated/);
this.register('template:application', compile('Engine'));
this.register(
'controller:application',
Expand Down Expand Up @@ -168,7 +172,9 @@ moduleFor(
'engine:blog',
Engine.extend({
init() {
this._super(...arguments);
ignoreDeprecation(() => {
this._super(...arguments);
}, /Using the globals resolver is deprecated/);
this.register('template:foo', compile('foo partial'));
this.register('template:application', compile('Engine{{outlet}} {{partial "foo"}}'));
this.register(
Expand Down Expand Up @@ -203,7 +209,9 @@ moduleFor(
'engine:chat-engine',
Engine.extend({
init() {
this._super(...arguments);
ignoreDeprecation(() => {
this._super(...arguments);
}, /Using the globals resolver is deprecated/);
this.register('template:foo', compile('foo partial'));
this.register('template:application', compile('Engine {{partial "foo"}}'));
this.register(
Expand Down Expand Up @@ -231,7 +239,9 @@ moduleFor(
'engine:chat-engine',
Engine.extend({
init() {
this._super(...arguments);
ignoreDeprecation(() => {
this._super(...arguments);
}, /Using the globals resolver is deprecated/);
this.register('template:components/foo-bar', compile(`{{partial "troll"}}`));
this.register('template:troll', compile('{{attrs.wat}}'));
this.register(
Expand Down Expand Up @@ -290,7 +300,9 @@ moduleFor(
'engine:blog',
Engine.extend({
init() {
this._super(...arguments);
ignoreDeprecation(() => {
this._super(...arguments);
}, /Using the globals resolver is deprecated/);

this.register(
'controller:application',
Expand Down Expand Up @@ -345,7 +357,9 @@ moduleFor(
'engine:blog',
Engine.extend({
init() {
this._super(...arguments);
ignoreDeprecation(() => {
this._super(...arguments);
}, /Using the globals resolver is deprecated/);
this.register(
'template:application',
compile(strip`
Expand Down Expand Up @@ -487,7 +501,9 @@ moduleFor(
'engine:blog',
Engine.extend({
init() {
this._super(...arguments);
ignoreDeprecation(() => {
this._super(...arguments);
}, /Using the globals resolver is deprecated/);
this.register('template:application', compile('Engine{{outlet}}'));
this.register(
'route:application',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { moduleFor, ApplicationTestCase, RenderingTestCase, runTask } from 'internal-test-helpers';
import {
moduleFor,
ApplicationTestCase,
Engine,
RenderingTestCase,
runTask,
} from 'internal-test-helpers';

import { set } from '@ember/-internals/metal';
import { getOwner } from '@ember/-internals/owner';
import { EMBER_ROUTING_MODEL_ARG } from '@ember/canary-features';
import Controller from '@ember/controller';
import Engine, { getEngineParent } from '@ember/engine';
import { getEngineParent } from '@ember/engine';

import { compile, Component } from '../utils/helpers';

Expand Down
18 changes: 12 additions & 6 deletions packages/@ember/application/tests/application_instance_test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import Engine from '@ember/engine';
import Application from '@ember/application';
import ApplicationInstance from '@ember/application/instance';
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, Engine, AbstractTestCase as TestCase } from 'internal-test-helpers';
import { getDebugFunction, setDebugFunction } from '@ember/debug';

const originalDebug = getDebugFunction('debug');
Expand All @@ -21,9 +20,16 @@ moduleFor(
super();

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 }));
<div id='one'><div id='one-child'>HI</div></div><div id='two'>HI</div>
`;

application = run(() => {
let app;
ignoreDeprecation(() => {
app = Application.create({ rootElement: '#one', router: null });
}, /Using the globals resolver is deprecated/);
return app;
});
}

teardown() {
Expand Down Expand Up @@ -165,7 +171,7 @@ moduleFor(
}

['@test can build and boot a registered engine'](assert) {
assert.expect(11);
assert.expect(12);

let ChatEngine = Engine.extend();
let chatEngineInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ moduleFor(
}

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

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

assert.expect(3);
assert.expect(4);

this.application.LOG_RESOLVER = true;
this.application.ScoobyDoo = EmberObject.extend();
Expand All @@ -330,7 +330,7 @@ moduleFor(
return;
}

assert.expect(3);
assert.expect(4);

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

application = run(Application, 'create');
ignoreDeprecation(() => {
application = run(Application, 'create');
}, /Using the globals resolver is deprecated/);

registry = application.__registry__;
}

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

application = run(EmberApplication, 'create');
expectDeprecation(() => {
application = run(EmberApplication, 'create');
}, /Using the globals resolver is deprecated/);

application.Person = EmberObject.extend({});
application.Orange = EmberObject.extend({});
Expand Down
16 changes: 12 additions & 4 deletions packages/@ember/application/tests/readiness_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ moduleFor(
jQuery.isReady = true;

run(() => {
application = Application.create({ router: false });
expectDeprecation(() => {
application = Application.create({ router: false });
}, /Using the globals resolver is deprecated/);

assert.equal(readyWasCalled, 0, 'ready is not called until later');
});
Expand All @@ -81,7 +83,9 @@ moduleFor(

["@test Application's ready event is called after the document becomes ready"](assert) {
run(() => {
application = Application.create({ router: false });
expectDeprecation(() => {
application = Application.create({ router: false });
}, /Using the globals resolver is deprecated/);
});

assert.equal(readyWasCalled, 0, "ready wasn't called yet");
Expand All @@ -93,7 +97,9 @@ moduleFor(

["@test Application's ready event can be deferred by other components"](assert) {
run(() => {
application = Application.create({ router: false });
expectDeprecation(() => {
application = Application.create({ router: false });
}, /Using the globals resolver is deprecated/);
application.deferReadiness();
});

Expand All @@ -115,7 +121,9 @@ moduleFor(
jQuery.isReady = false;

run(() => {
application = Application.create({ router: false });
expectDeprecation(() => {
application = Application.create({ router: false });
}, /Using the globals resolver is deprecated/);
application.deferReadiness();
assert.equal(readyWasCalled, 0, "ready wasn't called yet");
});
Expand Down
3 changes: 1 addition & 2 deletions packages/@ember/application/tests/visit_test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { moduleFor, ApplicationTestCase, runTask } from 'internal-test-helpers';
import { moduleFor, Engine, 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';
import Application from '@ember/application';
import ApplicationInstance from '@ember/application/instance';
import Engine from '@ember/engine';
import { Route } from '@ember/-internals/routing';
import { Component, helper, isSerializationFirstNode } from '@ember/-internals/glimmer';
import { compile } from 'ember-template-compiler';
Expand Down
5 changes: 2 additions & 3 deletions packages/@ember/engine/tests/engine_initializers_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { run } from '@ember/runloop';
import Engine from '@ember/engine';
import { moduleFor, AbstractTestCase as TestCase } from 'internal-test-helpers';
import { moduleFor, Engine, AbstractTestCase as TestCase } from 'internal-test-helpers';

let MyEngine, myEngine, myEngineInstance;

Expand Down Expand Up @@ -347,7 +346,7 @@ moduleFor(
}

['@test initializers are executed in their own context'](assert) {
assert.expect(1);
assert.expect(2);

MyEngine = Engine.extend();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { run } from '@ember/runloop';
import Engine, { setEngineParent } from '@ember/engine';
import { setEngineParent } from '@ember/engine';
import EngineInstance from '@ember/engine/instance';
import { moduleFor, AbstractTestCase as TestCase } from 'internal-test-helpers';
import { moduleFor, Engine, AbstractTestCase as TestCase } from 'internal-test-helpers';

let MyEngine, myEngine, myEngineInstance;

Expand Down Expand Up @@ -388,7 +388,7 @@ moduleFor(
}

['@test initializers are executed in their own context'](assert) {
assert.expect(1);
assert.expect(2);

let MyEngine = Engine.extend();

Expand Down
8 changes: 4 additions & 4 deletions packages/@ember/engine/tests/engine_instance_test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Engine, { getEngineParent, setEngineParent } from '@ember/engine';
import { getEngineParent, setEngineParent } from '@ember/engine';
import EngineInstance from '@ember/engine/instance';
import { run } from '@ember/runloop';
import { factory } from 'internal-test-helpers';
import { moduleFor, AbstractTestCase as TestCase } from 'internal-test-helpers';
import { moduleFor, Engine, AbstractTestCase as TestCase } from 'internal-test-helpers';

let engine, engineInstance;

Expand Down Expand Up @@ -39,7 +39,7 @@ moduleFor(
}

['@test unregistering a factory clears all cached instances of that factory'](assert) {
assert.expect(3);
assert.expect(4);

engineInstance = run(() => EngineInstance.create({ base: engine }));

Expand All @@ -64,7 +64,7 @@ moduleFor(
}

['@test can be booted when its parent has been set'](assert) {
assert.expect(3);
assert.expect(4);

engineInstance = run(() => EngineInstance.create({ base: engine }));

Expand Down
2 changes: 1 addition & 1 deletion packages/@ember/engine/tests/engine_test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { context } from '@ember/-internals/environment';
import { run } from '@ember/runloop';
import Engine from '@ember/engine';
import { Object as EmberObject } from '@ember/-internals/runtime';
import { privatize as P } from '@ember/-internals/container';
import {
moduleFor,
AbstractTestCase as TestCase,
Engine,
verifyInjection,
verifyRegistration,
} from 'internal-test-helpers';
Expand Down
12 changes: 9 additions & 3 deletions packages/ember-testing/tests/adapters_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ moduleFor(
});

run(function() {
App = EmberApplication.create();
ignoreDeprecation(() => {
App = EmberApplication.create();
}, /Using the globals resolver is deprecated/);
Test.adapter = CustomAdapter.create();
App.setupForTesting();
});
Expand All @@ -86,7 +88,9 @@ moduleFor(
Test.adapter = null;

run(function() {
App = EmberApplication.create();
ignoreDeprecation(() => {
App = EmberApplication.create();
}, /Using the globals resolver is deprecated/);
App.setupForTesting();
});

Expand All @@ -101,7 +105,9 @@ moduleFor(
Test.adapter = null;

run(function() {
App = EmberApplication.create();
ignoreDeprecation(() => {
App = EmberApplication.create();
}, /Using the globals resolver is deprecated/);
App.setupForTesting();
});

Expand Down
4 changes: 3 additions & 1 deletion packages/ember-testing/tests/helper_registration_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ function setupApp() {
helperContainer = {};

run(function() {
App = EmberApplication.create();
ignoreDeprecation(() => {
App = EmberApplication.create();
}, /Using the globals resolver is deprecated/);
App.setupForTesting();
App.injectTestHelpers(helperContainer);
});
Expand Down
Loading

0 comments on commit 2f49f5f

Please sign in to comment.