Skip to content

Commit 5de790e

Browse files
committed
Add test
1 parent f71b1c0 commit 5de790e

3 files changed

Lines changed: 14 additions & 12 deletions

File tree

packages/react/src/stores/__tests__/theme-store.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'bun-test-env-dom'
33

44
import { describe, expect, it } from 'bun:test'
55

6-
import { createServerThemeStore } from '../theme-store'
6+
import { createServerThemeStore } from '../theme-store-server'
77

88
describe('themeStore ssr', () => {
99
it('should filter mutations by type and target', async () => {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { createThemeStore } from './theme-store'
2+
3+
const serverThemeStore = {
4+
get: () => null,
5+
set: () => {},
6+
subscribe: () => () => {},
7+
}
8+
9+
export function createServerThemeStore(): ReturnType<typeof createThemeStore> {
10+
return serverThemeStore as unknown as ReturnType<typeof createThemeStore>
11+
}

packages/react/src/stores/theme-store.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use client'
22
import type { DevupTheme } from '../types/theme'
3+
import { createServerThemeStore } from './theme-store-server'
34

45
type Theme = keyof DevupTheme | null
56
type StoreChangeEvent = (newTheme: Theme) => void
@@ -39,17 +40,7 @@ function createClientThemeStore() {
3940
}
4041
}
4142

42-
const serverThemeStore: ReturnType<typeof createClientThemeStore> = {
43-
get: () => null,
44-
set: () => {},
45-
subscribe: () => () => {},
46-
} as unknown as ReturnType<typeof createClientThemeStore>
47-
48-
export function createServerThemeStore() {
49-
return serverThemeStore
50-
}
51-
5243
export const createThemeStore: typeof createClientThemeStore =
5344
typeof window === 'undefined'
54-
? createServerThemeStore
45+
? (createServerThemeStore as unknown as typeof createClientThemeStore)
5546
: createClientThemeStore

0 commit comments

Comments
 (0)