Skip to content

Commit 1dd69f0

Browse files
test(status-light): add dev mode warning tests in first-gen
1 parent b72ca8d commit 1dd69f0

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

first-gen/packages/status-light/test/status-light.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import '@spectrum-web-components/status-light/sp-status-light.js';
1313
import { StatusLight } from '@spectrum-web-components/status-light';
1414
import { elementUpdated, expect, fixture, html } from '@open-wc/testing';
15+
import { spy } from 'sinon';
1516

1617
describe('Status Light', () => {
1718
it('loads correctly', async () => {
@@ -41,4 +42,41 @@ describe('Status Light', () => {
4142
expect(el.hasAttribute('aria-disabled')).to.be.true;
4243
expect(el.getAttribute('aria-disabled')).to.equal('true');
4344
});
45+
46+
describe('dev mode warnings', () => {
47+
let warningMessage: typeof window.__swc.warn;
48+
49+
beforeEach(() => {
50+
// Create __swc if it doesn't exist
51+
window.__swc = window.__swc || { warn: () => {} };
52+
// Store original warn function
53+
warningMessage = window.__swc.warn;
54+
// Reset issued warnings to avoid dedupe interference
55+
window.__swc.issuedWarnings = new Set();
56+
// Enable debug guard
57+
window.__swc.DEBUG = true;
58+
});
59+
60+
afterEach(() => {
61+
// Restore original warn function
62+
window.__swc.warn = warningMessage;
63+
});
64+
65+
it('warns when unsupported variant is used (brown)', async () => {
66+
const warnSpy = spy();
67+
window.__swc.warn = warnSpy as unknown as typeof window.__swc.warn;
68+
69+
const el = await fixture<StatusLight>(html`
70+
<sp-status-light variant="brown"></sp-status-light>
71+
`);
72+
73+
await elementUpdated(el);
74+
75+
expect(warnSpy.called).to.be.true;
76+
expect(warnSpy.firstCall.args[0]).to.equal(el);
77+
expect(warnSpy.firstCall.args[1]).to.equal(
78+
`<${el.localName}> element expects the "variant" attribute to be one of the following:`
79+
);
80+
});
81+
});
4482
});

0 commit comments

Comments
 (0)