Files
webawesome/src/components/format-bytes/format-bytes.test.ts
Konnor Rogers 14914abf65 Initial SSR implementation (#157)
* continued ssr work

* continued ssr work

* prettier

* all components now rendering

* everything finally works

* fix type issues

* working on breadcrumb

* working on breadcrumb

* radio group

* convert all tests to ssr

* prettier

* test suite finally passing

* add layout stuff

* add changelog

* fix TS issue

* fix tests

* fixing deploy stuff

* get QR code displaying

* fix tests

* fix tests

* prettier

* condense hydration stuff

* prettier

* comment out range test

* fixing issues

* use base fixtures

* fixing examples

* dont vendor

* fix import of hydration support

* adding notes

* add notesg

* add ssr loader

* fix build

* prettier

* add notes

* add notes

* prettier

* fixing bundled stuff

* remove cdn

* remove cdn

* prettier

* fiixng tests

* prettier

* split jobs??

* prettier

* fix build stuff

* add reset mouse and await aTimeout

* prettier

* fix improper tests

* prettier

* bail on first

* fix linting

* only test form with client

* redundancy on ssr-loader??

* maybe this will work

* prettier

* try callout now

* fix form.test.ts

* fix form.test.ts

* prettier

* fix forms

* fix forms

* try again

* prettier

* add some awaits

* prettier

* comment out broken SSR tests

* prettier

* comment out broken SSR tests

* prettier

* dont skip in CI

* upgrade playwright to beta

* prettier

* try some trickery

* try some trickery

* await updateComplete

* try to fix form.test.ts

* import hydrateable elements 1 time

* prettier

* fix input defaultValue issues

* fix form controls to behave like their native counterpartS

* add changelog entry

* prettier

* fix unexpected behavior with range / button
2024-09-11 10:25:42 -04:00

124 lines
3.5 KiB
TypeScript

import { elementUpdated, expect } from '@open-wc/testing';
import { fixtures } from '../../internal/test/fixture.js';
import { html } from 'lit';
import type WaFormatBytes from './format-bytes.js';
describe('<wa-format-bytes>', () => {
for (const fixture of fixtures) {
describe(`with "${fixture.type}" rendering`, () => {
describe('defaults ', () => {
it('default properties', async () => {
const el = await fixture<WaFormatBytes>(html` <wa-format-bytes></wa-format-bytes> `);
expect(el.value).to.equal(0);
expect(el.unit).to.equal('byte');
expect(el.display).to.equal('short');
expect(el.lang).to.be.undefined;
});
});
describe('bytes', () => {
const results = [
{
value: 12,
short: '12 byte',
long: '12 bytes',
narrow: '12B'
},
{
value: 1200,
short: '1.2 kB',
long: '1.2 kilobytes',
narrow: '1.2kB'
},
{
value: 1200000,
short: '1.2 MB',
long: '1.2 megabytes',
narrow: '1.2MB'
},
{
value: 1200000000,
short: '1.2 GB',
long: '1.2 gigabytes',
narrow: '1.2GB'
}
];
results.forEach(expected => {
it('bytes : display formats', async () => {
const el = await fixture<WaFormatBytes>(html` <wa-format-bytes></wa-format-bytes> `);
// short
el.value = expected.value;
await elementUpdated(el);
expect(el.shadowRoot?.textContent).to.equal(expected.short);
// long
el.display = 'long';
el.value = expected.value;
await elementUpdated(el);
expect(el.shadowRoot?.textContent).to.equal(expected.long);
// narrow
el.display = 'narrow';
el.value = expected.value;
await elementUpdated(el);
expect(el.shadowRoot?.textContent).to.equal(expected.narrow);
});
});
});
describe('bits', () => {
const results = [
{
value: 12,
short: '12 bit',
long: '12 bits',
narrow: '12bit'
},
{
value: 1200,
short: '1.2 kb',
long: '1.2 kilobits',
narrow: '1.2kb'
},
{
value: 1200000,
short: '1.2 Mb',
long: '1.2 megabits',
narrow: '1.2Mb'
},
{
value: 1200000000,
short: '1.2 Gb',
long: '1.2 gigabits',
narrow: '1.2Gb'
}
];
results.forEach(expected => {
it('bits : display formats', async () => {
const el = await fixture<WaFormatBytes>(html` <wa-format-bytes unit="bit"></wa-format-bytes> `);
// short
el.value = expected.value;
await elementUpdated(el);
expect(el.shadowRoot?.textContent).to.equal(expected.short);
// long
el.display = 'long';
el.value = expected.value;
await elementUpdated(el);
expect(el.shadowRoot?.textContent).to.equal(expected.long);
// narrow
el.display = 'narrow';
el.value = expected.value;
await elementUpdated(el);
expect(el.shadowRoot?.textContent).to.equal(expected.narrow);
});
});
});
});
}
});