From cba48c512ce5426d6f6527a93e5366c3de5b9796 Mon Sep 17 00:00:00 2001 From: Thomas Wang Date: Fri, 2 Oct 2020 15:48:09 -0700 Subject: [PATCH] Trim RouterNonApplicationTestCase to minimum --- .../non_application_test_test.js | 8 +- .../lib/test-cases/router-non-application.js | 96 +------------------ 2 files changed, 5 insertions(+), 99 deletions(-) diff --git a/packages/ember/tests/routing/router_service_test/non_application_test_test.js b/packages/ember/tests/routing/router_service_test/non_application_test_test.js index 76beab597d3..ffaf14b3c10 100644 --- a/packages/ember/tests/routing/router_service_test/non_application_test_test.js +++ b/packages/ember/tests/routing/router_service_test/non_application_test_test.js @@ -12,14 +12,14 @@ moduleFor( super(...arguments); this.resolver.add('router:main', Router.extend(this.routerOptions)); - this.router.map(function() { - this.route('parent', { path: '/' }, function() { + this.router.map(function () { + this.route('parent', { path: '/' }, function () { this.route('child'); this.route('sister'); this.route('brother'); }); this.route('dynamic', { path: '/dynamic/:dynamic_id' }); - this.route('dynamicWithChild', { path: '/dynamic-with-child/:dynamic_id' }, function() { + this.route('dynamicWithChild', { path: '/dynamic-with-child/:dynamic_id' }, function () { this.route('child', { path: '/:child_id' }); }); }); @@ -81,7 +81,7 @@ moduleFor( this.render('{{foo-bar}}'); - run(function() { + run(function () { componentInstance.send('transitionToSister'); }); diff --git a/packages/internal-test-helpers/lib/test-cases/router-non-application.js b/packages/internal-test-helpers/lib/test-cases/router-non-application.js index 7e9837e4c65..f59a298f98a 100644 --- a/packages/internal-test-helpers/lib/test-cases/router-non-application.js +++ b/packages/internal-test-helpers/lib/test-cases/router-non-application.js @@ -1,15 +1,13 @@ import { assign } from '@ember/polyfills'; import { compile } from 'ember-template-compiler'; import { EventDispatcher } from '@ember/-internals/views'; -import { helper, Helper, Component, _resetRenderers } from '@ember/-internals/glimmer'; +import { Component, _resetRenderers } from '@ember/-internals/glimmer'; import { ModuleBasedResolver } from '../test-resolver'; import AbstractTestCase from './abstract'; import buildOwner from '../build-owner'; import { runAppend, runDestroy } from '../run'; -const TextNode = window.Text; - export default class RouterNonApplicationTestCase extends AbstractTestCase { constructor() { super(...arguments); @@ -30,20 +28,12 @@ export default class RouterNonApplicationTestCase extends AbstractTestCase { this.renderer = this.owner.lookup('renderer:-dom'); this.element = document.querySelector('#qunit-fixture'); this.component = null; - - if (!bootOptions || bootOptions.isInteractive !== false) { - owner.lookup('event_dispatcher:main').setup(this.getCustomDispatcherEvents(), this.element); - } } compile() { return compile(...arguments); } - getCustomDispatcherEvents() { - return {}; - } - getOwnerOptions() {} getBootOptions() {} @@ -105,10 +95,6 @@ export default class RouterNonApplicationTestCase extends AbstractTestCase { } } - get context() { - return this.component; - } - render(templateStr, context = {}) { let { owner } = this; @@ -130,84 +116,4 @@ export default class RouterNonApplicationTestCase extends AbstractTestCase { runAppend(this.component); } - - rerender() { - this.component.rerender(); - } - - registerHelper(name, funcOrClassBody) { - let type = typeof funcOrClassBody; - - if (type === 'function') { - this.owner.register(`helper:${name}`, helper(funcOrClassBody)); - } else if (type === 'object' && type !== null) { - this.owner.register(`helper:${name}`, Helper.extend(funcOrClassBody)); - } else { - throw new Error(`Cannot register ${funcOrClassBody} as a helper`); - } - } - - registerPartial(name, template) { - let owner = this.owner; - if (typeof template === 'string') { - owner.register( - `template:${name}`, - this.compile(template, { moduleName: `my-app/templates/-${name}.hbs` }) - ); - } - } - - registerComponent(name, { ComponentClass = Component, template = null }) { - let { owner } = this; - - if (ComponentClass) { - owner.register(`component:${name}`, ComponentClass); - } - - if (typeof template === 'string') { - owner.register( - `template:components/${name}`, - this.compile(template, { - moduleName: `my-app/templates/components/${name}.hbs`, - }) - ); - } - } - - registerModifier(name, ModifierClass) { - let { owner } = this; - - owner.register(`modifier:${name}`, ModifierClass); - } - - registerComponentManager(name, manager) { - let owner = this.owner; - owner.register(`component-manager:${name}`, manager); - } - - registerTemplate(name, template) { - let { owner } = this; - if (typeof template === 'string') { - owner.register( - `template:${name}`, - this.compile(template, { - moduleName: `my-app/templates/${name}.hbs`, - }) - ); - } else { - throw new Error(`Registered template "${name}" must be a string`); - } - } - - registerService(name, klass) { - this.owner.register(`service:${name}`, klass); - } - - assertTextNode(node, text) { - if (!(node instanceof TextNode)) { - throw new Error(`Expecting a text node, but got ${node}`); - } - - this.assert.strictEqual(node.textContent, text, 'node.textContent'); - } }