Skip to content

Commit 1312c6d

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
test(emcn): assert copy code appearances
1 parent 299cb85 commit 1312c6d

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

‎packages/emcn/src/components/code/copy-code-button.test.tsx‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,33 @@ describe('CopyCodeButton', () => {
1212
'names the icon-only button in the %s appearance',
1313
(appearance) => {
1414
const markup = renderToStaticMarkup(<CopyCodeButton code='example' appearance={appearance} />)
15+
const host = document.createElement('div')
16+
host.innerHTML = markup
17+
const button = host.querySelector('button')
1518

1619
expect(markup).toContain('aria-label="Copy code"')
1720
expect(markup).toContain('type="button"')
21+
expect(button).not.toBeNull()
22+
for (const className of [
23+
'flex',
24+
'items-center',
25+
'gap-1',
26+
'rounded',
27+
'px-1.5',
28+
'py-0.5',
29+
'text-xs',
30+
]) {
31+
expect(button?.classList.contains(className)).toBe(true)
32+
}
33+
34+
const codeHeaderClasses = [
35+
'text-[var(--text-tertiary)]',
36+
'hover-hover:bg-[var(--surface-5)]',
37+
'hover-hover:text-[var(--text-secondary)]',
38+
]
39+
for (const className of codeHeaderClasses) {
40+
expect(button?.classList.contains(className)).toBe(appearance === 'code-header')
41+
}
1842
}
1943
)
2044

0 commit comments

Comments
 (0)