state-dot-styles.client.spec.ts 996 B

1234567891011121314151617181920212223
  1. /**
  2. * StateDot's palette as CSS text. jsdom has no layout and CSS Modules resolve
  3. * to class-name maps in the component suites, so the only place the per-state
  4. * colors can be read is the stylesheet itself: a state whose rule is missing
  5. * renders on the inherited color instead of its own, which no render assertion
  6. * would catch.
  7. */
  8. import { readFileSync } from 'node:fs'
  9. import { fileURLToPath } from 'node:url'
  10. import { describe, expect, it } from 'vitest'
  11. const css = readFileSync(fileURLToPath(new URL('../src/StateDot.module.css', import.meta.url)), 'utf8')
  12. describe('StateDot.module.css', () => {
  13. it.each(['done', 'warning', 'error', 'idle'] as const)('gives the %s state its own color rule', (state) => {
  14. expect(css).toContain(`.dot[data-state='${state}']`)
  15. })
  16. it('keeps ongoing on the animated matrix rather than a solid-dot rule', () => {
  17. expect(css).not.toContain(".dot[data-state='ongoing']")
  18. expect(css).toContain('@keyframes dsh-state-dot-chase')
  19. })
  20. })