Skip to content

Commit

Permalink
Merge pull request #2663 from ONSdigital/fix/2100/components-name-not…
Browse files Browse the repository at this point in the history
…-matching-macros-name

Fix/2100/components name not matching macros name
  • Loading branch information
precious-onyenaucheya-ons authored Jun 19, 2023
2 parents 6f7001a + 5258e0e commit 7433d3c
Show file tree
Hide file tree
Showing 71 changed files with 2,558 additions and 2,611 deletions.
4 changes: 2 additions & 2 deletions config/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"templateName": "components/checkboxes/_checkbox-macro.njk",
"macroName": "onsCheckbox"
},
"icons": {
"icon": {
"macroName": "onsIcon"
},
"image": {
"macroName": "onsImage"
},
"lists": {
"list": {
"macroName": "onsList"
},
"related-content/section": {
Expand Down
2 changes: 1 addition & 1 deletion src/components/access-code/example-access-code-error.njk
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ layout: ~
})
%}

{% from "components/lists/_macro.njk" import onsList %}
{% from "components/list/_macro.njk" import onsList %}
{{
onsList({
"element": "ol",
Expand Down
2 changes: 1 addition & 1 deletion src/components/breadcrumbs/_macro.njk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% from "components/icons/_macro.njk" import onsIcon %}
{% from "components/icon/_macro.njk" import onsIcon %}

{% macro onsBreadcrumbs(params) %}
<nav class="ons-breadcrumb{{ ' ' + params.classes if params.classes else '' }}" aria-label="{{ params.ariaLabel | default("Breadcrumbs") }}" {% if params.id %} id="{{ params.id }}"{% endif %}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/breadcrumbs/_macro.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('macro: breadcrumbs', () => {

it('has a "chevron" icon for each breadcrumb item', () => {
const faker = templateFaker();
const iconsSpy = faker.spy('icons');
const iconsSpy = faker.spy('icon');

faker.renderComponent('breadcrumbs', EXAMPLE_BREADCRUMBS_MINIMAL);

Expand Down
2 changes: 1 addition & 1 deletion src/components/button/_macro.njk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% from "components/icons/_macro.njk" import onsIcon %}
{% from "components/icon/_macro.njk" import onsIcon %}

{% macro onsButton(params) %}

Expand Down
12 changes: 6 additions & 6 deletions src/components/button/_macro.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('macro: button', () => {

it('has `download` icon when `variants` contains "download"', () => {
const faker = templateFaker();
const iconsSpy = faker.spy('icons');
const iconsSpy = faker.spy('icon');

faker.renderComponent('button', {
url: 'http://example.com',
Expand All @@ -84,7 +84,7 @@ describe('macro: button', () => {

it('has `print` icon when `variants` contains "print"', () => {
const faker = templateFaker();
const iconsSpy = faker.spy('icons');
const iconsSpy = faker.spy('icon');

faker.renderComponent('button', {
url: 'http://example.com',
Expand All @@ -108,7 +108,7 @@ describe('macro: button', () => {

it('has `loader` icon when `variants` contains "loader"', () => {
const faker = templateFaker();
const iconsSpy = faker.spy('icons');
const iconsSpy = faker.spy('icon');

faker.renderComponent('button', {
variants: 'loader',
Expand All @@ -119,7 +119,7 @@ describe('macro: button', () => {

it('has `chevron` icon when `variants` contains "mobile"', () => {
const faker = templateFaker();
const iconsSpy = faker.spy('icons');
const iconsSpy = faker.spy('icon');

faker.renderComponent('button', {
variants: 'mobile',
Expand Down Expand Up @@ -346,7 +346,7 @@ describe('macro: button', () => {

it('has `arrow-next` icon by default', () => {
const faker = templateFaker();
const iconsSpy = faker.spy('icons');
const iconsSpy = faker.spy('icon');

faker.renderComponent('button', {
url: 'http://example.com',
Expand All @@ -369,7 +369,7 @@ describe('macro: button', () => {

it('has `external-link` icon when `newWindow` is `true`', () => {
const faker = templateFaker();
const iconsSpy = faker.spy('icons');
const iconsSpy = faker.spy('icon');

faker.renderComponent('button', {
url: 'http://example.com',
Expand Down
2 changes: 1 addition & 1 deletion src/components/card/_macro.njk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{%- macro onsCard(params) -%}

{% from "components/lists/_macro.njk" import onsList %}
{% from "components/list/_macro.njk" import onsList %}

{% set titleSize = params.titleSize | default('2') %}

Expand Down
2 changes: 1 addition & 1 deletion src/components/card/_macro.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('macro: card', () => {

it('renders the provided `itemsList` using the `list` component', () => {
const faker = templateFaker();
const listsSpy = faker.spy('lists');
const listsSpy = faker.spy('list');

faker.renderComponent('card', {
...EXAMPLE_CARD_WITHOUT_IMAGE,
Expand Down
2 changes: 1 addition & 1 deletion src/components/collapsible/_macro.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe('macro: collapsible', () => {

it('has `chevron` icon', () => {
const faker = templateFaker();
const iconsSpy = faker.spy('icons');
const iconsSpy = faker.spy('icon');
faker.renderComponent('collapsible', EXAMPLE_COLLAPSIBLE_BASIC);

expect(iconsSpy.occurrences[0].iconType).toBe('chevron');
Expand Down
4 changes: 2 additions & 2 deletions src/components/content-pagination/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<a href="{{ contentPaginationItem.url }}" class="ons-content-pagination__link" rel="{{ contentPaginationItem.rel }}">
<span class="ons-content-pagination__link-title">
{% if contentPaginationItem.rel == 'prev' %}
{% from "components/icons/_macro.njk" import onsIcon %}
{% from "components/icon/_macro.njk" import onsIcon %}
{{
onsIcon({
"iconType": 'arrow-previous',
"iconSize": 'm'
})
}}
{% else %}
{% from "components/icons/_macro.njk" import onsIcon %}
{% from "components/icon/_macro.njk" import onsIcon %}
{{
onsIcon({
"iconType": 'arrow-next',
Expand Down
4 changes: 2 additions & 2 deletions src/components/content-pagination/_macro.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('macro: content-pagination', () => {

it('renders the `arrow-previous` icon for the previous link entry', () => {
const faker = templateFaker();
const iconsSpy = faker.spy('icons');
const iconsSpy = faker.spy('icon');

faker.renderComponent('content-pagination', EXAMPLE_CONTENT_PAGINATION_PREV_ONLY);

Expand All @@ -91,7 +91,7 @@ describe('macro: content-pagination', () => {

it('renders the `arrow-next` icon for the next link entry', () => {
const faker = templateFaker();
const iconsSpy = faker.spy('icons');
const iconsSpy = faker.spy('icon');

faker.renderComponent('content-pagination', EXAMPLE_CONTENT_PAGINATION_NEXT_ONLY);

Expand Down
2 changes: 1 addition & 1 deletion src/components/details/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{% set titleTag = params.titleTag | default("h2") %}
<{{ titleTag }} class="ons-details__title">{{ params.title }}</{{ titleTag }}>
<span class="ons-details__icon">
{% from "components/icons/_macro.njk" import onsIcon %}
{% from "components/icon/_macro.njk" import onsIcon %}
{{
onsIcon({
"iconType": "chevron"
Expand Down
2 changes: 1 addition & 1 deletion src/components/details/_macro.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe('macro: details', () => {

it('has `chevron` icon', () => {
const faker = templateFaker();
const iconsSpy = faker.spy('icons');
const iconsSpy = faker.spy('icon');
faker.renderComponent('details', EXAMPLE_DETAILS_BASIC);

expect(iconsSpy.occurrences[0].iconType).toBe('chevron');
Expand Down
4 changes: 2 additions & 2 deletions src/components/footer/_macro.njk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% macro onsFooter(params) %}

{% from "components/lists/_macro.njk" import onsList %}
{% from "components/icons/_macro.njk" import onsIcon %}
{% from "components/list/_macro.njk" import onsList %}
{% from "components/icon/_macro.njk" import onsIcon %}

{% if params.lang %}
{% set lang = params.lang %}
Expand Down
14 changes: 7 additions & 7 deletions src/components/footer/_macro.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe('macro: footer', () => {

it('renders OGL icon', () => {
const faker = templateFaker();
const iconsSpy = faker.spy('icons');
const iconsSpy = faker.spy('icon');

faker.renderComponent('footer', params);

Expand Down Expand Up @@ -284,7 +284,7 @@ describe('macro: footer', () => {

it('renders expected lists using list component', () => {
const faker = templateFaker();
const listsSpy = faker.spy('lists');
const listsSpy = faker.spy('list');

faker.renderComponent('footer', params);

Expand Down Expand Up @@ -312,7 +312,7 @@ describe('macro: footer', () => {

it('renders expected lists using list component', () => {
const faker = templateFaker();
const listsSpy = faker.spy('lists');
const listsSpy = faker.spy('list');

faker.renderComponent('footer', params);

Expand Down Expand Up @@ -340,7 +340,7 @@ describe('macro: footer', () => {

it('renders expected lists using list component', () => {
const faker = templateFaker();
const listsSpy = faker.spy('lists');
const listsSpy = faker.spy('list');

faker.renderComponent('footer', params);

Expand Down Expand Up @@ -379,7 +379,7 @@ describe('macro: footer', () => {
};
it('renders the expected icon', () => {
const faker = templateFaker();
const iconsSpy = faker.spy('icons');
const iconsSpy = faker.spy('icon');

faker.renderComponent('footer', params);

Expand All @@ -403,7 +403,7 @@ describe('macro: footer', () => {
};
it('renders the expected icon', () => {
const faker = templateFaker();
const iconsSpy = faker.spy('icons');
const iconsSpy = faker.spy('icon');

faker.renderComponent('footer', params);

Expand Down Expand Up @@ -544,7 +544,7 @@ describe('macro: footer', () => {

it('renders crest icon when `crest` parameter is provided', () => {
const faker = templateFaker();
const iconsSpy = faker.spy('icons');
const iconsSpy = faker.spy('icon');

faker.renderComponent('footer', params);

Expand Down
2 changes: 1 addition & 1 deletion src/components/header/_macro.njk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% macro onsHeader(params) %}
{% from "components/button/_macro.njk" import onsButton %}
{% from "components/icons/_macro.njk" import onsIcon %}
{% from "components/icon/_macro.njk" import onsIcon %}
{% from "components/navigation/_macro.njk" import onsNavigation %}
{% from "components/browser-banner/_macro.njk" import onsBrowserBanner %}

Expand Down
10 changes: 5 additions & 5 deletions src/components/header/_macro.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ describe('macro: header', () => {

it('has the default masthead logo icon', () => {
const faker = templateFaker();
const iconsSpy = faker.spy('icons');
const iconsSpy = faker.spy('icon');

faker.renderComponent('header', EXAMPLE_HEADER_BASIC);

Expand All @@ -223,7 +223,7 @@ describe('macro: header', () => {

it('has the default masthead mobile logo icon', () => {
const faker = templateFaker();
const iconsSpy = faker.spy('icons');
const iconsSpy = faker.spy('icon');

faker.renderComponent('header', EXAMPLE_HEADER_BASIC);

Expand All @@ -232,7 +232,7 @@ describe('macro: header', () => {

it('has the default masthead logo icon alt text', () => {
const faker = templateFaker();
const iconsSpy = faker.spy('icons');
const iconsSpy = faker.spy('icon');

faker.renderComponent('header', EXAMPLE_HEADER_BASIC);

Expand All @@ -241,7 +241,7 @@ describe('macro: header', () => {

it('has the default masthead mobile logo icon alt text', () => {
const faker = templateFaker();
const iconsSpy = faker.spy('icons');
const iconsSpy = faker.spy('icon');

faker.renderComponent('header', EXAMPLE_HEADER_BASIC);

Expand Down Expand Up @@ -549,7 +549,7 @@ describe('macro: header', () => {

it('has the correct list item icon', () => {
const faker = templateFaker();
const iconsSpy = faker.spy('icons');
const iconsSpy = faker.spy('icon');

faker.renderComponent('header', {
...EXAMPLE_HEADER_BASIC,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as cheerio from 'cheerio';
import axe from '../../tests/helpers/axe';
import { renderComponent } from '../../tests/helpers/rendering';

describe('macro: icons', () => {
describe('macro: icon', () => {
describe.each([
'arrow-forward',
'arrow-next',
Expand Down Expand Up @@ -35,21 +35,21 @@ describe('macro: icons', () => {
'circle-lined',
])('icon type: %s', iconType => {
it('passes jest-axe checks', async () => {
const $ = cheerio.load(renderComponent('icons', { iconType }));
const $ = cheerio.load(renderComponent('icon', { iconType }));

const results = await axe($.html());
expect(results).toHaveNoViolations();
});

it('has an svg element', () => {
const $ = cheerio.load(renderComponent('icons', { iconType }));
const $ = cheerio.load(renderComponent('icon', { iconType }));

expect($('svg').length).toBe(1);
});

it('has additionally provided style classes', () => {
const $ = cheerio.load(
renderComponent('icons', {
renderComponent('icon', {
iconType,
classes: 'extra-class another-extra-class',
}),
Expand Down Expand Up @@ -80,7 +80,7 @@ describe('macro: icons', () => {
])('icon type: %s', iconType => {
it('has style variation class for provided icon size', () => {
const $ = cheerio.load(
renderComponent('icons', {
renderComponent('icon', {
iconType,
iconSize: 'xxl',
}),
Expand All @@ -99,7 +99,7 @@ describe('macro: icons', () => {
['ogl', 'Open Government License logo'],
])('icon type: %s', (iconType, expectedAltText) => {
it(`has default alt text '${expectedAltText}'`, () => {
const $ = cheerio.load(renderComponent('icons', { iconType }));
const $ = cheerio.load(renderComponent('icon', { iconType }));

expect(
$('title')
Expand All @@ -110,7 +110,7 @@ describe('macro: icons', () => {

it('has provided alt text', () => {
const $ = cheerio.load(
renderComponent('icons', {
renderComponent('icon', {
iconType,
altText: 'Example alt text',
}),
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
{%- if item.prefix -%}
{{- item.prefix -}}.
{% elif params.iconPosition == 'before' %}
{% from "components/icons/_macro.njk" import onsIcon %}
{% from "components/icon/_macro.njk" import onsIcon %}
{{
onsIcon({
"iconType": itemIconType,
Expand Down Expand Up @@ -75,7 +75,7 @@
{%- elif (item.index and listEl != 'ol') or (item.index and listEl == 'ol' and 'bare' in variants) -%}
{{- loop.index -}}
{% elif params.iconPosition == 'after' %}
{% from "components/icons/_macro.njk" import onsIcon %}
{% from "components/icon/_macro.njk" import onsIcon %}
{{
onsIcon({
"iconType": itemIconType,
Expand Down
Loading

0 comments on commit 7433d3c

Please sign in to comment.