Skip to content

Commit

Permalink
Format all code; Fix failing tests with .trim() of ouptut
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Edwards committed Jun 23, 2021
1 parent 08596c2 commit 0b45a59
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 30 deletions.
28 changes: 14 additions & 14 deletions packages/@glimmerx/core/tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Component>, options?: RenderComponentOptions) => {
const element = document.getElementById('qunit-fixture')!;
element.innerHTML = '';
renderTests('@glimmerx/core', async (
component: Constructor<Component>,
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;
});
10 changes: 6 additions & 4 deletions packages/@glimmerx/core/tests/modifier-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`<button {{on "click" this.incrementCounter}}>Count: {{this.count}}</button>`;
static template = hbs`
<button {{on "click" this.incrementCounter}}>Count: {{this.count}}</button>
`;
@tracked count = 0;

@action
Expand All @@ -19,17 +21,17 @@ module('Modifier Tests', () => {
const element = document.getElementById('qunit-fixture')!;

await renderComponent(MyComponent, element);

assert.strictEqual(
element.innerHTML,
element.innerHTML.trim(),
`<button>Count: 0</button>`,
'the component was rendered'
);

element.querySelector('button')!.click();

await didRender();
assert.strictEqual(
element.innerHTML,
element.innerHTML.trim(),
`<button>Count: 1</button>`,
'the component was rerendered'
);
Expand Down
6 changes: 4 additions & 2 deletions packages/@glimmerx/core/tests/render-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ export default function renderTests(

test('a component can use modifiers', async (assert) => {
class MyComponent extends Component {
static template = hbs`<button {{on "click" this.incrementCounter}}>Count: {{this.count}}</button>`;
static template = hbs`
<button {{on "click" this.incrementCounter}}>Count: {{this.count}}</button>
`;

@tracked count = 0;

Expand All @@ -170,7 +172,7 @@ export default function renderTests(
}

const html = await render(MyComponent);
assert.strictEqual(html, `<button>Count: 0</button>`, 'the component was rendered');
assert.strictEqual(html.trim(), `<button>Count: 0</button>`, 'the component was rendered');
});

test('supports functions as simple helpers', async (assert) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/@glimmerx/helper/src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class BasicHelperManager implements HelperManager<BasicHelperBucket> {
{},
{
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 });
},
}
);
Expand Down
2 changes: 1 addition & 1 deletion packages/@glimmerx/service/src/decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ export default class ButtonList extends Component {

static template = hbs`
{{#each this.buttonList.buttons as |button|}}
<SimpleButton ...attributes @count={{button.count}} @onClick={{fn this.increaseCount button}} />
<SimpleButton
...attributes
@count={{button.count}}
@onClick={{fn this.increaseCount button}}
/>
{{/each}}
`;
}
9 changes: 5 additions & 4 deletions packages/examples/basic/src/MyComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const TemplateOnlyComponent = hbs`<h1>I am rendered by a template only component

class MyComponent extends Component {
static template = hbs`
<h1>Hello {{this.message}}</h1> <br/>
<h1>Hello {{this.message}}</h1>
<br />
{{myHelper "foo" greeting="Hello"}}
<p>Current locale: {{this.currentLocale}}</p>
{{#if (isCJK)}}
Expand All @@ -46,10 +47,10 @@ class MyComponent extends Component {
<GtsComponent @count={{this.count}} />
</div>
<button {{on "click" this.increment}}>Increment</button>
<TemplateOnlyComponent @name="For Glimmerx"/>
<TemplateOnlyComponent @name="For Glimmerx" />
<ButtonList/>
<ButtonList/>
<ButtonList />
<ButtonList />
`;

message = 'hello world';
Expand Down
3 changes: 2 additions & 1 deletion packages/examples/basic/src/OtherComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ export default class OtherComponent extends Component {
static template = hbs`
<div style="padding:5px;background:{{@bgcolor}}">
<b>Counter Val: {{@count}}</b>
</div>`;
</div>
`;
}
2 changes: 1 addition & 1 deletion packages/examples/basic/src/OtherComponentCSF.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Colored.args = {

// Export an inline story in CSF format
export const inLineBasic = (args) =>
hbs`<OtherComponent @count={{args.count}} @bgcolor={{args.bgcolor}} }}/>`;
hbs`<OtherComponent @count={{args.count}} @bgcolor={{args.bgcolor}} }} />`;
inLineBasic.args = {
...Basic.args,
bgcolor: 'lightblue',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import RehydratingComponent from './RehydratingComponent';
export default hbs`
<div class="static-component">
<h1>Hello I am a static component. I don't change after page load.</h1>
<RehydratingComponent/>
<RehydratingComponent />
</div>
`;

0 comments on commit 0b45a59

Please sign in to comment.