Skip to content

Commit

Permalink
test: add tests for angular signals
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnowack committed Dec 4, 2023
1 parent 65a0b28 commit 138da17
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
25 changes: 25 additions & 0 deletions packages/plugin-angular/__tests__/reactivity.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { vi, describe, it, expect } from 'vitest'
import { effect } from '@angular/core'
import { Collection } from 'signaldb'
import angularReactivityAdapter from '../src'

describe('angular', () => {
it('should be reactive with angular signals', () => {
const collection = new Collection({ reactivity: angularReactivityAdapter })
const callback = vi.fn()
const cleanup = vi.fn()

effect((onCleanup) => {
const cursor = collection.find({ name: 'John' })
callback(cursor.count())
onCleanup(() => {
cleanup()
cursor.cleanup()
})
})
collection.insert({ id: '1', name: 'John' })
expect(cleanup).toHaveBeenCalledTimes(1)
expect(callback).toHaveBeenCalledTimes(2)
expect(callback).toHaveBeenLastCalledWith(1)
})
})
1 change: 0 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export default defineConfig({
'commitlint.config.js',
'**/examples/**',
'**/docs/**',
'packages/plugin-angular/src/index.ts', // disabled as it is currently not possible to test angular (see #306)
],
},
reporters: process.env.GITHUB_ACTIONS
Expand Down

0 comments on commit 138da17

Please sign in to comment.