@iamproperty/components 7.8.2--beta1 → 7.8.2--beta3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/css/components/actionbar.component.css +1 -1
- package/assets/css/components/actionbar.component.css.map +1 -1
- package/assets/css/components/applied-filters.css +1 -1
- package/assets/css/components/applied-filters.css.map +1 -1
- package/assets/css/components/calendar.component.css +1 -1
- package/assets/css/components/calendar.component.css.map +1 -1
- package/assets/css/components/modal.component.css +1 -1
- package/assets/css/components/modal.component.css.map +1 -1
- package/assets/css/components/tabs.component.css +1 -1
- package/assets/css/components/tabs.component.css.map +1 -1
- package/assets/css/components/video-card.component.css +1 -1
- package/assets/css/components/video-card.component.css.map +1 -1
- package/assets/css/components/video-modal.component.css +1 -1
- package/assets/css/components/video-modal.component.css.map +1 -1
- package/assets/css/core.min.css +1 -1
- package/assets/css/core.min.css.map +1 -1
- package/assets/css/elements/badge-tag.css +1 -1
- package/assets/css/elements/badge-tag.css.map +1 -1
- package/assets/css/style.min.css +1 -1
- package/assets/css/style.min.css.map +1 -1
- package/assets/js/components/accordion/accordion.component.min.js +1 -1
- package/assets/js/components/actionbar/actionbar.component.min.js +2 -2
- package/assets/js/components/address-lookup/address-lookup.component.min.js +3 -3
- package/assets/js/components/address-lookup/address-lookup.component.min.js.map +1 -1
- package/assets/js/components/advanced-select/advanced-select.component.min.js +3 -3
- package/assets/js/components/advanced-select/advanced-select.component.min.js.map +1 -1
- package/assets/js/components/applied-filters/applied-filters.component.min.js +2 -2
- package/assets/js/components/banner/banner.component.min.js +1 -1
- package/assets/js/components/barchart/barchart.component.min.js +1 -1
- package/assets/js/components/bento-grid/bento-grid.component.min.js +1 -1
- package/assets/js/components/bone/bone.component.min.js +1 -1
- package/assets/js/components/button/button.component.min.js +1 -1
- package/assets/js/components/calendar/calendar.component.min.js +2 -2
- package/assets/js/components/card/card.component.min.js +6 -6
- package/assets/js/components/card/card.component.min.js.map +1 -1
- package/assets/js/components/carousel/carousel.component.min.js +1 -1
- package/assets/js/components/collapsible-side/collapsible-side.component.min.js +1 -1
- package/assets/js/components/config/config.component.min.js +1 -1
- package/assets/js/components/content/content.component.min.js +1 -1
- package/assets/js/components/darkmode/darkmode.component.min.js +1 -1
- package/assets/js/components/doughnutchart/doughnutchart.component.min.js +1 -1
- package/assets/js/components/fileupload/fileupload.component.min.js +1 -1
- package/assets/js/components/filter-card/filter-card.component.min.js +4 -4
- package/assets/js/components/filter-card/filter-card.component.min.js.map +1 -1
- package/assets/js/components/filterlist/filterlist.component.min.js +1 -1
- package/assets/js/components/form/form.component.min.js +1 -1
- package/assets/js/components/header/header.component.min.js +1 -1
- package/assets/js/components/inline-edit/inline-edit.component.min.js +1 -1
- package/assets/js/components/input/input.component.min.js +1 -1
- package/assets/js/components/input-range/input-range.component.min.js +1 -1
- package/assets/js/components/marketing/marketing.component.min.js +1 -1
- package/assets/js/components/menu/menu.component.min.js +1 -1
- package/assets/js/components/milestone/milestone.component.min.js +1 -1
- package/assets/js/components/milestone-group/milestone-group.component.min.js +1 -1
- package/assets/js/components/modal/modal.component.min.js +2 -2
- package/assets/js/components/multi-step/multi-step.component.min.js +1 -1
- package/assets/js/components/multi-step-modal/multi-step-modal.component.min.js +1 -1
- package/assets/js/components/multiselect/multiselect.component.js +14 -1
- package/assets/js/components/multiselect/multiselect.component.min.js +3 -3
- package/assets/js/components/multiselect/multiselect.component.min.js.map +1 -1
- package/assets/js/components/nav/nav.component.min.js +1 -1
- package/assets/js/components/notification/notification.component.min.js +1 -1
- package/assets/js/components/pagination/pagination.component.min.js +1 -1
- package/assets/js/components/password/password.component.min.js +1 -1
- package/assets/js/components/popover/popover.component.min.js +1 -1
- package/assets/js/components/rank/rank.component.min.js +1 -1
- package/assets/js/components/rankings/rankings.component.min.js +1 -1
- package/assets/js/components/rating/rating.component.min.js +1 -1
- package/assets/js/components/record-card/record-card.component.min.js +4 -4
- package/assets/js/components/record-card/record-card.component.min.js.map +1 -1
- package/assets/js/components/search/search.component.min.js +5 -5
- package/assets/js/components/search/search.component.min.js.map +1 -1
- package/assets/js/components/skeleton/skeleton.component.min.js +1 -1
- package/assets/js/components/slider/slider.component.min.js +1 -1
- package/assets/js/components/split-button/split-button.component.min.js +1 -1
- package/assets/js/components/std-address-lookup/std-address-lookup.component.min.js +4 -4
- package/assets/js/components/std-address-lookup/std-address-lookup.component.min.js.map +1 -1
- package/assets/js/components/std-nav/std-nav.component.min.js +1 -1
- package/assets/js/components/std-nav-standalone/std-nav-standalone.component.min.js +1 -1
- package/assets/js/components/table/table.component.min.js +1 -1
- package/assets/js/components/table-ajax/table-ajax.component.min.js +1 -1
- package/assets/js/components/table-basic/table-basic.component.min.js +1 -1
- package/assets/js/components/table-no-submit/table-no-submit.component.min.js +1 -1
- package/assets/js/components/table-submit/table-submit.component.min.js +1 -1
- package/assets/js/components/tabs/tabs.component.min.js +2 -2
- package/assets/js/components/tag/tag.component.min.js +1 -1
- package/assets/js/components/tooltip/tooltip.component.min.js +1 -1
- package/assets/js/components/video/video.component.min.js +1 -1
- package/assets/js/components/video-card/video-card.component.min.js +6 -6
- package/assets/js/components/video-card/video-card.component.min.js.map +1 -1
- package/assets/js/components/video-modal/video-modal.component.min.js +2 -2
- package/assets/js/components/word-count/word-count.component.min.js +1 -1
- package/assets/js/modules/advanced-select.js +6 -3
- package/assets/js/modules/advanced-select.test.js +28 -0
- package/assets/js/modules/applied-filters.test.js +21 -0
- package/assets/js/modules/card.module.js +3 -2
- package/assets/js/modules/card.module.test.js +20 -0
- package/assets/js/modules/carousel.test.js +18 -0
- package/assets/js/modules/chart.module.test.js +22 -0
- package/assets/js/modules/chart.test.js +15 -0
- package/assets/js/modules/content.test.js +20 -0
- package/assets/js/modules/data-layer.test.js +12 -0
- package/assets/js/modules/dialogs.test.js +13 -0
- package/assets/js/modules/drawer.test.js +16 -0
- package/assets/js/modules/dropdown.test.js +31 -0
- package/assets/js/modules/dynamicEvents.test.js +19 -0
- package/assets/js/modules/fileupload.test.js +17 -0
- package/assets/js/modules/filterlist.test.js +18 -0
- package/assets/js/modules/{helper.test.js → helpers.test.js} +42 -2
- package/assets/js/modules/integration-tests.test.js +12 -0
- package/assets/js/modules/milestone-group.test.js +18 -0
- package/assets/js/modules/milestone.test.js +31 -0
- package/assets/js/modules/modal.test.js +18 -0
- package/assets/js/modules/nav.test.js +37 -0
- package/assets/js/modules/notification.test.js +11 -0
- package/assets/js/modules/orderablelist.test.js +15 -0
- package/assets/js/modules/pagination.test.js +21 -0
- package/assets/js/modules/password.test.js +33 -0
- package/assets/js/modules/table.test.js +42 -0
- package/assets/js/modules/tabs.test.js +23 -0
- package/assets/js/modules/test-dom.js +725 -0
- package/assets/js/modules/test-globals.js +7 -0
- package/assets/js/modules/test-utils.js +26 -0
- package/assets/js/modules/test.js +20 -1
- package/assets/js/modules/testimonial.test.js +14 -0
- package/assets/js/modules/videos.test.js +37 -0
- package/assets/js/scripts.bundle.js +1 -1
- package/assets/js/scripts.bundle.min.js +1 -1
- package/assets/sass/components/modal.component.scss +1 -2
- package/assets/sass/elements/badge-tag.css +1 -1
- package/assets/sass/utilities/border.css +1 -1
- package/assets/ts/components/multiselect/multiselect.component.ts +20 -1
- package/assets/ts/modules/advanced-select.test.ts +33 -0
- package/assets/ts/modules/advanced-select.ts +6 -2
- package/assets/ts/modules/applied-filters.test.ts +25 -0
- package/assets/ts/modules/card.module.test.ts +24 -0
- package/assets/ts/modules/card.module.ts +2 -1
- package/assets/ts/modules/carousel.test.ts +27 -0
- package/assets/ts/modules/chart.module.test.ts +26 -0
- package/assets/ts/modules/chart.test.ts +19 -0
- package/assets/ts/modules/content.test.ts +24 -0
- package/assets/ts/modules/data-layer.test.ts +15 -0
- package/assets/ts/modules/dialogs.test.ts +17 -0
- package/assets/ts/modules/drawer.test.ts +20 -0
- package/assets/ts/modules/dropdown.test.ts +38 -0
- package/assets/ts/modules/dynamicEvents.test.ts +23 -0
- package/assets/ts/modules/fileupload.test.ts +21 -0
- package/assets/ts/modules/filterlist.test.ts +22 -0
- package/assets/ts/modules/{helper.test.ts → helpers.test.ts} +63 -2
- package/assets/ts/modules/integration-tests.test.ts +15 -0
- package/assets/ts/modules/milestone-group.test.ts +22 -0
- package/assets/ts/modules/milestone.test.ts +35 -0
- package/assets/ts/modules/modal.test.ts +22 -0
- package/assets/ts/modules/nav.test.ts +41 -0
- package/assets/ts/modules/notification.test.ts +15 -0
- package/assets/ts/modules/orderablelist.test.ts +19 -0
- package/assets/ts/modules/pagination.test.ts +25 -0
- package/assets/ts/modules/password.test.ts +40 -0
- package/assets/ts/modules/table.test.ts +57 -0
- package/assets/ts/modules/tabs.test.ts +27 -0
- package/assets/ts/modules/test-dom.ts +798 -0
- package/assets/ts/modules/test-globals.ts +7 -0
- package/assets/ts/modules/test-utils.ts +29 -0
- package/assets/ts/modules/test.ts +28 -1
- package/assets/ts/modules/testimonial.test.ts +17 -0
- package/assets/ts/modules/videos.test.ts +33 -0
- package/dist/components.es.js +24 -24
- package/dist/components.umd.js +113 -113
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { describe, expect, it } from './test.ts';
|
|
2
|
+
import { createElement, installTestDom } from './test-dom.ts';
|
|
3
|
+
import { append } from './test-utils.ts';
|
|
4
|
+
import { filterTheList } from './filterlist.ts';
|
|
5
|
+
const { window } = installTestDom();
|
|
6
|
+
describe('Filter list module', () => {
|
|
7
|
+
it('filters list items and records the search term', () => {
|
|
8
|
+
window.dataLayer = [];
|
|
9
|
+
const list = createElement('ul');
|
|
10
|
+
const one = createElement('li', {}, 'Alpha');
|
|
11
|
+
const two = createElement('li', {}, 'Beta');
|
|
12
|
+
append(list, one, two);
|
|
13
|
+
filterTheList(list, 'alp');
|
|
14
|
+
expect(!one.classList.contains('d-none'));
|
|
15
|
+
expect(two.classList.contains('d-none'));
|
|
16
|
+
expect(window.dataLayer[0].event === 'Filtered list');
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -1,10 +1,50 @@
|
|
|
1
|
-
import { describe, it, expect } from './test.
|
|
2
|
-
import { isValidPostcode } from './helpers.
|
|
1
|
+
import { describe, it, expect } from './test.js';
|
|
2
|
+
import { getSwipeDirection, isNumeric, isTraversable, isValidPostcode, numberOfDays, resolvePath, safeID, snake, ucfirst, ucwords, unsnake, zeroPad, } from './helpers.js';
|
|
3
|
+
import { installTestDom } from './test-dom.js';
|
|
3
4
|
describe("MathUtils Tests", function () {
|
|
4
5
|
it('should pass', function () {
|
|
5
6
|
expect(1 === 1);
|
|
6
7
|
});
|
|
7
8
|
});
|
|
9
|
+
describe('The general helper functions', () => {
|
|
10
|
+
installTestDom();
|
|
11
|
+
it('should identify numeric strings only', () => {
|
|
12
|
+
expect(isNumeric('12.5'));
|
|
13
|
+
expect(!isNumeric(''));
|
|
14
|
+
expect(!isNumeric('abc'));
|
|
15
|
+
expect(!isNumeric(12));
|
|
16
|
+
});
|
|
17
|
+
it('should format simple string values', () => {
|
|
18
|
+
expect(zeroPad(7, 3) === '007');
|
|
19
|
+
expect(ucfirst('hello') === 'Hello');
|
|
20
|
+
expect(ucwords('hello world') === 'Hello World');
|
|
21
|
+
expect(unsnake('hello_world') === 'hello world');
|
|
22
|
+
expect(snake('hello world') === 'hello_world');
|
|
23
|
+
expect(safeID('Hello world!') === 'hello_world');
|
|
24
|
+
});
|
|
25
|
+
it('should count inclusive date ranges', () => {
|
|
26
|
+
expect(numberOfDays('01/01/2026', '03/01/2026') === 3);
|
|
27
|
+
});
|
|
28
|
+
it('should resolve nested object paths', () => {
|
|
29
|
+
const data = { user: { name: 'Ada', roles: ['admin'] } };
|
|
30
|
+
expect(resolvePath(data, 'user.name', '') === 'Ada');
|
|
31
|
+
expect(resolvePath(data, 'user.roles[0]', '') === 'admin');
|
|
32
|
+
expect(resolvePath(data, 'account.name', 'fallback') === 'fallback');
|
|
33
|
+
});
|
|
34
|
+
it('should identify traversable values', () => {
|
|
35
|
+
expect(isTraversable([]));
|
|
36
|
+
expect(isTraversable({}));
|
|
37
|
+
expect(!isTraversable(null));
|
|
38
|
+
expect(!isTraversable('value'));
|
|
39
|
+
});
|
|
40
|
+
it('should detect swipe direction', () => {
|
|
41
|
+
expect(getSwipeDirection(100, 100, 20, 100) === 'left');
|
|
42
|
+
expect(getSwipeDirection(100, 100, 180, 100) === 'right');
|
|
43
|
+
expect(getSwipeDirection(100, 100, 100, 20) === 'top');
|
|
44
|
+
expect(getSwipeDirection(100, 100, 100, 180) === 'bottom');
|
|
45
|
+
expect(getSwipeDirection(100, 100, 101, 101) === 'tap');
|
|
46
|
+
});
|
|
47
|
+
});
|
|
8
48
|
describe('The postcode helper function', () => {
|
|
9
49
|
// #region valid pattern variations
|
|
10
50
|
it('should return true when testing the postcode "ne33hd"', () => {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { describe, expect, it } from './test.ts';
|
|
2
|
+
import { installTestDom } from './test-dom.ts';
|
|
3
|
+
import { silenceConsole } from './test-utils.ts';
|
|
4
|
+
import integrationTests from './integration-tests.ts';
|
|
5
|
+
const { window } = installTestDom();
|
|
6
|
+
describe('Integration tests module', () => {
|
|
7
|
+
it('runs integration checks against an empty document', () => {
|
|
8
|
+
silenceConsole(() => integrationTests());
|
|
9
|
+
expect(window.integrationTestsIntro.includes('component or element'));
|
|
10
|
+
expect(Array.isArray(window.integrationTests));
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { describe, expect, it } from './test.ts';
|
|
2
|
+
import { createElement, installTestDom } from './test-dom.ts';
|
|
3
|
+
import milestoneGroup from './milestone-group.ts';
|
|
4
|
+
installTestDom();
|
|
5
|
+
describe('Milestone group module', () => {
|
|
6
|
+
it('toggles future milestone visibility', () => {
|
|
7
|
+
const group = createElement('iam-milestone-group', { dataShowAllToggle: 'true' });
|
|
8
|
+
let opened = false;
|
|
9
|
+
group.addEventListener('show-future-items', () => {
|
|
10
|
+
opened = true;
|
|
11
|
+
});
|
|
12
|
+
milestoneGroup(group);
|
|
13
|
+
group.children[0].click();
|
|
14
|
+
expect(group.classList.contains('show-all'));
|
|
15
|
+
expect(group.children[0].innerHTML === 'Hide next steps');
|
|
16
|
+
expect(opened);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { describe, expect, it } from './test.ts';
|
|
2
|
+
import { createElement, installTestDom } from './test-dom.ts';
|
|
3
|
+
import { append } from './test-utils.ts';
|
|
4
|
+
import milestone from './milestone.ts';
|
|
5
|
+
installTestDom();
|
|
6
|
+
describe('Milestone module', () => {
|
|
7
|
+
it('adds milestone status and task details', () => {
|
|
8
|
+
const milestoneElement = createElement('iam-milestone', {
|
|
9
|
+
dataStatus: 'Current',
|
|
10
|
+
dataItems: JSON.stringify([
|
|
11
|
+
{
|
|
12
|
+
name: 'Checks',
|
|
13
|
+
description: 'Run checks',
|
|
14
|
+
date_completed: '2026-01-01',
|
|
15
|
+
actions: [
|
|
16
|
+
{ action: 'One', date_completed: '2026-01-01' },
|
|
17
|
+
{ action: 'Two' },
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
]),
|
|
21
|
+
});
|
|
22
|
+
milestoneElement.shadowRoot = createElement('shadow-root');
|
|
23
|
+
const wrap = createElement('div', { class: 'milestone-wrap' });
|
|
24
|
+
const tasks = createElement('div', { class: 'task-wrap' });
|
|
25
|
+
append(milestoneElement.shadowRoot, wrap, tasks);
|
|
26
|
+
milestone(milestoneElement);
|
|
27
|
+
expect(milestoneElement.classList.contains('current'));
|
|
28
|
+
expect(wrap.children[0].innerHTML === 'Current Step');
|
|
29
|
+
expect(tasks.children[0].querySelector('summary').innerHTML.includes('(1/2)'));
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { describe, expect, it } from './test.ts';
|
|
2
|
+
import { createElement, installTestDom } from './test-dom.ts';
|
|
3
|
+
import { append } from './test-utils.ts';
|
|
4
|
+
import { closeModal, openModal } from './modal.ts';
|
|
5
|
+
const { window } = installTestDom();
|
|
6
|
+
describe('Modal module', () => {
|
|
7
|
+
it('opens and closes modal dialogs with data layer events', () => {
|
|
8
|
+
window.dataLayer = [];
|
|
9
|
+
const dialog = createElement('dialog');
|
|
10
|
+
const modal = createElement('iam-modal', { id: 'confirm' });
|
|
11
|
+
append(dialog, modal);
|
|
12
|
+
openModal(modal);
|
|
13
|
+
closeModal(modal);
|
|
14
|
+
expect(dialog.open === false);
|
|
15
|
+
expect(window.dataLayer[0].event === 'openModal');
|
|
16
|
+
expect(window.dataLayer[1].event === 'closeModal');
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { describe, expect, it } from './test.ts';
|
|
2
|
+
import { createElement, installTestDom } from './test-dom.ts';
|
|
3
|
+
import { append } from './test-utils.ts';
|
|
4
|
+
import { populateLinks, setEnabledLinks } from './nav.ts';
|
|
5
|
+
installTestDom();
|
|
6
|
+
describe('Navigation module', () => {
|
|
7
|
+
it('builds navigation links and enables linked destinations', () => {
|
|
8
|
+
const links = [
|
|
9
|
+
{
|
|
10
|
+
title: 'Sales',
|
|
11
|
+
productKey: 'sales',
|
|
12
|
+
featureKey: 'dashboard',
|
|
13
|
+
destinations: {
|
|
14
|
+
unlinked: '/sales',
|
|
15
|
+
linkedEnabled: '/linked',
|
|
16
|
+
linkedDisabled: '/disabled',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
const component = createElement('nav');
|
|
21
|
+
component.innerHTML = populateLinks(links);
|
|
22
|
+
const link = createElement('a', {
|
|
23
|
+
dataProduct: 'sales',
|
|
24
|
+
dataFeature: 'dashboard',
|
|
25
|
+
dataEnabled: '/linked',
|
|
26
|
+
href: '/sales',
|
|
27
|
+
target: '_blank',
|
|
28
|
+
});
|
|
29
|
+
append(component, link);
|
|
30
|
+
setEnabledLinks(component, {
|
|
31
|
+
attributes: { products: { sales: { features: { dashboard: true } } } },
|
|
32
|
+
});
|
|
33
|
+
expect(populateLinks(links).includes('data-product="sales"'));
|
|
34
|
+
expect(link.getAttribute('href') === '/linked');
|
|
35
|
+
expect(!link.hasAttribute('target'));
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { describe, expect, it } from './test.ts';
|
|
2
|
+
import { createElement, installTestDom } from './test-dom.ts';
|
|
3
|
+
import { closeNotification } from './notification.ts';
|
|
4
|
+
installTestDom();
|
|
5
|
+
describe('Notification module', () => {
|
|
6
|
+
it('hides notifications', () => {
|
|
7
|
+
const notification = createElement('div');
|
|
8
|
+
closeNotification(notification);
|
|
9
|
+
expect(notification.classList.contains('d-none'));
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { describe, expect, it } from './test.ts';
|
|
2
|
+
import { createElement, installTestDom } from './test-dom.ts';
|
|
3
|
+
import { append } from './test-utils.ts';
|
|
4
|
+
import orderlist from './orderablelist.ts';
|
|
5
|
+
installTestDom();
|
|
6
|
+
describe('Orderable list module', () => {
|
|
7
|
+
it('sets sortable list semantics', () => {
|
|
8
|
+
const list = createElement('ol');
|
|
9
|
+
append(list, createElement('li', {}, 'First'), createElement('li', {}, 'Second'));
|
|
10
|
+
orderlist(list);
|
|
11
|
+
expect(list.getAttribute('role') === 'list');
|
|
12
|
+
expect(list.children[0].getAttribute('draggable') === 'true');
|
|
13
|
+
expect(list.children[1].getAttribute('data-order') === '2');
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { describe, expect, it } from './test.ts';
|
|
2
|
+
import { createElement, installTestDom } from './test-dom.ts';
|
|
3
|
+
import createPaginationButtons from './pagination.ts';
|
|
4
|
+
installTestDom();
|
|
5
|
+
describe('Pagination module', () => {
|
|
6
|
+
it('renders pagination controls from controller attributes', () => {
|
|
7
|
+
const controller = createElement('iam-table', {
|
|
8
|
+
dataPages: '3',
|
|
9
|
+
dataPage: '2',
|
|
10
|
+
dataTotal: '30',
|
|
11
|
+
dataShow: '10',
|
|
12
|
+
dataIncrement: '10',
|
|
13
|
+
});
|
|
14
|
+
const pagination = createElement('div');
|
|
15
|
+
const result = createPaginationButtons(controller, pagination);
|
|
16
|
+
expect(result === true);
|
|
17
|
+
expect(pagination.innerHTML.includes('<option value="2" selected>2</option>'));
|
|
18
|
+
expect(pagination.innerHTML.includes('data-page="1"'));
|
|
19
|
+
expect(pagination.innerHTML.includes('data-page="3"'));
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { describe, expect, it } from './test.ts';
|
|
2
|
+
import { createElement, installTestDom } from './test-dom.ts';
|
|
3
|
+
import { append } from './test-utils.ts';
|
|
4
|
+
import { changeType, checkPWDStrength } from './password.ts';
|
|
5
|
+
const { document } = installTestDom();
|
|
6
|
+
describe('Password module', () => {
|
|
7
|
+
it('toggles password input visibility', () => {
|
|
8
|
+
const wrapper = createElement('div');
|
|
9
|
+
const input = createElement('input', { type: 'password' });
|
|
10
|
+
input.type = 'password';
|
|
11
|
+
const toggle = createElement('span', { dataAltClass: 'is-visible' });
|
|
12
|
+
const button = createElement('button', { class: 'is-hidden' });
|
|
13
|
+
append(toggle, button);
|
|
14
|
+
append(wrapper, input, toggle);
|
|
15
|
+
changeType(toggle);
|
|
16
|
+
toggle.dispatchEvent(new Event('click'));
|
|
17
|
+
expect(input.getAttribute('type') === 'text');
|
|
18
|
+
expect(button.getAttribute('class') === 'is-visible');
|
|
19
|
+
});
|
|
20
|
+
it('writes password strength feedback without the breach check when already checked', () => {
|
|
21
|
+
const input = createElement('input', {
|
|
22
|
+
dataStrengthChecker: 'strength',
|
|
23
|
+
minlength: '8',
|
|
24
|
+
value: 'Aa1!aaaa',
|
|
25
|
+
});
|
|
26
|
+
const feedback = createElement('div', { id: 'strength', class: 'invalid-feedback' });
|
|
27
|
+
append(document.body, input, feedback);
|
|
28
|
+
checkPWDStrength(input, 'success');
|
|
29
|
+
expect(feedback.getAttribute('data-strength') === '5');
|
|
30
|
+
expect(feedback.innerHTML.includes('Very strong'));
|
|
31
|
+
expect(!feedback.classList.contains('invalid-feedback'));
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import { describe, expect, it } from './test.ts';
|
|
3
|
+
import { createElement, installTestDom } from './test-dom.ts';
|
|
4
|
+
import { append } from './test-utils.ts';
|
|
5
|
+
import { addDataAttributes, formatCell, sortTableByValues } from './table.ts';
|
|
6
|
+
installTestDom();
|
|
7
|
+
const makeTable = () => {
|
|
8
|
+
const table = createElement('table');
|
|
9
|
+
const thead = createElement('thead');
|
|
10
|
+
const headRow = createElement('tr');
|
|
11
|
+
const tbody = createElement('tbody');
|
|
12
|
+
append(thead, append(headRow, createElement('th', {}, 'Name'), createElement('th', {}, 'Score')));
|
|
13
|
+
append(tbody, append(createElement('tr'), createElement('td', { dataLabel: 'Name' }, 'Bravo'), createElement('td', { dataLabel: 'Score' }, '2')), append(createElement('tr'), createElement('td', { dataLabel: 'Name' }, 'Alpha'), createElement('td', { dataLabel: 'Score' }, '10')));
|
|
14
|
+
append(table, thead, tbody);
|
|
15
|
+
return { table, tbody };
|
|
16
|
+
};
|
|
17
|
+
describe('Table module', () => {
|
|
18
|
+
it('formats and sorts table data', () => {
|
|
19
|
+
const { table, tbody } = makeTable();
|
|
20
|
+
sortTableByValues(table, 'Score', 'asc');
|
|
21
|
+
expect(formatCell('capitalise', 'alpha') === 'Alpha');
|
|
22
|
+
expect(tbody.innerHTML.indexOf('2') < tbody.innerHTML.indexOf('10'));
|
|
23
|
+
});
|
|
24
|
+
it('adds data labels and content markers to table cells', () => {
|
|
25
|
+
const table = createElement('table');
|
|
26
|
+
const thead = createElement('thead');
|
|
27
|
+
const headRow = createElement('tr');
|
|
28
|
+
const statusHeading = createElement('th', {}, 'Status');
|
|
29
|
+
const dateHeading = createElement('th', { dataFormat: 'capitalise' }, 'Name');
|
|
30
|
+
const tbody = createElement('tbody');
|
|
31
|
+
const row = createElement('tr');
|
|
32
|
+
append(headRow, statusHeading, dateHeading);
|
|
33
|
+
append(thead, headRow);
|
|
34
|
+
append(row, createElement('td', {}, 'Complete'), createElement('td', {}, 'alpha'));
|
|
35
|
+
append(tbody, row);
|
|
36
|
+
append(table, thead, tbody);
|
|
37
|
+
addDataAttributes(table);
|
|
38
|
+
expect(row.children[0].getAttribute('data-label') === 'Status');
|
|
39
|
+
expect(row.children[0].getAttribute('data-content') === 'complete');
|
|
40
|
+
expect(row.children[1].innerHTML === 'Alpha');
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { describe, expect, it } from './test.ts';
|
|
2
|
+
import { createElement, installTestDom } from './test-dom.ts';
|
|
3
|
+
import { append } from './test-utils.ts';
|
|
4
|
+
import { openFirstTab, toggleTab } from './tabs.ts';
|
|
5
|
+
installTestDom();
|
|
6
|
+
describe('Tabs module', () => {
|
|
7
|
+
it('toggles tabs and opens the first tab by default', () => {
|
|
8
|
+
const tabs = createElement('iam-tabs');
|
|
9
|
+
const first = createElement('details');
|
|
10
|
+
const second = createElement('details');
|
|
11
|
+
const buttonOne = createElement('button', { dataIndex: '0' });
|
|
12
|
+
const buttonTwo = createElement('button', { dataIndex: '1' });
|
|
13
|
+
tabs.shadowRoot = createElement('shadow-root');
|
|
14
|
+
const links = createElement('div', { class: 'tabs__links' });
|
|
15
|
+
append(links, buttonOne, buttonTwo);
|
|
16
|
+
append(tabs.shadowRoot, links);
|
|
17
|
+
append(tabs, first, second);
|
|
18
|
+
toggleTab([first, second], buttonTwo);
|
|
19
|
+
openFirstTab(tabs);
|
|
20
|
+
expect(!first.hasAttribute('open'));
|
|
21
|
+
expect(second.hasAttribute('open'));
|
|
22
|
+
});
|
|
23
|
+
});
|