import { describe, test, expect, beforeAll } from "vitest" import { Herb } from "@herb-tools/node-wasm" import { Formatter } from "../../src" import { createExpectFormattedToMatch } from "../helpers" import dedent from "dedent" let formatter: Formatter let expectFormattedToMatch: ReturnType describe("@herb-tools/formatter", () => { beforeAll(async () => { await Herb.load() formatter = new Formatter(Herb, { indentWidth: 2, maxLineLength: 80, }) expectFormattedToMatch = createExpectFormattedToMatch(formatter) }) test("formats simple HTML with ERB content", () => { const source = `
<%= "Hello" %> World
` const result = formatter.format(source) expect(result).toEqual(dedent`
<%= "Hello" %> World
`) }) test("formats standalone ERB", () => { const source = `<% title %>` const result = formatter.format(source) expect(result).toEqual(`<% title %>`) }) test("ERB output tags on two lines on top-level", () => { expectFormattedToMatch(dedent` <%= title %> <%= title %> `) }) test("adjecent ERB output tags without space on top-level", () => { const source = `<%= title %><%= title %>` const result = formatter.format(source) expect(result).toEqual(`<%= title %><%= title %>`) }) test("adjecent ERB output tags with space on top-level", () => { const source = `<%= title %> <%= title %>` const result = formatter.format(source) expect(result).toEqual(`<%= title %> <%= title %>`) }) test("adjecent ERB output tags without space within

", () => { const source = `

<%= title %><%= title %>

` const result = formatter.format(source) expect(result).toEqual(`

<%= title %><%= title %>

`) }) test("adjecent ERB output tags with space within

", () => { const source = `

<%= title %> <%= title %>

` const result = formatter.format(source) expect(result).toEqual(`

<%= title %> <%= title %>

`) }) test("formats nested blocks with final example", () => { const source = `
<%= tag.div class: "div" do %> <% if true %>OK<% else %>NO<% end %> <% end %>
` const result = formatter.format(source) expect(result).toEqual(dedent`
<%= tag.div class: "div" do %> <% if true %> OK <% else %> NO <% end %> <% end %>
`) }) test("preserves ERB within HTML attributes and content", () => { const source = dedent`

<%= title %>

` const result = formatter.format(source) expect(result).toEqual(dedent`

<%= title %>

`) }) test("should not add extra % to ERB closing tags with quoted strings", () => { expectFormattedToMatch(dedent`
<%= link_to "Nederlands", url_for(locale: 'nl'), class: "px-4 py-2 hover:bg-slate-100 rounded block" %> <%= link_to "Français", url_for(locale: 'fr'), class: "px-4 py-2 hover:bg-slate-100 rounded block" %> <%= link_to "English", url_for(locale: 'en'), class: "px-4 py-2 hover:bg-slate-100 rounded block" %>
`) }) test("should handle complex ERB in layout files", () => { const input = dedent`
<% if notice.present? %>

<%= notice %>

<% end %>
` const result = formatter.format(input) expect(result).not.toContain("% %>") expect(result).toContain("<% if notice.present? %>") expect(result).toContain("<% end %>") expect(result).toContain("<%= notice %>") }) test("handles ERB tags ending with various patterns", () => { const inputs = [ '<%= link_to "test" %>', '<%= link_to "test", class: "btn" %>', '<%= render "partial" %>', "<% if something? %>", '<%= tag.div("content") %>', ] inputs.forEach((input) => { const result = formatter.format(input) expect(result).not.toContain("% %>") expect(result).toBe(input) }) }) test("preserves ERB content with HTML entities when line wrapping occurs", () => { const input = dedent`

<%= link_to "Start", start_path %>’s overview of <%= link_to "Section", section_path %>, <%= link_to "End", end_path %>.

` const result = formatter.format(input) expect(result).toBe(dedent`

<%= link_to "Start", start_path %>’s overview of <%= link_to "Section", section_path %>, <%= link_to "End", end_path %>.

`) }) test("preserves complex ERB expressions when exceeding line length", () => { const input = dedent`

For assistance, contact us at <%= config.phone_number %> or <%= mail_to(config.support_email, class: "email-link") %> if you need help with your account.

` const result = formatter.format(input) expect(result).toBe(dedent`

For assistance, contact us at <%= config.phone_number %> or <%= mail_to(config.support_email, class: "email-link") %> if you need help with your account.

`) }) test("issue 469: keeps punctuation attached to ERB interpolations and inline elements", () => { const input = `<%= @user.translated_greeting %>,
` const result = formatter.format(input) expect(result).toBe(`<%= @user.translated_greeting %>,
`) }) test("issue 590: does not duplicate content with inline elements and long lines", () => { const input = dedent`

Hi
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567

` const result = formatter.format(input) expect(result).toBe(dedent`

Hi
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567

`) }) test("issue 588: does not recursively duplicate text and br tags", () => { const input = dedent` <%= form_with model: @article do |form| %>

Text 1
The lantern flickered softly in the wind as the old clock struck midnight across the quiet village, casting long shadows that danced upon the cobblestone streets.

<% end %> ` const result = formatter.format(input) expect(result).toBe(dedent` <%= form_with model: @article do |form| %>

Text 1
The lantern flickered softly in the wind as the old clock struck midnight across the quiet village, casting long shadows that danced upon the cobblestone streets.

<% end %> `) const secondFormat = formatter.format(result) expect(secondFormat).toBe(result) }) test("issue 564: does not duplicate multiline text with br elements", () => { const input = dedent` Par défaut, un dossier déposé peut être complété ou corrigé par le demandeur jusqu'à sa mise en instruction.
Dans une démarche déclarative, une fois déposé, un dossier ne peut plus être modifié. Soit il passe immédiatement en instruction
` const result = formatter.format(input) expect(result).toBe(dedent` Par défaut, un dossier déposé peut être complété ou corrigé par le demandeur jusqu'à sa mise en instruction.
Dans une démarche déclarative, une fois déposé, un dossier ne peut plus être modifié. Soit il passe immédiatement en instruction
`) const secondFormat = formatter.format(result) expect(secondFormat).toBe(result) }) test("issue 978: does not duplicate content with multiple adjacent inline/ERB groups separated by br", () => { const input = dedent`

<%= t("admin.tickets.form.savings") %><%= ticket.ticketable.savings_percentage %>%
<%= t("admin.tickets.form.price_per_ticket") %><%= format_price(ticket.ticketable.price_per_ticket) %>

` const result = formatter.format(input) expect(result).toBe(dedent`

<%= t("admin.tickets.form.savings") %><%= ticket.ticketable.savings_percentage %>%
<%= t("admin.tickets.form.price_per_ticket") %><%= format_price(ticket.ticketable.price_per_ticket) %>

`) // Test idempotency const secondFormat = formatter.format(result) expect(secondFormat).toBe(result) }) test("https://github.com/hanakai-rb/site/blob/8adc128d9d464f3e37615be2aa29d57979904533/app/templates/pages/home.html.erb", () => { const input = dedent`

Hanakai

This is the upcoming Hanakai website.

This will be the all-in-one home for everything to do with Hanami, Dry and Rom.

` const result = formatter.format(input) expect(result).toBe(dedent`

Hanakai

This is the upcoming Hanakai website.

This will be the all-in-one home for everything to do with Hanami, Dry and Rom.

`) expect(formatter.format(result)).toBe(result) }) test("https://github.com/marcoroth/herb/issues/436#issuecomment-3220198776", () => { const input = dedent`

Here is some text.
Tel: 08-123 456 78

` const result = formatter.format(input) expect(result).toBe(dedent`

Here is some text.
Tel: 08-123 456 78

`) expect(formatter.format(result)).toBe(result) }) test("https://github.com/marcoroth/herb/issues/564#issuecomment-3371485687", () => { const input = dedent`

Should not be duplicated.
Text with a inline elementsomething@something.com and some more text after

` const result = formatter.format(input) expect(result).toBe(dedent`

Should not be duplicated.
Text with a inline elementsomething@something.com and some more text after

`) expect(formatter.format(result)).toBe(result) }) test("handles inline HTML elements with long text content", () => { const input = dedent`

Visit our amazing product catalog with hundreds of items or contact our customer support team for assistance with your order.

` const result = formatter.format(input) expect(result).toBe(dedent`

Visit our amazing product catalog with hundreds of items or contact our customer support team for assistance with your order.

`) }) test("handles multiple inline elements with adjacent text", () => { const input = dedent`
Call us at 555-123-4567, email help@example.com, or visit our downtown office during business hours.
` const result = formatter.format(input) expect(result).toBe(dedent`
Call us at 555-123-4567, email help@example.com, or visit our downtown office during business hours.
`) }) test("handles inline elements with punctuation attachment", () => { const input = dedent`

Read the terms and conditions, review our privacy policy, and check the frequently asked questions.

` const result = formatter.format(input) expect(result).toBe(dedent`

Read the terms and conditions, review our privacy policy, and check the frequently asked questions.

`) }) test("handles nested inline elements with line wrapping", () => { const input = dedent`

Please review Chapter 3: Advanced Techniques in the user manual for detailed instructions on configuration.

` const result = formatter.format(input) expect(result).toBe(dedent`

Please review Chapter 3: Advanced Techniques in the user manual for detailed instructions on configuration.

`) }) test("handles inline elements immediately followed by punctuation", () => { const input = dedent`
Download the latest version; install it quickly; then restart your computer!
` const result = formatter.format(input) expect(result).toBe(dedent`
Download the latest version; install it quickly; then restart your computer!
`) }) test("handles mixed content with inline elements and long URLs", () => { const input = dedent`

For more information, visit our comprehensive documentation or contact support.

` const result = formatter.format(input) expect(result).toBe(dedent`

For more information, visit our comprehensive documentation or contact support.

`) }) test("handles anchor tags with content that forces line breaks", () => { const input = dedent`

For more information, visit our comprehensive documentation or contact support.

` const result = formatter.format(input) expect(result).toBe(dedent`

For more information, visit our comprehensive documentation or contact support.

`) }) test("https://github.com/marcoroth/herb/issues/436#issue-3351228515", () => { const input = dedent` <%= message.subject %> | Company <%= stylesheet_link_tag "mailer", media: "all" %> <% if content_for?(:preheader) %> <% end %>
<% if content_for?(:header) %> <%= yield :header %> <% else %> <%= hosted_image_tag('mailer/header-logo.png', class: 'h-[35px] block mb-3') %> <% end %> <%= yield %>
<%= hosted_image_tag('mailer/footer-logo.png', class: 'h-[48px] mb-1') %>

©<%= Time.current.year %> - Company Inc, All rights reserved.
Main Street, San Francisco, CAs, USA 12345
Contact Support | Terms of Service | Privacy Policy

` const expected = dedent` <%= message.subject %> | Company <%= stylesheet_link_tag "mailer", media: "all" %> <% if content_for?(:preheader) %> <% end %>
<% if content_for?(:header) %> <%= yield :header %> <% else %> <%= hosted_image_tag('mailer/header-logo.png', class: 'h-[35px] block mb-3') %> <% end %> <%= yield %>
<%= hosted_image_tag('mailer/footer-logo.png', class: 'h-[48px] mb-1') %>

©<%= Time.current.year %> - Company Inc, All rights reserved.
Main Street, San Francisco, CAs, USA 12345
Contact Support | Terms of Service | Privacy Policy

` const result = formatter.format(input) expect(result).toBe(expected) }) test("https://github.com/marcoroth/herb/issues/436#issuecomment-3219820557 Example 1", () => { const input = dedent` <% unless skip_sidebar? || sidebar_sections_for_action.blank? %> <%= render "active_admin/shared/sidebar_sections" %> <% end %> ` const expected = dedent` <% unless skip_sidebar? || sidebar_sections_for_action.blank? %> <%= render "active_admin/shared/sidebar_sections" %> <% end %> ` const result = formatter.format(input) expect(result).toBe(expected) }) test("https://github.com/marcoroth/herb/issues/436#issuecomment-3219820557 Example 2", () => { const input = dedent`
` const expected = dedent`
` const result = formatter.format(input) expect(result).toBe(expected) }) test("https://github.com/marcoroth/herb/issues/436#issuecomment-3219820557 Example 3", () => { expectFormattedToMatch(dedent` <% content_for :head do %> <%= javascript_import_module_tag "src/chat" %> <% end %>
`) }) test("https://github.com/marcoroth/herb/issues/436#issuecomment-3219820557 Example 4", () => { const input = dedent` <% prices = params.dig("subscription", "prices") || resource.price_list.dig("products")&.map { |key, value| {product_id: key, stripe_price_id: value} } || [{product_id: Product::PUBLIC_IDS[:overweight]}] %> <%= semantic_form_for [:admin, resource], url: override_prices_admin_subscription_path(resource), method: :post do |f| %>
<%= f.inputs do %>
<% prices.each_with_index do |price, index| %> <% stripe_price = Rails.cache.fetch("stripe_price_#{price[:stripe_price_id]}", expires_in: 1.hour) { Stripe::Price.retrieve(price[:stripe_price_id]) } if price[:stripe_price_id].present? %>
<%= f.input :product_id, as: :select, collection: Product.all, selected: price[:product_id], label: "Product #{index + 1}", value_field: :public_id, input_html: { name: "subscription[prices][#{index}][product_id]", } %> <%= f.input :amount, as: :number, label: "Price", input_html: { name: "subscription[prices][#{index}][amount]", value: price[:amount]&.to_i || stripe_price&.unit_amount&./(100) || 0, min: 0 } %> <% if index > 0 %> Remove Product <% end %>
<% end %>
<%= link_to "Add Another Product", "#", id: "add-price-btn", class: "button secondary" %>
<% end %>
<%= f.actions do %> <%= f.action :submit, label: "Override Prices" %> <%= link_to "Cancel", resource_path(resource), class: "button" %> <% end %>
<% end %> ` const expected = dedent` <% prices = params.dig("subscription", "prices") || resource.price_list.dig("products")&.map { |key, value| {product_id: key, stripe_price_id: value} } || [{product_id: Product::PUBLIC_IDS[:overweight]}] %> <%= semantic_form_for [:admin, resource], url: override_prices_admin_subscription_path(resource), method: :post do |f| %>
<%= f.inputs do %>
<% prices.each_with_index do |price, index| %> <% stripe_price = Rails.cache.fetch("stripe_price_#{price[:stripe_price_id]}", expires_in: 1.hour) { Stripe::Price.retrieve(price[:stripe_price_id]) } if price[:stripe_price_id].present? %>
<%= f.input :product_id, as: :select, collection: Product.all, selected: price[:product_id], label: "Product #{index + 1}", value_field: :public_id, input_html: { name: "subscription[prices][#{index}][product_id]", } %> <%= f.input :amount, as: :number, label: "Price", input_html: { name: "subscription[prices][#{index}][amount]", value: price[:amount]&.to_i || stripe_price&.unit_amount&./(100) || 0, min: 0 } %> <% if index > 0 %> Remove Product <% end %>
<% end %>
<%= link_to "Add Another Product", "#", id: "add-price-btn", class: "button secondary" %>
<% end %>
<%= f.actions do %> <%= f.action :submit, label: "Override Prices" %> <%= link_to "Cancel", resource_path(resource), class: "button" %> <% end %>
<% end %> ` const result = formatter.format(input) expect(result).toBe(expected) }) test("https://github.com/marcoroth/herb/issues/436#issuecomment-3219820557 Example 5", () => { const input = dedent` <%# Non-link tag that stands for skipped pages... - available local variables current_page: a page object for the currently displayed page total_pages: total number of pages per_page: number of items to fetch per page remote: data-remote -%> <%= t('views.pagination.truncate').html_safe %> ` const expected = dedent` <%# Non-link tag that stands for skipped pages... - available local variables current_page: a page object for the currently displayed page total_pages: total number of pages per_page: number of items to fetch per page remote: data-remote -%> <%= t('views.pagination.truncate').html_safe %> ` const result = formatter.format(input) expect(result).toBe(expected) }) test("https://github.com/marcoroth/herb/issues/436#issuecomment-3219820557 Example 6", () => { const input = dedent` <%= render 'user_mailer/greeting' %>

Welcome back! Your subscription to the <%= @subscription.plan&.name || "Custom Plan" %> has been successfully resumed.

Subscription Details:
Plan Name: <%= @subscription.plan&.name || "Custom Plan" %>
Resumption Date: <%= render_date(Time.current, format: '%B %e, %Y') %>
Pickups Left: <%= @subscription.credit_service.available_credits.values.first || 0 %><%= " (#{@subscription.loads * 20}lbs per pickup)" if @subscription.loads > 0 %>
Next Billing Date: <%= render_date(@subscription.current_period_end, format: '%B %e, %Y') %>

Why wait now? Schedule your next pickup today!

<%= render "user_mailer/schedule_now" %> <%= render "user_subscription_mailer/more_info" %> <%= render "user_mailer/questions" %>

Thank you for choosing Company again. We look forward to serving you!

<%= render "user_mailer/thanks" %> ` const expected = dedent` <%= render 'user_mailer/greeting' %>

Welcome back! Your subscription to the <%= @subscription.plan&.name || "Custom Plan" %> has been successfully resumed.

Subscription Details:
Plan Name: <%= @subscription.plan&.name || "Custom Plan" %>
Resumption Date: <%= render_date(Time.current, format: '%B %e, %Y') %>
Pickups Left: <%= @subscription.credit_service.available_credits.values.first || 0 %><%= " (#{@subscription.loads * 20}lbs per pickup)" if @subscription.loads > 0 %>
Next Billing Date: <%= render_date(@subscription.current_period_end, format: '%B %e, %Y') %>

Why wait now? Schedule your next pickup today!

<%= render "user_mailer/schedule_now" %> <%= render "user_subscription_mailer/more_info" %> <%= render "user_mailer/questions" %>

Thank you for choosing Company again. We look forward to serving you!

<%= render "user_mailer/thanks" %> ` const result = formatter.format(input) expect(result).toBe(expected) }) test("https://github.com/marcoroth/herb/issues/436#issuecomment-3356738094", () => { expectFormattedToMatch(dedent` <% if cover.present? %>
<%= image_tag attachment_url(cover), size: "460x249", class: "img-fluid figure-img" %>
Cover Image
Dimensions <%= "#{cover.metadata['width']}x#{cover.metadata['height']}" %> — <%= link_to "View original", rails_blob_path(cover), target: "_blank", rel: "noopener" %>
<% end %> `) }) test("adjecent ERB text within elements", () => { const input = dedent`

<%= formatted %> text that needs <%= needs %> <%= to_be_formatted %> without being reset to the start of the line. Text<%= also_with %><%= ERB_tags_next_to_each_other %>and after.

` const expected = dedent`

<%= formatted %> text that needs <%= needs %> <%= to_be_formatted %> without being reset to the start of the line. Text<%= also_with %><%= ERB_tags_next_to_each_other %>and after.

` const result = formatter.format(input) expect(result).toBe(expected) }) test("ERB output with adjecent text within HTML element", () => { const input = dedent`
<%= icon("icon") %>some text some text some text some text some text
` const expected = dedent`
<%= icon("icon") %>some text some text some text some text some text
` const result = formatter.format(input) expect(result).toBe(expected) }) test("ERB output after adjecent text within HTML element", () => { const input = dedent`
some text some text some text some text some text<%= icon("icon") %>
` const expected = dedent`
some text some text some text some text some text<%= icon("icon") %>
` const result = formatter.format(input) expect(result).toBe(expected) }) test("ERB output with adjecent text within HTML element causing line-break", () => { const input = dedent`
<%= icon("icon") %>some text some text some text some text some text some text some text
` const expected = dedent`
<%= icon("icon") %>some text some text some text some text some text some text some text
` const result = formatter.format(input) expect(result).toBe(expected) }) test("ERB output after adjecent text within HTML element causing line-break", () => { const input = dedent`
some text some text some text some text some text somes text<%= icon("icon") %>
` const expected = dedent`
some text some text some text some text some text somes text<%= icon("icon") %>
` const result = formatter.format(input) expect(result).toBe(expected) }) test("ERB output before and after adjecent text within HTML element causing line-break", () => { const input = dedent`
some text some text some text some text some text some text some<%= icon("icon") %>text some text
` const expected = dedent`
some text some text some text some text some text some text some<%= icon("icon") %>text some text
` const result = formatter.format(input) expect(result).toBe(expected) }) test("ERB output with adjecent text within ERB block", () => { const input = dedent` <%= link_to "/" do %><%= icon("icon") %>some text some text<% end %> ` const expected = dedent` <%= link_to "/" do %> <%= icon("icon") %>some text some text <% end %> ` const result = formatter.format(input) expect(result).toBe(expected) }) test("ERB output after adjecent text within ERB block", () => { const input = dedent` <%= link_to "/" do %>some text some text<%= icon("icon") %><% end %> ` const expected = dedent` <%= link_to "/" do %> some text some text<%= icon("icon") %> <% end %> ` const result = formatter.format(input) expect(result).toBe(expected) }) test("ERB output before and after adjecent text within ERB block", () => { const input = dedent` <%= link_to "/" do %>some text<%= icon("icon") %>some text<% end %> ` const expected = dedent` <%= link_to "/" do %> some text<%= icon("icon") %>some text <% end %> ` const result = formatter.format(input) expect(result).toBe(expected) }) test("ERB output with adjecent text within ERB block causing line-break", () => { const input = dedent` <%= link_to "/" do %><%= icon("icon") %>some text some text some text some text some text some text some text<% end %> ` const expected = dedent` <%= link_to "/" do %> <%= icon("icon") %>some text some text some text some text some text some text some text <% end %> ` const result = formatter.format(input) expect(result).toBe(expected) }) test("ERB output after adjecent text within ERB block causing line-break", () => { const input = dedent` <%= link_to "/" do %>some text some text some text some text some text some text some text<%= icon("icon") %><% end %> ` const expected = dedent` <%= link_to "/" do %> some text some text some text some text some text some text some text<%= icon("icon") %> <% end %> ` const result = formatter.format(input) expect(result).toBe(expected) }) test("ERB output before and after adjecent text within ERB block causing line-break", () => { const input = dedent` <%= link_to "/" do %>some text some text some text some text some text some text some<%= icon("icon") %>text some text<% end %> ` const expected = dedent` <%= link_to "/" do %> some text some text some text some text some text some text some<%= icon("icon") %>text some text <% end %> ` const result = formatter.format(input) expect(result).toBe(expected) }) test("ERB output with heredoc (issue 476)", () => { expectFormattedToMatch(dedent` <%= < `) }) test("ERB output with squiggly heredoc", () => { expectFormattedToMatch(dedent` <%= <<~HEREDOC example HEREDOC %> `) }) test("ERB output with hyphen heredoc", () => { expectFormattedToMatch(dedent` <%= <<-HEREDOC example HEREDOC %> `) }) test("ERB output with single-quoted heredoc", () => { expectFormattedToMatch(dedent` <%= <<'HEREDOC' no #{interpolation} HEREDOC %> `) }) test("ERB output with double-quoted heredoc", () => { expectFormattedToMatch(dedent` <%= <<"HEREDOC" with #{interpolation} HEREDOC %> `) }) test("ERB output with heredoc and method chaining", () => { expectFormattedToMatch(dedent` <%= < `) }) test("ERB output with bitshift operator", () => { expectFormattedToMatch(`<%= 1 << 4 %>`) }) test("ERB output with append operator", () => { expectFormattedToMatch(`<%= array << item %>`) }) test("ERB output with heredoc as method argument", () => { expectFormattedToMatch(dedent` <%= foo(< `) }) test("ERB output with heredoc after assignment", () => { expectFormattedToMatch(dedent` <%= x = < `) }) test("ERB output with squiggly heredoc as method argument", () => { expectFormattedToMatch(dedent` <%= foo(<<~HEREDOC) example HEREDOC %> `) }) test("ERB output with dash heredoc as method argument", () => { expectFormattedToMatch(dedent` <%= foo(<<-HEREDOC) example HEREDOC %> `) }) test("ERB output with a heredoc that is not the last argument", () => { expectFormattedToMatch(dedent` <%= foo(<<~HEREDOC, layout: false) example HEREDOC %> `) }) test("ERB output with a chained call on a heredoc", () => { expectFormattedToMatch(dedent` <%= foo(<<~HEREDOC).upcase example HEREDOC %> `) }) test("ERB output with two heredocs", () => { expectFormattedToMatch(dedent` <%= foo(<<~FIRST, <<~SECOND) one FIRST two SECOND %> `) }) test("ERB output with a quoted heredoc identifier", () => { expectFormattedToMatch(dedent` <%= foo(<<~'HEREDOC') example HEREDOC %> `) }) test("ERB statement with a heredoc", () => { expectFormattedToMatch(dedent` <% x = foo(<<~HEREDOC) example HEREDOC %> `) }) test("indents a heredoc closing tag to match its opening tag", () => { expectFormattedToMatch(dedent`
<%= foo(<<~HEREDOC) example HEREDOC %>
`) }) test("keeps a heredoc tag on its own line instead of fusing it into text flow", () => { const input = dedent`

hello <%= foo(<<~HEREDOC) example HEREDOC %>

` const result = formatter.format(input) expect(result).toBe(dedent`

hello <%= foo(<<~HEREDOC) example HEREDOC %>

`) }) test("keeps hyphen-attached inline element together during line wrapping", () => { const input = dedent`
This is a div where we still can assume that whitespace can be inserted-infront or after of this bold you can not insert whitespace. Next senctence.
` const expected = dedent`
This is a div where we still can assume that whitespace can be inserted-infront or after of this bold you can not insert whitespace. Next senctence.
` const result = formatter.format(input) expect(result).toBe(expected) }) })