From 0b45a5920ae40cde08bc652b0050b40c0f2c8d86 Mon Sep 17 00:00:00 2001 From: Matthew Edwards Date: Wed, 23 Jun 2021 14:40:37 -0700 Subject: [PATCH] Format all code; Fix failing tests with .trim() of ouptut --- packages/@glimmerx/core/tests/index.ts | 28 +++++++++---------- .../@glimmerx/core/tests/modifier-tests.ts | 10 ++++--- packages/@glimmerx/core/tests/render-tests.ts | 6 ++-- packages/@glimmerx/helper/src/helper.ts | 2 +- packages/@glimmerx/service/src/decorator.ts | 2 +- .../addon/components/button-list.js | 6 +++- packages/examples/basic/src/MyComponent.ts | 9 +++--- packages/examples/basic/src/OtherComponent.ts | 3 +- .../basic/src/OtherComponentCSF.stories.ts | 2 +- .../src/StaticComponent.ts | 2 +- 10 files changed, 40 insertions(+), 30 deletions(-) diff --git a/packages/@glimmerx/core/tests/index.ts b/packages/@glimmerx/core/tests/index.ts index f08a1af8..3af479b9 100644 --- a/packages/@glimmerx/core/tests/index.ts +++ b/packages/@glimmerx/core/tests/index.ts @@ -3,19 +3,19 @@ import renderTests, { Constructor } from './render-tests'; import { renderComponent, RenderComponentOptions } from '..'; import Component from '@glimmerx/component'; -renderTests( - '@glimmerx/core', - async (component: Constructor, options?: RenderComponentOptions) => { - const element = document.getElementById('qunit-fixture')!; - element.innerHTML = ''; +renderTests('@glimmerx/core', async ( + component: Constructor, + options?: RenderComponentOptions +) => { + const element = document.getElementById('qunit-fixture')!; + element.innerHTML = ''; - if (options) { - options.element = element; - await renderComponent(component, options); - } else { - await renderComponent(component, element); - } - - return element.innerHTML; + if (options) { + options.element = element; + await renderComponent(component, options); + } else { + await renderComponent(component, element); } -); + + return element.innerHTML; +}); diff --git a/packages/@glimmerx/core/tests/modifier-tests.ts b/packages/@glimmerx/core/tests/modifier-tests.ts index 7f9fd68e..ee138720 100644 --- a/packages/@glimmerx/core/tests/modifier-tests.ts +++ b/packages/@glimmerx/core/tests/modifier-tests.ts @@ -7,7 +7,9 @@ import { renderComponent, didRender } from '..'; module('Modifier Tests', () => { test('Supports the on modifier', async (assert) => { class MyComponent extends Component { - static template = hbs``; + static template = hbs` + + `; @tracked count = 0; @action @@ -19,17 +21,17 @@ module('Modifier Tests', () => { const element = document.getElementById('qunit-fixture')!; await renderComponent(MyComponent, element); + assert.strictEqual( - element.innerHTML, + element.innerHTML.trim(), ``, 'the component was rendered' ); element.querySelector('button')!.click(); - await didRender(); assert.strictEqual( - element.innerHTML, + element.innerHTML.trim(), ``, 'the component was rerendered' ); diff --git a/packages/@glimmerx/core/tests/render-tests.ts b/packages/@glimmerx/core/tests/render-tests.ts index 108dd1c0..4ca6e858 100644 --- a/packages/@glimmerx/core/tests/render-tests.ts +++ b/packages/@glimmerx/core/tests/render-tests.ts @@ -159,7 +159,9 @@ export default function renderTests( test('a component can use modifiers', async (assert) => { class MyComponent extends Component { - static template = hbs``; + static template = hbs` + + `; @tracked count = 0; @@ -170,7 +172,7 @@ export default function renderTests( } const html = await render(MyComponent); - assert.strictEqual(html, ``, 'the component was rendered'); + assert.strictEqual(html.trim(), ``, 'the component was rendered'); }); test('supports functions as simple helpers', async (assert) => { diff --git a/packages/@glimmerx/helper/src/helper.ts b/packages/@glimmerx/helper/src/helper.ts index efc5124e..411a9ce9 100644 --- a/packages/@glimmerx/helper/src/helper.ts +++ b/packages/@glimmerx/helper/src/helper.ts @@ -31,7 +31,7 @@ class BasicHelperManager implements HelperManager { {}, { get(_target, key) { - return owner && owner.lookup({ type: 'service', name: (key as unknown) as string }); + return owner && owner.lookup({ type: 'service', name: key as unknown as string }); }, } ); diff --git a/packages/@glimmerx/service/src/decorator.ts b/packages/@glimmerx/service/src/decorator.ts index b397019f..61991294 100644 --- a/packages/@glimmerx/service/src/decorator.ts +++ b/packages/@glimmerx/service/src/decorator.ts @@ -36,5 +36,5 @@ export function service( return makeServiceDecorator(targetOrServiceName); } - return makeServiceDecorator((key as unknown) as string)(targetOrServiceName, key!); + return makeServiceDecorator(key as unknown as string)(targetOrServiceName, key!); } diff --git a/packages/examples/basic-addon/addon/components/button-list.js b/packages/examples/basic-addon/addon/components/button-list.js index 2470e833..cb318f65 100644 --- a/packages/examples/basic-addon/addon/components/button-list.js +++ b/packages/examples/basic-addon/addon/components/button-list.js @@ -14,7 +14,11 @@ export default class ButtonList extends Component { static template = hbs` {{#each this.buttonList.buttons as |button|}} - + {{/each}} `; } diff --git a/packages/examples/basic/src/MyComponent.ts b/packages/examples/basic/src/MyComponent.ts index f9b20bed..98c4c2fd 100644 --- a/packages/examples/basic/src/MyComponent.ts +++ b/packages/examples/basic/src/MyComponent.ts @@ -28,7 +28,8 @@ const TemplateOnlyComponent = hbs`

I am rendered by a template only component class MyComponent extends Component { static template = hbs` -

Hello {{this.message}}


+

Hello {{this.message}}

+
{{myHelper "foo" greeting="Hello"}}

Current locale: {{this.currentLocale}}

{{#if (isCJK)}} @@ -46,10 +47,10 @@ class MyComponent extends Component { - + - - + + `; message = 'hello world'; diff --git a/packages/examples/basic/src/OtherComponent.ts b/packages/examples/basic/src/OtherComponent.ts index cff1b976..a95e3cc1 100644 --- a/packages/examples/basic/src/OtherComponent.ts +++ b/packages/examples/basic/src/OtherComponent.ts @@ -4,5 +4,6 @@ export default class OtherComponent extends Component { static template = hbs`
Counter Val: {{@count}} -
`; + + `; } diff --git a/packages/examples/basic/src/OtherComponentCSF.stories.ts b/packages/examples/basic/src/OtherComponentCSF.stories.ts index fe04be41..6823834d 100644 --- a/packages/examples/basic/src/OtherComponentCSF.stories.ts +++ b/packages/examples/basic/src/OtherComponentCSF.stories.ts @@ -38,7 +38,7 @@ Colored.args = { // Export an inline story in CSF format export const inLineBasic = (args) => - hbs``; + hbs``; inLineBasic.args = { ...Basic.args, bgcolor: 'lightblue', diff --git a/packages/examples/partial-rehydration/src/StaticComponent.ts b/packages/examples/partial-rehydration/src/StaticComponent.ts index 5db96b34..3991556c 100644 --- a/packages/examples/partial-rehydration/src/StaticComponent.ts +++ b/packages/examples/partial-rehydration/src/StaticComponent.ts @@ -4,6 +4,6 @@ import RehydratingComponent from './RehydratingComponent'; export default hbs`

Hello I am a static component. I don't change after page load.

- +
`;