shoelace/src/components/spinner/spinner.test.ts

32 wiersze
1.3 KiB
TypeScript
Czysty Zwykły widok Historia

2023-06-13 19:43:21 +00:00
import '../../../dist/shoelace.js';
import { expect, fixture, html } from '@open-wc/testing';
import type SlSpinner from './spinner.js';
describe('<sl-spinner>', () => {
describe('when provided no parameters', () => {
2022-03-08 22:34:17 +00:00
it('should pass accessibility tests', async () => {
2023-01-10 15:48:55 +00:00
const spinner = await fixture<SlSpinner>(html` <sl-spinner></sl-spinner> `);
await expect(spinner).to.be.accessible();
});
2023-01-10 15:48:55 +00:00
it('should have a role of "status".', async () => {
const spinner = await fixture<SlSpinner>(html` <sl-spinner></sl-spinner> `);
const base = spinner.shadowRoot!.querySelector('[part~="base"]')!;
2022-08-10 20:53:27 +00:00
expect(base).have.attribute('role', 'progressbar');
});
2023-01-10 15:48:55 +00:00
it('should use "transform: rotate(x)" instead of "rotate: x" when animating', async () => {
const spinner = await fixture<SlSpinner>(html` <sl-spinner></sl-spinner> `);
const indicator = spinner.shadowRoot!.querySelector('.spinner__indicator')!;
//
// This matrix is the computed value when using `transform: rotate(x)` on the indicator. When using `rotate: x`,
// it will be "none" instead.
//
// Related: https://github.com/shoelace-style/shoelace/issues/1121
//
expect(getComputedStyle(indicator).transform).to.equal('matrix(1, 0, 0, 1, 0, 0)');
});
});
});