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