Skip to content

Instantly share code, notes, and snippets.

@bobbyg603
Created December 17, 2022 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bobbyg603/c06130f9c8b0b42e465e255b0a327291 to your computer and use it in GitHub Desktop.
Save bobbyg603/c06130f9c8b0b42e465e255b0a327291 to your computer and use it in GitHub Desktop.
How to Build a Web Component
import { MediumCardBodyElement } from '../src';
import { fixture, assert } from '@open-wc/testing';
import { html } from 'lit/static-html.js';
suite('medium-card-body', () => {
test('is defined', () => {
const el = document.createElement('medium-card-body');
assert.instanceOf(el, MediumCardBodyElement);
});
test('renders with card body with body content', async () => {
const body = '🧍';
const el = await fixture(html`<medium-card-body .body="${body}"></medium-card-body>`);
assert.shadowDom.equal(
el,
body
);
});
test('renders card with color from css variable', async () => {
const color = 'rgb(0, 128, 0)';
const style = `--medium-body-color: ${color}`;
const el = (await fixture(html`<medium-card-body style="${style}"></medium-card-body>`)) as MediumCardBodyElement;
await el.updateComplete;
assert.equal(getComputedStyle(el).color, color);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment