Skip to content

Commit e077f1d

Browse files
committed
chore: added workflow for ci
updated tests to include a minor edge case updated package.json
1 parent 334732c commit e077f1d

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

.github/workflows/ci.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Setup Bun
16+
uses: oven-sh/setup-bun@v2
17+
with:
18+
bun-version: latest
19+
20+
- name: Install dependencies
21+
run: bun install
22+
23+
- name: Run tests
24+
run: bun test
25+
26+
- name: Build
27+
run: bun run build

index.test.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,4 +219,31 @@ describe("quiddity create", () => {
219219

220220
hook.unmount()
221221
})
222+
223+
it("exposes derived functions that read latest state", () => {
224+
const useStore = createStore<{
225+
count: number
226+
inc: () => void
227+
}>(
228+
(set) => ({
229+
count: 2,
230+
inc: () => set((state) => ({ count: state.count + 1 })),
231+
}),
232+
(state) => ({
233+
multBy: (n: number) => state.count * n,
234+
})
235+
)
236+
237+
const hook = renderHook(useStore)
238+
239+
expect(hook.current.multBy(3)).toBe(6)
240+
241+
act(() => {
242+
hook.current.inc()
243+
})
244+
245+
expect(hook.current.multBy(3)).toBe(9)
246+
247+
hook.unmount()
248+
})
222249
})

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
},
77
"version": "0.1.0",
88
"description": "Local-first React state helpers with mutator-style updates.",
9+
"license": "MIT",
910
"main": "./dist/index.cjs",
1011
"module": "./dist/index.js",
1112
"types": "./dist/index.d.ts",
@@ -42,6 +43,7 @@
4243
},
4344
"files": [
4445
"dist",
46+
"LICENSE",
4547
"README.md"
4648
]
4749
}

0 commit comments

Comments
 (0)