Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/645 add unit tests for slots #903

Merged
merged 19 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
ce8464f
fix(ui-library): adding tab bar slot test
davidken91 Feb 9, 2024
8743960
fix(ui-library): updating form caption group test
davidken91 Feb 9, 2024
20d2bc8
fix(ui-library): adding select slot test
davidken91 Feb 9, 2024
285a32e
fix(ui-library): adding tooltip slot test
davidken91 Feb 9, 2024
407e6fc
Merge branch 'develop' into fix/645-add-unit-tests-for-slots
davidken91 Feb 9, 2024
4ffad3f
fix(ui-library): making slot unit tests dynamically check for child e…
davidken91 Feb 12, 2024
c2b1e1f
Merge branch 'fix/645-add-unit-tests-for-slots' of https://github.com…
davidken91 Feb 12, 2024
59924f9
Merge branch 'develop' into fix/645-add-unit-tests-for-slots
davidken91 Feb 12, 2024
a69ff71
Merge branch 'develop' into fix/645-add-unit-tests-for-slots
davidken91 Feb 13, 2024
50b47c3
fix(ui-library): adding tooltip child component test
davidken91 Feb 13, 2024
f19e6e8
Merge branch 'fix/645-add-unit-tests-for-slots' of https://github.com…
davidken91 Feb 13, 2024
89d9078
Merge branch 'develop' into fix/645-add-unit-tests-for-slots
davidken91 Feb 14, 2024
420cd67
Merge branch 'develop' of https://github.com/deven-org/BO1LER-Kitchen…
davidken91 Feb 16, 2024
25272b6
Merge branch 'develop' into fix/645-add-unit-tests-for-slots
davidken91 Feb 16, 2024
a3cce54
Merge branch 'develop' into fix/645-add-unit-tests-for-slots
davidken91 Feb 16, 2024
224245f
Merge branch 'develop' into fix/645-add-unit-tests-for-slots
davidken91 Feb 19, 2024
c454600
fix(ui-library): removing empty spaces in tab bar test
davidken91 Feb 19, 2024
502dbfa
Merge branch 'develop' into fix/645-add-unit-tests-for-slots
davidken91 Feb 20, 2024
47253f9
Merge branch 'develop' into fix/645-add-unit-tests-for-slots
davidken91 Feb 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BlrFormCaptionGroupRenderFunction } from './renderFunction';
import { BlrFormCaptionGroupType } from './index';

import { fixture, expect } from '@open-wc/testing';
import { querySelectorDeep } from 'query-selector-shadow-dom';
import { querySelectorAllDeep } from 'query-selector-shadow-dom';
import { BlrFormCaptionRenderFunction } from '../form-caption/renderFunction';
import { html } from 'lit-html';

Expand Down Expand Up @@ -33,8 +33,7 @@ const mixedCaptions = html` ${hintCaption} ${errorCaption} `;
describe('blr-form-caption-group', () => {
it('is rendering captions inside slot', async () => {
const element = await fixture(BlrFormCaptionGroupRenderFunction(sampleParams, mixedCaptions));
const caption = querySelectorDeep('blr-form-caption', element.getRootNode() as HTMLElement);

expect(caption).to.exist;
const captions = querySelectorAllDeep('blr-form-caption', element.getRootNode() as HTMLElement);
expect(captions).to.be.lengthOf(captions.length);
});
});
7 changes: 7 additions & 0 deletions packages/ui-library/src/components/select/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,11 @@ describe('blr-select', () => {

expect(className).to.contain('sm');
});

it('is rendering options inside slot', async () => {
const element = await fixture(BlrSelectRenderFunction({ ...sampleParams, size: 'sm' }, optionsAsChildren));
const options = querySelectorAllDeep('.blr-select-option', element?.getRootNode() as HTMLElement);
const optionsLength = optionsAsChildren.strings[0].trim().split('</option>').filter(Boolean).length;
expect(options).to.be.lengthOf(optionsLength);
});
});
19 changes: 12 additions & 7 deletions packages/ui-library/src/components/tab-bar/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import '@boiler/ui-library/dist/';
import { BlrTabBarRenderFunction } from './renderFunction';

import { fixture, expect } from '@open-wc/testing';
import { querySelectorDeep } from 'query-selector-shadow-dom';
import { querySelectorAllDeep, querySelectorDeep } from 'query-selector-shadow-dom';
import { html } from 'lit-html';
import { BlrTabBarType } from '.';

Expand Down Expand Up @@ -45,18 +45,23 @@ describe('blr-tab-bar', () => {
it('has a size md by default', async () => {
const element = await fixture(BlrTabBarRenderFunction(sampleParams, tabsAsChildren));

const input = querySelectorDeep('.blr-tab-bar-group', element.getRootNode() as HTMLElement);
const className = input?.className;

const tabBar = querySelectorDeep('.blr-tab-bar-group', element.getRootNode() as HTMLElement);
const className = tabBar?.className;
expect(className).to.contain('md');
});

it('has a size sm when "size" is set to "sm" ', async () => {
const element = await fixture(BlrTabBarRenderFunction({ ...sampleParams, size: 'sm' }, tabsAsChildren));

const input = querySelectorDeep('.blr-tab-bar-group', element.getRootNode() as HTMLElement);
const className = input?.className;

const tabBar = querySelectorDeep('.blr-tab-bar-group', element.getRootNode() as HTMLElement);
const className = tabBar?.className;
expect(className).to.contain('sm');
});

it('is rendering tabs inside slot', async () => {
const element = await fixture(BlrTabBarRenderFunction({ ...sampleParams, size: 'sm' }, tabsAsChildren));
const tabs = querySelectorAllDeep('.nav-item-container', element?.getRootNode() as HTMLElement);
const tabsLength = tabsAsChildren.strings[0].trim().split('</p>').filter(Boolean).length;
expect(tabs).to.be.lengthOf(tabsLength);
});
});
10 changes: 9 additions & 1 deletion packages/ui-library/src/components/tooltip/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ const sampleParams: BlrTooltipType = {
placement: 'right',
};

const testContent = html`<div style="height: 200px; width: 200px; background-color: lightblue"></div>`;
const testContent = html`<div
className="blue-box"
style="height: 200px; width: 200px; background-color: lightblue"
></div>`;

describe('blr-tooltip', () => {
it('is having a tooltip bubble element', async () => {
Expand All @@ -22,4 +25,9 @@ describe('blr-tooltip', () => {

expect(tooltip).to.exist;
});

it('is rendering the tooltip child element', async () => {
const element = await fixture(BlrTooltipRenderFunction(sampleParams, testContent));
expect(element.childNodes[1]).to.exist;
});
});
Loading