Skip to content

Commit

Permalink
Add new failing test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
twbartel committed Jun 3, 2020
1 parent 460518b commit c2b4a66
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 5 deletions.
96 changes: 92 additions & 4 deletions tests/Failing/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ exports[`controversial.melody.twig 1`] = `
{% set isRewardRate = isMarriottRewardRate or (rewardRateAltIds and deal.dealId in altIds) %}
<!-- Always break objects -->
<section class="{{ { base: css.prices } | classes }}"></section>
<section class="{{ {
base: css.prices
} | classes }}"></section>
<!-- This is what happens if we reduce indentation depth here:
"as" and object keys at same indentation level
Expand All @@ -70,13 +72,17 @@ exports[`controversial.melody.twig 1`] = `
</article>
<!-- Parentheses stripped. Cannot fix this. Either always parentheses, or never when args empty. -->
{% include './partials/arrowBtn.melody.twig' with { ref: prev | default } only %}
{% include './partials/arrowBtn.melody.twig' with {
ref: prev | default
} only %}
<!-- A lot of line breaks with a width of 80 and twigAlwaysBreakObjects = true -->
<p class="alert__message">
{{
'results_for'
| translate({ searchedterm: '<mark class="highlight-search-term">' ~ semKeyword ~ '</mark>' })
| translate({
searchedterm: '<mark class="highlight-search-term">' ~ semKeyword ~ '</mark>'
})
| raw
}}
</p>
Expand All @@ -102,6 +108,41 @@ exports[`failing.melody.twig 1`] = `
} | classes
}
%}
{# "only" dropped, comment dropped #}
{% embed '@hotelsearch/common/tooltip/tooltip.melody.twig' with {
position: 'bottomTrailing',
id: 'most-popular-badge',
classList: tooltipOpen ? 'show-tooltip',
isAriaHidden: not tooltipOpen ?? false
} only %}
{# Necessary block to inject html into the tooltip #}
{% block text %}
<p>Hey></p>
{% endblock %}
{% endembed %}
{# Inserts a newline where it shouldn't #}
<span class="rat-chart__bar">
<span class="rat-chart__bar-holder">
<span class="rat-chart__bar-content rat-color--{{ valueIndex }}" {{ { "style": width } | attrs }}></span>
</span>
</span>
{# Parentheses dropped. Might be valid, but could be better, cosmetically #}
{% for feature in (showAAAmenities ? entirePlaceFeatures : topFeatures) %}
abcd
{% endfor %}
{# There should be no whitespace changes in textarea #}
<textarea class="{{ codePreview }}">{{
'
{% icon "' ~ icon ~ '" with {
classList: "' ~ classMap | classes ~ '",
} %}
'
}}
</textarea>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{# IF tag in element not allowed
<option {% if not purchasable.isAvailable %}disabled{% endif %}>
Expand All @@ -116,7 +157,54 @@ exports[`failing.melody.twig 1`] = `
{% icon 'general/arrow-36x36'
with
{ classList: { base: "#{css["arrowIcon#{action}"]} icon-rtl", 'icon-flip': flipIcon ?? false } | classes }
{
classList: {
base: "#{css["arrowIcon#{action}"]} icon-rtl",
'icon-flip': flipIcon ?? false
} | classes
}
%}
{# "only" dropped, comment dropped #}
{% embed '@hotelsearch/common/tooltip/tooltip.melody.twig'
with {
position: 'bottomTrailing',
id: 'most-popular-badge',
classList: tooltipOpen ? 'show-tooltip',
isAriaHidden: not (tooltipOpen ?? false)
}
%}
{% block text %}
<p>
Hey>
</p>
{% endblock %}
{% endembed %}
{# Inserts a newline where it shouldn't #}
<span class="rat-chart__bar">
<span class="rat-chart__bar-holder">
<span class="rat-chart__bar-content rat-color--{{ valueIndex }}"
{{ {
style: width
} | attrs }}>
</span>
</span>
</span>
{# Parentheses dropped. Might be valid, but could be better, cosmetically #}
{% for feature in showAAAmenities ? entirePlaceFeatures : topFeatures %}
abcd
{% endfor %}
{# There should be no whitespace changes in textarea #}
<textarea class="{{ codePreview }}">
{{ '
{% icon "' ~ icon ~ '" with {
classList: "' ~ (classMap | classes) ~ '",
} %}
' }}
</textarea>
`;
35 changes: 35 additions & 0 deletions tests/Failing/failing.melody.twig
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,38 @@
} | classes
}
%}

{# "only" dropped, comment dropped #}
{% embed '@hotelsearch/common/tooltip/tooltip.melody.twig' with {
position: 'bottomTrailing',
id: 'most-popular-badge',
classList: tooltipOpen ? 'show-tooltip',
isAriaHidden: not tooltipOpen ?? false
} only %}
{# Necessary block to inject html into the tooltip #}
{% block text %}
<p>Hey></p>
{% endblock %}
{% endembed %}

{# Inserts a newline where it shouldn't #}
<span class="rat-chart__bar">
<span class="rat-chart__bar-holder">
<span class="rat-chart__bar-content rat-color--{{ valueIndex }}" {{ { "style": width } | attrs }}></span>
</span>
</span>

{# Parentheses dropped. Might be valid, but could be better, cosmetically #}
{% for feature in (showAAAmenities ? entirePlaceFeatures : topFeatures) %}
abcd
{% endfor %}

{# There should be no whitespace changes in textarea #}
<textarea class="{{ codePreview }}">{{
'
{% icon "' ~ icon ~ '" with {
classList: "' ~ classMap | classes ~ '",
} %}
'
}}
</textarea>
2 changes: 1 addition & 1 deletion tests/Failing/jsfmt.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
run_spec(__dirname, ["melody"], {
twigPrintWidth: 120,
twigAlwaysBreakObjects: false,
twigAlwaysBreakObjects: true,
twigFollowOfficialCodingStandards: false
});

0 comments on commit c2b4a66

Please sign in to comment.