Skip to content

Commit

Permalink
added tests and updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
precious-onyenaucheya-ons committed Jul 21, 2023
1 parent 28ef690 commit c7c31c5
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 17 deletions.
35 changes: 18 additions & 17 deletions src/components/list/_macro-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@

## ListItem

| Name | Type | Required | Description |
| ------------------- | ------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| listClasses | string | false | Classes to be added to the list item |
| text | string | true | The text for the list item |
| title | string | false | The text for the list item - _used for Craft CMS_ |
| navigationTitle | string | false | The text for the list item - _used for Craft CMS_ |
| url | string | false | Wraps the list item text in a link with the set `href` |
| classes | string | false | Classes to be added to the list item link |
| variants | string | false | Use the value “inPageLink” for list items set with `url` when using the [error summary panel](/patterns/correct-errors/#error-summary) |
| target | string | false | Sets the HTML `target` attribute for the list item when `url` is set |
| screenreaderMessage | string | false | Sets a message to be read out by screen readers when `target` is set to “\_blank” to open a new tab. Defaults to “opens in a new tab”. |
| external | boolean | false | Sets the list item as an [external link](#external-links) |
| prefix | string | false | Will prefix the list item with the parameter’s value |
| suffix | string | false | Will suffix the list item with the parameter’s value |
| current | boolean | false | Set to “true” to indicate the current page in a list of content navigational links |
| iconType | string | false | Adds an icon to the individual list item when set to the name of one of the [available icons](/foundations/icons#a-to-z) |
| attributes | object | false | HTML attributes (for example, data attributes) to add to list item link |
| Name | Type | Required | Description |
| ------------------- | ----------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| listClasses | string | false | Classes to be added to the list item |
| text | string | true | The text for the list item |
| title | string | false | The text for the list item - _used for Craft CMS_ |
| navigationTitle | string | false | The text for the list item - _used for Craft CMS_ |
| url | string | false | Wraps the list item text in a link with the set `href` |
| classes | string | false | Classes to be added to the list item link |
| variants | string | false | Use the value “inPageLink” for list items set with `url` when using the [error summary panel](/patterns/correct-errors/#error-summary) |
| target | string | false | Sets the HTML `target` attribute for the list item when `url` is set |
| screenreaderMessage | string | false | Sets a message to be read out by screen readers when `target` is set to “\_blank” to open a new tab. Defaults to “opens in a new tab”. |
| external | boolean | false | Sets the list item as an [external link](#external-links) |
| prefix | string | false | Will prefix the list item with the parameter’s value |
| suffix | string | false | Will suffix the list item with the parameter’s value |
| current | boolean | false | Set to “true” to indicate the current page in a list of content navigational links |
| iconType | string | false | Adds an icon to the individual list item when set to the name of one of the [available icons](/foundations/icons#a-to-z) |
| attributes | object | false | HTML attributes (for example, data attributes) to add to list item link |
| itemsList | `Array<ListItem>` | false | Settings for each [list item](#listitem) |
35 changes: 35 additions & 0 deletions src/components/list/_macro.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,4 +622,39 @@ describe('macro: list', () => {
expect($('#first + .ons-list__suffix').length).toBe(1);
});
});

describe('nested list element', () => {
it('has provided variant style class when one variant is provided', () => {
const $ = cheerio.load(
renderComponent('list', {
...EXAMPLE_NESTED_LIST_TEXT_ITEMS,
variants: 'dashed',
}),
);

expect($('.ons-list--dashed').length).toBe(2);
});

it('has provided variant style classes when multiple variants are provided', () => {
const $ = cheerio.load(
renderComponent('list', {
...EXAMPLE_NESTED_LIST_TEXT_ITEMS,
variants: ['dashed', 'inline'],
}),
);

expect($('.ons-list').hasClass('ons-list--dashed')).toBe(true);
expect($('.ons-list').hasClass('ons-list--inline')).toBe(true);
});

it('has the expected quantity of <li> elements when a <ol> element is specified', () => {
const $ = cheerio.load(
renderComponent('list', {
...EXAMPLE_NESTED_LIST_TEXT_ITEMS,
}),
);

expect($('.ons-list li').length).toBe(5);
});
});
});

0 comments on commit c7c31c5

Please sign in to comment.