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: STRF-10494 last and first helpers works with strings #254

Merged
merged 2 commits into from
Mar 15, 2023

Conversation

rafa-avila-bc
Copy link
Contributor

What? Why?

while testing in int i found that the following error is thrown

FailedPrecondition: arr.join is not a function : TypeError: arr.join is not a function
    at stringAlt (/opt/app/node_modules/@bigcommerce/stencil-paper-handlebars/helpers/3p/array.js:312:16)

with the following template:

<div style="background-color:aquamarine;">
    <p style="text-align: center;">
        {{first [1,2,3]}}
    </p>
    <p style="text-align: center;">
        {{first [9,8,7,6,5,4,3,2,1] 3}}
    </p>
    <p style="text-align: center;">
        {{first [1,2,3,4,5,6,7,8,9,0] 15}}
    </p>
    <p style="text-align: center;">
        {{last [1,2,3]}}
    </p>
    <p style="text-align: center;">
        {{last [9,8,7,6,5,4,3,2,1] 8}}
    </p>
    <p style="text-align: center;">
        {{last [1,2,3,4,5,6,7,8,9,0] 15}}
    </p>
</div>

    <div style="background-color: aqua;">
        <p style="text-align: center;">
            {{first "BigCommerce"}}
        </p>
        <p style="text-align: center;">
            {{first "BigCommerce" 3}}
        </p>
        <p style="text-align: center;">
            {{first "BigCommerce" 15}}
        </p>
        <p style="text-align: center;">
            {{last "BigCommerce"}}
        </p>
        <p style="text-align: center;">
            {{last "BigCommerce" 8}}
        </p>
        <p style="text-align: center;">
            {{last "BigCommerce" 15}}
        </p>
    </div>

so I'm adding a guard code here.

How was it tested?

unit test


cc @bigcommerce/storefront-team

@rafa-avila-bc rafa-avila-bc self-assigned this Mar 15, 2023
@zvuki
Copy link
Contributor

zvuki commented Mar 15, 2023

@rafa-avila-bc do you want to update a unit test?

jordanarldt
jordanarldt previously approved these changes Mar 15, 2023
@jordanarldt
Copy link
Contributor

Looks good to me, @rafa-avila-bc make sure to address Andrei's comment before merging 👍

jmwiese
jmwiese previously approved these changes Mar 15, 2023
@rafa-avila-bc
Copy link
Contributor Author

@zvuki I've added unit tests.

@rafa-avila-bc rafa-avila-bc merged commit 51f341e into bigcommerce:master Mar 15, 2023
@github-actions
Copy link
Contributor

🎉 This PR is included in version 5.7.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

4 participants