Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos in yield-context-extractor.ts #417

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/utils/yield-context-extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
const acc: Record<string, unknown> = {};

return {
$elemant: node.tag,
$element: node.tag,
$attributes: this.map(node.attributes).reduce((acc, [key, val]) => {
Object.defineProperty(acc, key, {
value: val,
Expand All @@ -79,12 +79,12 @@
return acc;
}, acc),
$modifiers: this.map(node.modifiers),
$programms: this.map(node.children).filter((e) => typeof e !== 'string'),
$programs: this.map(node.children).filter((e) => typeof e !== 'string'),

Check warning on line 82 in src/utils/yield-context-extractor.ts

View check run for this annotation

Codecov / codecov/patch

src/utils/yield-context-extractor.ts#L82

Added line #L82 was not covered by tests
};
}
Template(node: ASTv1.Template | ASTv1.Program) {
return {
$programms: this.map(node.body).filter((e) => typeof e !== 'string'),
$programs: this.map(node.body).filter((e) => typeof e !== 'string'),
};
}
ConcatStatement(node: ASTv1.ConcatStatement) {
Expand Down Expand Up @@ -137,14 +137,14 @@
BlockStatement(node: ASTv1.BlockStatement) {
const result = this.SubExpression(node);

const $programms = [this.Block(node.program)];
const $programs = [this.Block(node.program)];

Check warning on line 140 in src/utils/yield-context-extractor.ts

View check run for this annotation

Codecov / codecov/patch

src/utils/yield-context-extractor.ts#L140

Added line #L140 was not covered by tests

if (node.inverse) {
$programms.push(this.Block(node.inverse));
$programs.push(this.Block(node.inverse));

Check warning on line 143 in src/utils/yield-context-extractor.ts

View check run for this annotation

Codecov / codecov/patch

src/utils/yield-context-extractor.ts#L143

Added line #L143 was not covered by tests
}

Object.defineProperty(result, '$programms', {
value: $programms,
Object.defineProperty(result, '$programs', {

Check warning on line 146 in src/utils/yield-context-extractor.ts

View check run for this annotation

Codecov / codecov/patch

src/utils/yield-context-extractor.ts#L146

Added line #L146 was not covered by tests
value: $programs,
});

return result;
Expand Down
24 changes: 22 additions & 2 deletions test/utils/yield-context-extractor-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function extract(tpl: string) {
return extractYieldMetadata(preprocess(tpl));
}

describe('Yeld Metadata API', () => {
describe('Yield Metadata API', () => {
it('should handle default yield with hash', () => {
expect(
extract(`
Expand Down Expand Up @@ -91,7 +91,27 @@ describe('Yeld Metadata API', () => {
`)
).toEqual({ 'default:0:': ['component', 'foo-bar'], 'default:1:': ['component', 'foo-baz'] });
});
it('should handle default yeld with single positional hash argument with component property', () => {
it('should handle default yield with single positional hash argument with component property', () => {
expect(extract(`{{yield (hash Foo=(component "my-component"))}}`)).toEqual({ 'default:0:Foo': ['component', 'my-component'] });
});
it('should extract only yield content when nested in a div with other content', () => {
expect(
extract(`
<div class="example">
<p>Some Content</p>
{{yield (hash Foo=(component "my-component"))}}
</div>
`)
).toEqual({ 'default:0:Foo': ['component', 'my-component'] });
});

it('should extract only yield content when nested in an "if" statement', () => {
expect(
extract(`
{{#if this.isTrue}}
{{yield (hash Foo=(component "my-component"))}}
{{/if}}
`)
).toEqual({ 'default:0:Foo': ['component', 'my-component'] });
});
});
Loading