Download desktop/src/stores/uiStore.test.ts from chenbhao/codev: direct link, hf CLI and curl.
- Browser
- Download file 1.74 kB
-
https://huggingface.co/chenbhao/codev/resolve/e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/stores/uiStore.test.ts
- Command line
-
hf download hf://chenbhao/codev@e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/stores/uiStore.test.ts
-
curl -L -o uiStore.test.ts https://huggingface.co/chenbhao/codev/resolve/e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/stores/uiStore.test.ts
1.74 kB
| import { beforeEach, describe, expect, it, vi } from 'vitest' | |
| describe('uiStore theme handling', () => { | |
| beforeEach(() => { | |
| vi.resetModules() | |
| window.localStorage.clear() | |
| document.documentElement.removeAttribute('data-theme') | |
| document.documentElement.style.colorScheme = '' | |
| }) | |
| it('defaults new installs to the pure white theme', async () => { | |
| const { initializeTheme, useUIStore } = await import('./uiStore') | |
| expect(useUIStore.getState().theme).toBe('white') | |
| initializeTheme() | |
| expect(document.documentElement.getAttribute('data-theme')).toBe('white') | |
| expect(document.documentElement.style.colorScheme).toBe('light') | |
| }) | |
| it('hydrates and applies the pure white theme as a light color scheme', async () => { | |
| window.localStorage.setItem('cc-haha-theme', 'white') | |
| const { initializeTheme, useUIStore } = await import('./uiStore') | |
| expect(useUIStore.getState().theme).toBe('white') | |
| initializeTheme() | |
| expect(document.documentElement.getAttribute('data-theme')).toBe('white') | |
| expect(document.documentElement.style.colorScheme).toBe('light') | |
| }) | |
| it('cycles through pure white, warm classic, and dark themes', async () => { | |
| const { useUIStore } = await import('./uiStore') | |
| useUIStore.getState().toggleTheme() | |
| expect(useUIStore.getState().theme).toBe('light') | |
| expect(document.documentElement.style.colorScheme).toBe('light') | |
| useUIStore.getState().toggleTheme() | |
| expect(useUIStore.getState().theme).toBe('dark') | |
| expect(document.documentElement.style.colorScheme).toBe('dark') | |
| useUIStore.getState().toggleTheme() | |
| expect(useUIStore.getState().theme).toBe('white') | |
| expect(document.documentElement.style.colorScheme).toBe('light') | |
| }) | |
| }) | |