Skip to content

Commit

Permalink
Merge branch 'major-release' into enhancement/69/change-utility-class…
Browse files Browse the repository at this point in the history
…es-to-8px-grid
  • Loading branch information
precious-onyenaucheya-ons authored Sep 30, 2024
2 parents 6640fc5 + 6c9be98 commit c1f94ce
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 173 deletions.
12 changes: 6 additions & 6 deletions src/tests/helpers/cheerio.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import * as cheerio from 'cheerio';
import * as helper from '../../tests/helpers/cheerio';

const EXAMPLE_HTML = `
<div>
<div id="a">First</div>
<div id="b" class="second">Second</div>
<div id="c" class="third">Third</div>
</div>
`;
<div>
<div id="a">First</div>
<div id="b" class="second">Second</div>
<div id="c" class="third">Third</div>
</div>
`;

describe('mapAll(cheerioNodes, selector)', () => {
it('gets mapped values`', () => {
Expand Down
118 changes: 59 additions & 59 deletions src/tests/helpers/puppeteer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,28 @@ describe('PuppeteerEndpointFaker', () => {
});

const TEST_HTML_REQUEST_DATA_FROM_ENDPOINT = `
<div id="output"></div>
<script>
fetch('/test/fake/api/json/abc')
.then(async (response) => {
const data = await response.json();
const el = document.getElementById('output');
el.innerHTML = response.status + ':' + data.value;
el.classList.add('test');
});
</script>
`;
<div id="output"></div>
<script>
fetch('/test/fake/api/json/abc')
.then(async (response) => {
const data = await response.json();
const el = document.getElementById('output');
el.innerHTML = response.status + ':' + data.value;
el.classList.add('test');
});
</script>
`;

describe('get requestHistory()', () => {
it('has faked requests in history', async () => {
await setTestPage(
'/test',
`
<script>
fetch('/test/fake/api/text?abc=123');
fetch('/test/fake/api/json?abc=456');
</script>
`,
<script>
fetch('/test/fake/api/text?abc=123');
fetch('/test/fake/api/json?abc=456');
</script>
`,
);

const paths = apiFaker.requestHistory.map((entry) => entry.path);
Expand All @@ -78,13 +78,13 @@ describe('PuppeteerEndpointFaker', () => {
await setTestPage(
'/test',
`
<script>
fetch('/test/fake/api/text?abc=123');
fetch('/test/fake/api/text?abc=789');
fetch('/test/fake/api/other');
fetch('/test/fake/api/json?abc=456');
</script>
`,
<script>
fetch('/test/fake/api/text?abc=123');
fetch('/test/fake/api/text?abc=789');
fetch('/test/fake/api/other');
fetch('/test/fake/api/json?abc=456');
</script>
`,
);

const paths = apiFaker.requestHistory.map((entry) => entry.path);
Expand All @@ -95,12 +95,12 @@ describe('PuppeteerEndpointFaker', () => {
await setTestPage(
'/test',
`
<script>
fetch('/test/fake/api/text?abc=123');
fetch('/test');
fetch('/test/fake/api/json?abc=456');
</script>
`,
<script>
fetch('/test/fake/api/text?abc=123');
fetch('/test');
fetch('/test/fake/api/json?abc=456');
</script>
`,
);

const paths = apiFaker.requestHistory.map((entry) => entry.path);
Expand All @@ -111,10 +111,10 @@ describe('PuppeteerEndpointFaker', () => {
await setTestPage(
'/test',
`
<script>
fetch('/test/fake/api/text?abc=123');
</script>
`,
<script>
fetch('/test/fake/api/text?abc=123');
</script>
`,
);

const entry = apiFaker.requestHistory.find((entry) => entry.path === '/text?abc=123');
Expand All @@ -125,14 +125,14 @@ describe('PuppeteerEndpointFaker', () => {
await setTestPage(
'/test',
`
<script>
fetch('/test/fake/api/text?abc=123', {
headers: {
'foo': '123',
}
});
</script>
`,
<script>
fetch('/test/fake/api/text?abc=123', {
headers: {
'foo': '123',
}
});
</script>
`,
);

const entry = apiFaker.requestHistory.find((entry) => entry.path === '/text?abc=123');
Expand All @@ -145,13 +145,13 @@ describe('PuppeteerEndpointFaker', () => {
await setTestPage(
'/test',
`
<script>
fetch('/test/fake/api/text?abc=123');
fetch('/test/fake/api/text?abc=789');
fetch('/test/fake/api/other');
fetch('/test/fake/api/json?abc=456');
</script>
`,
<script>
fetch('/test/fake/api/text?abc=123');
fetch('/test/fake/api/text?abc=789');
fetch('/test/fake/api/other');
fetch('/test/fake/api/json?abc=456');
</script>
`,
);

expect(apiFaker.requestedPaths).toEqual(['/text?abc=123', '/text?abc=789', '/other', '/json?abc=456']);
Expand All @@ -171,11 +171,11 @@ describe('PuppeteerEndpointFaker', () => {
await setTestPage(
'/test',
`
<script>
fetch('/test/fake/api/text?abc=123');
fetch('/test/fake/api/json?abc=456');
</script>
`,
<script>
fetch('/test/fake/api/text?abc=123');
fetch('/test/fake/api/json?abc=456');
</script>
`,
);
await apiFaker.reset();

Expand Down Expand Up @@ -299,12 +299,12 @@ describe('PuppeteerEndpointFaker', () => {
await setTestPage(
'/test',
`
<script>
fetch('/test/fake/api/text?abc=123');
fetch('/test/fake/api/json?abc=456');
fetch('/test/fake/api/json?abc=456');
</script>
`,
<script>
fetch('/test/fake/api/text?abc=123');
fetch('/test/fake/api/json?abc=456');
fetch('/test/fake/api/json?abc=456');
</script>
`,
);

expect(apiFaker.getRequestCount('/text?abc=123')).toBe(1);
Expand Down
30 changes: 15 additions & 15 deletions src/tests/helpers/rendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);

Expand Down
Loading

0 comments on commit c1f94ce

Please sign in to comment.