Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

signal-proxy.test.ts

28 lines816 Bytes

1import { signal } from '@angular/core'
2import { isReactive } from '@angular/core/primitives/signals'
3import { describe } from 'vitest'
4import { signalProxy } from '../signal-proxy'
5​
6describe('signalProxy', () => {
7 const inputSignal = signal({ fn: () => 'bar', baz: 'qux' })
8 const proxy = signalProxy(inputSignal)
9​
10 it('should have computed fields', () => {
11 expect(proxy.baz()).toEqual('qux')
12 expect(isReactive(proxy.baz)).toBe(true)
13 })
14​
15 it('should pass through functions as-is', () => {
16 expect(proxy.fn()).toEqual('bar')
17 expect(isReactive(proxy.fn)).toBe(false)
18 })
19​
20 it('supports "in" operator', () => {
21 expect('baz' in proxy).toBe(true)
22 expect('foo' in proxy).toBe(false)
23 })
24​
25 it('supports "Object.keys"', () => {
26 expect(Object.keys(proxy)).toEqual(['fn', 'baz'])
27 })
28})