Skip to content

Commit

Permalink
chore: update tests for theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajdeep Chandra authored and Rajdeep Chandra committed May 13, 2024
1 parent 2c5c4a6 commit 33c5c24
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
1 change: 0 additions & 1 deletion tools/theme/src/spectrum-two/theme.css
Expand Up @@ -10,7 +10,6 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

/* @import url('@spectrum-web-components/styles/core-global.css'); */
@import url('@spectrum-web-components/styles/tokens-v2/global-vars.css');
@import url('@spectrum-web-components/styles/tokens-v2/spectrum/global-vars.css');
@import url('@spectrum-web-components/styles/tokens-v2/spectrum/custom-vars.css');
Expand Down
23 changes: 15 additions & 8 deletions tools/theme/test/theme-devmode.test.ts
Expand Up @@ -16,8 +16,18 @@ import { elementUpdated, expect, fixture, html } from '@open-wc/testing';
import { stub } from 'sinon';

describe('Dev mode', () => {
window.__swc.verbose = true;
const consoleWarnStub = stub(console, 'warn');
let consoleWarnStub!: ReturnType<typeof stub>;
before(() => {
window.__swc.verbose = true;
consoleWarnStub = stub(console, 'warn');
});
afterEach(() => {
consoleWarnStub.resetHistory();
});
after(() => {
window.__swc.verbose = false;
consoleWarnStub.restore();
});

it('warns in Dev Mode when no attributes or fragments', async () => {
const el = await fixture<Theme>(html`
Expand All @@ -29,7 +39,7 @@ describe('Dev mode', () => {
expect(consoleWarnStub.called).to.be.true;
const spyCall = consoleWarnStub.getCall(0);
expect(
spyCall.args.at(0).includes('theme delivery'),
(spyCall.args.at(0) as string).includes('theme delivery'),
'confirm "theme delivery"-centric message'
).to.be.true;
expect(spyCall.args.at(-1), 'confirm `data` shape').to.deep.equal({
Expand All @@ -39,7 +49,6 @@ describe('Dev mode', () => {
level: 'default',
},
});
consoleWarnStub.reset();
});

it('warns in Dev Mode when you pass a theme attribute', async () => {
Expand All @@ -52,7 +61,7 @@ describe('Dev mode', () => {
expect(consoleWarnStub.called).to.be.true;
const spyCall = consoleWarnStub.getCall(0);
expect(
spyCall.args.at(0).includes('deprecated'),
(spyCall.args.at(0) as string).includes('deprecated'),
'confirm "theme-deprecation"-centric message'
).to.be.true;
expect(spyCall.args.at(-1), 'confirm `data` shape').to.deep.equal({
Expand All @@ -62,7 +71,6 @@ describe('Dev mode', () => {
level: 'deprecation',
},
});
consoleWarnStub.reset();
});

it('warns in Dev Mode when you use Spectrum Two theme ', async () => {
Expand All @@ -79,7 +87,7 @@ describe('Dev mode', () => {
expect(consoleWarnStub.called).to.be.true;
const spyCall = consoleWarnStub.getCall(0);
expect(
spyCall.args.at(0).includes('beta version'),
(spyCall.args.at(0) as string).includes('beta version'),
'confirm "beta-theme"-centric message'
).to.be.true;
expect(spyCall.args.at(-1), 'confirm `data` shape').to.deep.equal({
Expand All @@ -89,6 +97,5 @@ describe('Dev mode', () => {
level: 'high',
},
});
consoleWarnStub.reset();
});
});

0 comments on commit 33c5c24

Please sign in to comment.