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

added _parent and context to data returned by #with in helpers #1840 #1952

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

smmhatami
Copy link
Contributor

This is a fix to solve Issue 1840. Resolves #1840. Added _parent and context to data returned by with in helpers just like each does to each iterated field.
I just couldn't find where and how should I add tests for this functionality, i would be glad if you help me with that.
thanks!

@jaylinski jaylinski self-requested a review June 23, 2023 16:38
Copy link
Member

@jaylinski jaylinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the right place for a test would be here:

describe('#with', function () {
it('with', function () {
expectTemplate('{{#with person}}{{first}} {{last}}{{/with}}')
.withInput({
person: {
first: 'Alan',
last: 'Johnson',
},
})
.toCompileTo('Alan Johnson');
});
it('with with function argument', function () {
expectTemplate('{{#with person}}{{first}} {{last}}{{/with}}')
.withInput({
person: function () {
return {
first: 'Alan',
last: 'Johnson',
};
},
})
.toCompileTo('Alan Johnson');
});
it('with with else', function () {
expectTemplate(
'{{#with person}}Person is present{{else}}Person is not present{{/with}}'
).toCompileTo('Person is not present');
});
it('with provides block parameter', function () {
expectTemplate('{{#with person as |foo|}}{{foo.first}} {{last}}{{/with}}')
.withInput({
person: {
first: 'Alan',
last: 'Johnson',
},
})
.toCompileTo('Alan Johnson');
});
it('works when data is disabled', function () {
expectTemplate('{{#with person as |foo|}}{{foo.first}} {{last}}{{/with}}')
.withInput({ person: { first: 'Alan', last: 'Johnson' } })
.withCompileOptions({ data: false })
.toCompileTo('Alan Johnson');
});
});

Tests can be run via npm install and npm run test.

@jaylinski jaylinski added this to the 5.0.0 milestone Aug 1, 2023
Copy link
Member

@jaylinski jaylinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smmhatami Can you add a test for this? (See comment above on where to add it.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using key / context in helpers
2 participants