mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-10-20 18:56:22 +00:00
ui-shared: test the beachball container through public style accessors
The two style tests read CSSStyleDeclaration._values, a private store whose layout changed in cssstyle 4.6; with it, `background` is not a key there and both tests failed (hidden until now by continue-on-error). They compare style.background, style.borderRadius and the rest instead. Setting a different default background turns both red.
This commit is contained in:
1 parent
479df8c4f9
commit
5daf8f1435
1 file changed
+18
-11
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2017-2025 @pezkuwi/ui-shared authors & contributors
|
// Copyright 2017-2026 @pezkuwi/ui-shared authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
||||||
@@ -6,13 +6,23 @@
|
|||||||
import { container } from './container.js';
|
import { container } from './container.js';
|
||||||
|
|
||||||
describe('container', (): void => {
|
describe('container', (): void => {
|
||||||
|
// Read through the public CSSStyleDeclaration accessors; the private _values
|
||||||
|
// store these tests used to read is laid out differently by each cssstyle release.
|
||||||
|
const styles = ({ style }: HTMLElement) => ({
|
||||||
|
background: style.background,
|
||||||
|
borderRadius: style.borderRadius,
|
||||||
|
display: style.display,
|
||||||
|
height: style.height,
|
||||||
|
margin: style.margin,
|
||||||
|
overflow: style.overflow,
|
||||||
|
padding: style.padding,
|
||||||
|
width: style.width
|
||||||
|
});
|
||||||
|
|
||||||
it('applies default styles', (): void => {
|
it('applies default styles', (): void => {
|
||||||
expect(
|
expect(styles(container(100))).toEqual({
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-member-access
|
|
||||||
(container(100).style as any)._values
|
|
||||||
).toMatchObject({
|
|
||||||
background: 'white',
|
background: 'white',
|
||||||
'border-radius': '50px',
|
borderRadius: '50px',
|
||||||
display: 'inline-block',
|
display: 'inline-block',
|
||||||
height: '100px',
|
height: '100px',
|
||||||
margin: '0px',
|
margin: '0px',
|
||||||
@@ -23,12 +33,9 @@ describe('container', (): void => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('overrides with supplied styles', (): void => {
|
it('overrides with supplied styles', (): void => {
|
||||||
expect(
|
expect(styles(container(50, 'black', '', { display: 'block' }))).toEqual({
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-member-access
|
|
||||||
(container(50, 'black', '', { display: 'block' }).style as any)._values
|
|
||||||
).toMatchObject({
|
|
||||||
background: 'black',
|
background: 'black',
|
||||||
'border-radius': '25px',
|
borderRadius: '25px',
|
||||||
display: 'block',
|
display: 'block',
|
||||||
height: '50px',
|
height: '50px',
|
||||||
margin: '0px',
|
margin: '0px',
|
||||||
|
|||||||
Reference in new issue
Block a user