diff --git a/src/components/button/_macro.njk b/src/components/button/_macro.njk index ba06e0abfc..0b48a1f0ae 100644 --- a/src/components/button/_macro.njk +++ b/src/components/button/_macro.njk @@ -72,7 +72,7 @@ {% else %} type="{{ buttonType }}" {% endif %} - class="ons-btn{{ ' ' + params.classes if params.classes else '' }}{% if params.variants and params.variants is not string %}{% for variant in params.variants %}{{ ' ' }}ons-btn--{{ variant }}{% endfor %}{% else %}{{ ' ' }}ons-btn--{{ params.variants }}{% endif %}{{ ' ons-btn--link ons-js-submit-btn' if params.url }}{{ variantClasses }}" + class="ons-btn{{ ' ' + params.classes if params.classes else '' }}{% if params.variants and params.variants is not string %}{% for variant in params.variants %}{{ ' ' }}ons-btn--{{ variant }}{% endfor %}{% elif params.variants %}{{ ' ' }}ons-btn--{{ params.variants }}{% endif %}{{ ' ons-btn--link ons-js-submit-btn' if params.url }}{{ variantClasses }}" {% if params.id %}id="{{ params.id }}"{% endif %} {% if params.value and tag != "a" %}value="{{ params.value }}"{% endif %} {% if params.name and tag != "a" %}name="{{ params.name }}"{% endif %} diff --git a/src/components/text-indent/example-text-indent.njk b/src/components/text-indent/example-text-indent.njk index 23ce6cfa46..fff746b2b7 100644 --- a/src/components/text-indent/example-text-indent.njk +++ b/src/components/text-indent/example-text-indent.njk @@ -1,6 +1,6 @@ {% from "components/text-indent/_macro.njk" import onsTextIndent %} {{- onsTextIndent({ - text: '

Telephone: 0800 141 2021
Monday to Friday, 8 am to 7pm
Saturday, 8am to 4pm

' + "text": '

Telephone: 0800 141 2021
Monday to Friday, 8 am to 7pm
Saturday, 8am to 4pm

' }) -}} diff --git a/src/tests/helpers/cheerio.spec.js b/src/tests/helpers/cheerio.spec.js index f0d591fdb9..e22de1942b 100644 --- a/src/tests/helpers/cheerio.spec.js +++ b/src/tests/helpers/cheerio.spec.js @@ -3,12 +3,12 @@ import * as cheerio from 'cheerio'; import * as helper from '../../tests/helpers/cheerio'; const EXAMPLE_HTML = ` -
-
First
-
Second
-
Third
-
-`; +
+
First
+
Second
+
Third
+
+ `; describe('mapAll(cheerioNodes, selector)', () => { it('gets mapped values`', () => { diff --git a/src/tests/helpers/puppeteer.spec.js b/src/tests/helpers/puppeteer.spec.js index fa1693a673..e7ab51cd9a 100644 --- a/src/tests/helpers/puppeteer.spec.js +++ b/src/tests/helpers/puppeteer.spec.js @@ -46,28 +46,28 @@ describe('PuppeteerEndpointFaker', () => { }); const TEST_HTML_REQUEST_DATA_FROM_ENDPOINT = ` -
- - `; +
+ + `; describe('get requestHistory()', () => { it('has faked requests in history', async () => { await setTestPage( '/test', ` - - `, + + `, ); const paths = apiFaker.requestHistory.map((entry) => entry.path); @@ -78,13 +78,13 @@ describe('PuppeteerEndpointFaker', () => { await setTestPage( '/test', ` - - `, + + `, ); const paths = apiFaker.requestHistory.map((entry) => entry.path); @@ -95,12 +95,12 @@ describe('PuppeteerEndpointFaker', () => { await setTestPage( '/test', ` - - `, + + `, ); const paths = apiFaker.requestHistory.map((entry) => entry.path); @@ -111,10 +111,10 @@ describe('PuppeteerEndpointFaker', () => { await setTestPage( '/test', ` - - `, + + `, ); const entry = apiFaker.requestHistory.find((entry) => entry.path === '/text?abc=123'); @@ -125,14 +125,14 @@ describe('PuppeteerEndpointFaker', () => { await setTestPage( '/test', ` - - `, + + `, ); const entry = apiFaker.requestHistory.find((entry) => entry.path === '/text?abc=123'); @@ -145,13 +145,13 @@ describe('PuppeteerEndpointFaker', () => { await setTestPage( '/test', ` - - `, + + `, ); expect(apiFaker.requestedPaths).toEqual(['/text?abc=123', '/text?abc=789', '/other', '/json?abc=456']); @@ -171,11 +171,11 @@ describe('PuppeteerEndpointFaker', () => { await setTestPage( '/test', ` - - `, + + `, ); await apiFaker.reset(); @@ -299,12 +299,12 @@ describe('PuppeteerEndpointFaker', () => { await setTestPage( '/test', ` - - `, + + `, ); expect(apiFaker.getRequestCount('/text?abc=123')).toBe(1); diff --git a/src/tests/helpers/rendering.js b/src/tests/helpers/rendering.js index aa239923d4..4bacb9e408 100644 --- a/src/tests/helpers/rendering.js +++ b/src/tests/helpers/rendering.js @@ -44,20 +44,20 @@ export function renderComponent(componentName, params = {}, children = null, fak if (!!children) { return renderTemplate( ` - {% from "${info.templateName}" import ${info.macroName} %} - {%- call ${info.macroName}(${JSON.stringify(params, null, 2)}) -%} - ${Array.isArray(children) ? children.join('') : children} - {%- endcall -%} - `, + {% from "${info.templateName}" import ${info.macroName} %} + {%- call ${info.macroName}(${JSON.stringify(params, null, 2)}) -%} + ${Array.isArray(children) ? children.join('') : children} + {%- endcall -%} + `, fakerContext, isDesignSystemExample, ); } else { return renderTemplate( ` - {% from "${info.templateName}" import ${info.macroName} %} - {{- ${info.macroName}(${JSON.stringify(params, null, 2)}) -}} - `, + {% from "${info.templateName}" import ${info.macroName} %} + {{- ${info.macroName}(${JSON.stringify(params, null, 2)}) -}} + `, fakerContext, isDesignSystemExample, ); @@ -66,9 +66,9 @@ export function renderComponent(componentName, params = {}, children = null, fak export function renderBaseTemplate(config) { const compositedTemplate = ` - {% extends 'layout/_template.njk' %} - ${config} - `; + {% extends 'layout/_template.njk' %} + ${config} + `; return renderTemplate(compositedTemplate); } @@ -172,10 +172,10 @@ export async function setTestPage(path, template, blockName = 'body') { verifyConsoleSubscription(page); const compositedTemplate = ` - {% block ${blockName} %} - ${template} - {% endblock %} - `; + {% block ${blockName} %} + ${template} + {% endblock %} + `; const html = renderBaseTemplate(compositedTemplate); diff --git a/src/tests/helpers/rendering.spec.js b/src/tests/helpers/rendering.spec.js index a5b5d3e75a..2412f420ea 100644 --- a/src/tests/helpers/rendering.spec.js +++ b/src/tests/helpers/rendering.spec.js @@ -37,24 +37,24 @@ describe('getMacroName(componentName)', () => { describe('renderTemplate(template)', () => { it('renders the provided template', () => { const result = helper.renderTemplate(` - {%- for value in [1, 2, 3] -%} - {{ value }} - {%- endfor -%} - `); + {%- for value in [1, 2, 3] -%} + {{ value }} + {%- endfor -%} + `); expect(result).toBe(`123`); }); it('imports a component macro when rendering the provided template', () => { const result = helper.renderTemplate(` - {% from "components/button/_macro.njk" import onsButton %} + {% from "components/button/_macro.njk" import onsButton %} - {{ - onsButton({ - text: 'Click me!' - }) - }} - `); + {{ + onsButton({ + text: 'Click me!' + }) + }} + `); expect(result).toContain('Click me!'); }); @@ -89,21 +89,21 @@ describe('templateFaker()', () => { faker.setFake( 'button', ` - {% macro onsButton(params) %} - FAKE BUTTON - {% endmacro %} - `, + {% macro onsButton(params) %} + FAKE BUTTON + {% endmacro %} + `, ); const result = faker.renderTemplate(` - {% from "components/button/_macro.njk" import onsButton %} + {% from "components/button/_macro.njk" import onsButton %} - {{ - onsButton({ - text: 'Click me!' - }) - }} - `); + {{ + onsButton({ + text: 'Click me!' + }) + }} + `); expect(result.trim()).toBe('FAKE BUTTON'); }); @@ -113,10 +113,10 @@ describe('templateFaker()', () => { faker.setFake( 'button', ` - {% macro onsButton(params) %} - FAKE BUTTON - {% endmacro %} - `, + {% macro onsButton(params) %} + FAKE BUTTON + {% endmacro %} + `, ); const result = faker.renderComponent('button', { @@ -131,18 +131,19 @@ describe('templateFaker()', () => { faker.setFake( 'checkboxes/checkbox', ` - {% macro onsCheckbox(params) %} - FAKE CHECKBOX - {% endmacro %} - `, + {% macro onsCheckbox(params) %} + FAKE CHECKBOX + {% endmacro %} + `, ); const result = faker.renderTemplate(` - {% from "components/checkboxes/_checkbox-macro.njk" import onsCheckbox %} - {{ - onsCheckbox({ id: 'test' }) - }} - `); + {% from "components/checkboxes/_checkbox-macro.njk" import onsCheckbox %} + + {{ + onsCheckbox({ id: 'test' }) + }} + `); expect(result.trim()).toBe('FAKE CHECKBOX'); }); @@ -155,14 +156,14 @@ describe('templateFaker()', () => { /*const buttonSpy =*/ faker.spy('button', options); const result = faker.renderTemplate(` - {% from "components/button/_macro.njk" import onsButton %} + {% from "components/button/_macro.njk" import onsButton %} - {{ - onsButton({ - text: 'Test Button A' - }) - }} - `); + {{ + onsButton({ + text: 'Test Button A' + }) + }} + `); expect(result).toContain('Test Button A'); }); @@ -172,14 +173,14 @@ describe('templateFaker()', () => { /*const buttonSpy =*/ faker.spy('button', { suppressOutput: true }); const result = faker.renderTemplate(` - {% from "components/button/_macro.njk" import onsButton %} + {% from "components/button/_macro.njk" import onsButton %} - {{ - onsButton({ - text: 'Test Button A' - }) - }} - `); + {{ + onsButton({ + text: 'Test Button A' + }) + }} + `); expect(result).not.toContain('Test Button A'); }); @@ -192,19 +193,19 @@ describe('templateFaker()', () => { const buttonSpy = faker.spy('button', options); faker.renderTemplate(` - {% from "components/button/_macro.njk" import onsButton %} - - {{ - onsButton({ - text: 'Test Button A' - }) - }} - {{ - onsButton({ - text: 'Test Button B' - }) - }} - `); + {% from "components/button/_macro.njk" import onsButton %} + + {{ + onsButton({ + text: 'Test Button A' + }) + }} + {{ + onsButton({ + text: 'Test Button B' + }) + }} + `); expect(buttonSpy.occurrences[0].text).toBe('Test Button A'); expect(buttonSpy.occurrences[1].text).toBe('Test Button B'); @@ -219,37 +220,37 @@ describe('templateFaker()', () => { const panelSpy = faker.spy('panel'); faker.renderTemplate(` - {% from "components/button/_macro.njk" import onsButton %} - {% from "components/panel/_macro.njk" import onsPanel %} - - {% set foo %} - {{ - onsButton({ - text: 'Test Button A' - }) - }} - {% endset %} - - {{ - onsButton({ - text: 'Test Button B' - }) - }} - - {{ - onsPanel({ - body: 'Test Panel' - }) - }} - - {% set bar %} - {{ - onsButton({ - text: 'Test Button C' - }) - }} - {% endset %} - `); + {% from "components/button/_macro.njk" import onsButton %} + {% from "components/panel/_macro.njk" import onsPanel %} + + {% set foo %} + {{ + onsButton({ + text: 'Test Button A' + }) + }} + {% endset %} + + {{ + onsButton({ + text: 'Test Button B' + }) + }} + + {{ + onsPanel({ + body: 'Test Panel' + }) + }} + + {% set bar %} + {{ + onsButton({ + text: 'Test Button C' + }) + }} + {% endset %} + `); expect(buttonSpy.occurrences[0]).toBeUndefined(); expect(buttonSpy.occurrences[1].text).toBe('Test Button B');