Skip to content

Commit

Permalink
chore: bump dependencies (#551)
Browse files Browse the repository at this point in the history
* chore: bump dependencies

* fix: stylelint issues

* chore: align jest versions

* test: fixed failing tests

* test: fixed tests for manage WIP

* test: fixed tests for presentation WIP

* chore: fix eslint errors WIP

* chore: fix eslint errors in core WIP

* test: fixed tests for components WIP
  • Loading branch information
lem-onade authored Jan 6, 2022
1 parent 5dcaa49 commit 2f0a2ba
Show file tree
Hide file tree
Showing 49 changed files with 20,574 additions and 24,657 deletions.
14,063 changes: 5,920 additions & 8,143 deletions package-lock.json

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,28 @@
"@commitlint/cli": "^12.0.1",
"@digita-ai/commitlint-config": "^0.3.3",
"@digita-ai/eslint-config": "^0.3.3",
"@digita-ai/jest-config": "^0.3.3",
"@digita-ai/lerna-config": "^0.3.3",
"@digita-ai/jest-config": "^0.4.4",
"@digita-ai/lerna-config": "^0.4.4",
"@types/jest": "^26.0.23",
"@typescript-eslint/eslint-plugin": "^4.22.1",
"dot-json": "^1.2.1",
"eslint": "^7.16.0",
"eslint-import-resolver-typescript": "^2.4.0",
"eslint-plugin-deprecation": "^1.3.2",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^25.3.4",
"eslint-plugin-jest-formatting": "^3.1.0",
"eslint-plugin-jsdoc": "^32.2.0",
"eslint-plugin-no-null": "^1.0.2",
"eslint-plugin-prefer-arrow": "^1.2.3",
"husky": "^5.0.6",
"jest": "^26.6.3",
"jest-coverage-thresholds-bumper": "0.0.4",
"jest-extended": "^0.11.5",
"jest-mock-extended": "^1.0.14",
"lerna": "^3.22.1",
"yaml-cli": "^1.1.8",
"jest": "^27.4.5",
"jest-coverage-thresholds-bumper": "1.1.0",
"jest-extended": "^1.2.0",
"jest-mock-extended": "^2.0.4",
"lerna": "^4.0.0",
"lint-staged": "^10.5.4",
"ts-jest": "^26.5.5",
"ts-jest": "27.1.2",
"typescript": "3.8.3"
},
"commitlint": {
Expand Down
112 changes: 52 additions & 60 deletions packages/solid-crs-components/lib/forms/form-element.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('FormElementComponent', () => {
let machine: Interpreter<FormContext<any>, State<FormStates, FormContext<unknown>>, FormEvent>;
let input: HTMLInputElement;

beforeEach(() => {
beforeEach(async () => {

machine = interpret(
formMachine<any>(
Expand All @@ -30,33 +30,33 @@ describe('FormElementComponent', () => {
}),
);

component = window.document.createElement('nde-form-element') as FormElementComponent<any>;
component = document.createElement('nde-form-element') as FormElementComponent<any>;

component.actor = machine;
component.field = 'name';
component.data = { uri: '', name: 'Test', description: 'description', selected: [ '1' ] };

const label = window.document.createElement('label');
const label = document.createElement('label');
label.innerHTML = 'Foo';
label.slot = 'label';
component.appendChild(label);

const help = window.document.createElement('div');
const help = document.createElement('div');
help.innerHTML = 'Bar';
help.slot = 'help';
component.appendChild(help);

const icon = window.document.createElement('div');
const icon = document.createElement('div');
icon.innerHTML = 'x';
icon.slot = 'icon';
component.appendChild(icon);

const action = window.document.createElement('button');
const action = document.createElement('button');
action.innerHTML = 'go';
action.slot = 'action';
component.appendChild(action);

input = window.document.createElement('input');
input = document.createElement('input');
input.type = 'text';
input.slot = 'input';
component.appendChild(input);
Expand All @@ -67,6 +67,9 @@ describe('FormElementComponent', () => {

jest.clearAllMocks();

document.body.appendChild(component);
await component.updateComplete;

});

afterEach(() => {
Expand All @@ -85,30 +88,29 @@ describe('FormElementComponent', () => {

it('should set default value on slotted text input field', async () => {

window.document.body.appendChild(component);
document.body.appendChild(component);
await component.updateComplete;

expect((window.document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelector<HTMLSlotElement>('.field slot').assignedElements()[0] as HTMLInputElement).value).toBe('Test');
expect(input.value).toBe('Test');

});

it('should allow slotted textarea field', async () => {

component.field = 'description';
const select = window.document.createElement('textarea');
const select = document.createElement('textarea');
select.slot = 'input';
select.innerText = 'test description';
component.appendChild(select);
component.removeChild(input);

window.document.body.appendChild(component);
await component.updateComplete;

expect((window.document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelector<HTMLSlotElement>('.field slot').assignedElements()[0] as HTMLSelectElement).innerText).toEqual(select.innerText);
expect((component.shadowRoot.querySelector<HTMLSlotElement>('.field slot').assignedElements()[0] as HTMLSelectElement).innerText).toEqual(select.innerText);

});

it('should send event when updating slotted text input field', async (done) => {
it('should send event when updating slotted text input field', (done) => {

machine.onEvent(((event) => {

Expand All @@ -126,17 +128,14 @@ describe('FormElementComponent', () => {

machine.start();

window.document.body.appendChild(component);
await component.updateComplete;

// const input = window.document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelector<HTMLSlotElement>('.input slot').assignedElements()[0] as HTMLInputElement;
// const input = document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelector<HTMLSlotElement>('.input slot').assignedElements()[0] as HTMLInputElement;

input.value = 'Lorem';
input.dispatchEvent(new Event('input'));

});

it('should send event when updating slotted number input field', async (done) => {
it('should send event when updating slotted number input field', (done) => {

machine.onEvent(((event) => {

Expand All @@ -156,9 +155,6 @@ describe('FormElementComponent', () => {

component.field = 'weight';

window.document.body.appendChild(component);
await component.updateComplete;

input.type = 'number';
(input.value as any) = 123;
input.dispatchEvent(new Event('input'));
Expand All @@ -172,18 +168,18 @@ describe('FormElementComponent', () => {
it('should allow slotted select field', async () => {

component.field = 'description';
const select = window.document.createElement('select');
const select = document.createElement('select');
select.slot = 'input';
const option = window.document.createElement('option');
const option = document.createElement('option');
option.id = 'description';
select.appendChild(option);
component.appendChild(select);
component.removeChild(input);

window.document.body.appendChild(component);
document.body.appendChild(component);
await component.updateComplete;

expect((window.document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelector<HTMLSlotElement>('.field slot').assignedElements()[0] as HTMLSelectElement).children.length).toBe(1);
expect((document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelector<HTMLSlotElement>('.field slot').assignedElements()[0] as HTMLSelectElement).children.length).toBe(1);

});

Expand All @@ -198,14 +194,15 @@ describe('FormElementComponent', () => {

beforeEach(async() => {

component.removeChild(input);
component.field = 'selected';
ul = window.document.createElement('ul');
ul = document.createElement('ul');
ul.slot = 'input';
ul.type = 'multiselect';
titleListItem = window.document.createElement('li');
titleListItem = document.createElement('li');
titleListItem.setAttribute('for', 'title');
inputListItem = window.document.createElement('li');
inputLabel = window.document.createElement('label');
inputListItem = document.createElement('li');
inputLabel = document.createElement('label');
inputLabel.htmlFor = 'selected';
input.type = 'checkbox';
input.id = '1';
Expand All @@ -218,14 +215,13 @@ describe('FormElementComponent', () => {
component.appendChild(ul);
machine.start();

window.document.body.appendChild(component);
await component.updateComplete;
component.bindActorToInput(component.inputSlot, component.actor, component.field, component.data);

});

it('should allow slotted <ul> <li> with checkbox input fields', () => {

expect((window.document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelector<HTMLSlotElement>('.field slot').assignedElements()[0] as HTMLSelectElement)).toEqual(ul);
expect((document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelector<HTMLSlotElement>('.field slot').assignedElements()[0] as HTMLSelectElement)).toEqual(ul);

});

Expand Down Expand Up @@ -312,7 +308,7 @@ describe('FormElementComponent', () => {

});

it('should send SUBMITTED event when enter keypress', async (done) => {
it('should send SUBMITTED event when enter keypress', (done) => {

machine.onEvent(((event) => {

Expand All @@ -327,9 +323,6 @@ describe('FormElementComponent', () => {
machine.start();

component.submitOnEnter = true;
window.document.body.appendChild(component);
await component.updateComplete;

component.validationResults = [];
component.isValid = true;
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }));
Expand All @@ -340,11 +333,11 @@ describe('FormElementComponent', () => {

component.validationResults = [ { field: 'name', message: 'lorem' } ];

window.document.body.appendChild(component);
document.body.appendChild(component);
await component.updateComplete;

expect(window.document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelectorAll<HTMLSlotElement>('.results .result').length).toBe(1);
expect(window.document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelectorAll<HTMLSlotElement>('.help[hidden]').length).toBe(1);
expect(document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelectorAll<HTMLSlotElement>('.results .result').length).toBe(1);
expect(document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelectorAll<HTMLSlotElement>('.help[hidden]').length).toBe(1);

});

Expand All @@ -353,75 +346,75 @@ describe('FormElementComponent', () => {
component.validationResults = [ { field: 'name', message: 'lorem' } ];
component.hideValidation = true;

window.document.body.appendChild(component);
document.body.appendChild(component);
await component.updateComplete;

expect(window.document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelector<HTMLDivElement>('.results').hidden).toBeTruthy();
expect(window.document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelector<HTMLDivElement>('.content').classList).toContain('no-validation');
expect(document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelector<HTMLDivElement>('.results').hidden).toBeTruthy();
expect(document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelector<HTMLDivElement>('.content').classList).toContain('no-validation');

});

it('should show static slotted content', async () => {

window.document.body.appendChild(component);
document.body.appendChild(component);
await component.updateComplete;

expect(window.document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelector<HTMLSlotElement>('.help slot').assignedElements().length).toBe(1);
expect(window.document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelector<HTMLSlotElement>('.label slot').assignedElements().length).toBe(1);
expect(window.document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelector<HTMLSlotElement>('.icon slot').assignedElements().length).toBe(1);
expect(window.document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelector<HTMLSlotElement>('.action slot').assignedElements().length).toBe(1);
expect(document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelector<HTMLSlotElement>('.help slot').assignedElements().length).toBe(1);
expect(document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelector<HTMLSlotElement>('.label slot').assignedElements().length).toBe(1);
expect(document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelector<HTMLSlotElement>('.icon slot').assignedElements().length).toBe(1);
expect(document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelector<HTMLSlotElement>('.action slot').assignedElements().length).toBe(1);

});

it('should show loading when validating is true', async () => {

component.showLoading = true;

window.document.body.appendChild(component);
document.body.appendChild(component);
await component.updateComplete;

expect(window.document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelectorAll<HTMLDivElement>('.icon .loading').length).toEqual(1);
expect(document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelectorAll<HTMLDivElement>('.icon .loading').length).toEqual(1);

});

it('should not show loading when validating is false', async () => {

component.showLoading = false;

window.document.body.appendChild(component);
document.body.appendChild(component);
await component.updateComplete;

expect(window.document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelectorAll<HTMLDivElement>('.icon .loading').length).toEqual(0);
expect(document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelectorAll<HTMLDivElement>('.icon .loading').length).toEqual(0);

});

it('should show icon when not loading', async () => {

component.showLoading = false;

window.document.body.appendChild(component);
document.body.appendChild(component);
await component.updateComplete;

expect(window.document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelectorAll<HTMLDivElement>('.icon slot[name="icon"]').length).toEqual(1);
expect(document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelectorAll<HTMLDivElement>('.icon slot[name="icon"]').length).toEqual(1);

});

it('should not show icon when loading', async () => {

component.showLoading = true;

window.document.body.appendChild(component);
document.body.appendChild(component);
await component.updateComplete;

expect(window.document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelectorAll<HTMLDivElement>('.icon slot[name="icon"]').length).toEqual(0);
expect(document.body.getElementsByTagName('nde-form-element')[0].shadowRoot.querySelectorAll<HTMLDivElement>('.icon slot[name="icon"]').length).toEqual(0);

});

it('should disable input when locked', async () => {

component.lockInput = true;

window.document.body.appendChild(component);
document.body.appendChild(component);
await component.updateComplete;

expect(input.disabled).toBeTruthy();
Expand All @@ -432,7 +425,7 @@ describe('FormElementComponent', () => {

component.lockInput = false;

window.document.body.appendChild(component);
document.body.appendChild(component);
await component.updateComplete;

expect(input.disabled).toBeFalsy();
Expand All @@ -443,8 +436,7 @@ describe('FormElementComponent', () => {

component.className += ' inverse';

window.document.body.appendChild(component);
await component.updateComplete;
component.updated(new Map());

expect(component.inverse).toBeTruthy();

Expand All @@ -453,7 +445,7 @@ describe('FormElementComponent', () => {
describe('bindActorToInput', () => {

const slot: HTMLSlotElement = {
...window.document.createElement('input'),
...document.createElement('input'),
assignedElements: jest.fn(),
assignedNodes: jest.fn(),
};
Expand Down
Loading

0 comments on commit 2f0a2ba

Please sign in to comment.