From 66bc36336322970c16f663eea0259dd53970621b Mon Sep 17 00:00:00 2001 From: Marlon Huber-Smith Date: Wed, 17 Jan 2024 10:34:20 +0100 Subject: [PATCH] Add skipped test for future improvement to createFacet. --- .../core/src/facet/createFacet.spec.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/@react-facet/core/src/facet/createFacet.spec.ts b/packages/@react-facet/core/src/facet/createFacet.spec.ts index 441da769..4f14db16 100644 --- a/packages/@react-facet/core/src/facet/createFacet.spec.ts +++ b/packages/@react-facet/core/src/facet/createFacet.spec.ts @@ -235,3 +235,24 @@ describe('setWithCallback', () => { expect(listenerMock).not.toHaveBeenCalled() }) }) + +describe('regressions', () => { + it.skip('only calls initial observer once for a facet with an initialValue and a startSubscription', () => { + const value = 'test-value' + const initialValue = 'initial-value' + const cleanup = jest.fn() + const startSubscription = jest.fn().mockImplementation((update) => { + update(value) + return cleanup + }) + + const mock = createFacet({ startSubscription, initialValue }) + + const listener = jest.fn() + + mock.observe(listener) + + expect(listener).toHaveBeenCalledTimes(1) + expect(listener).toHaveBeenLastCalledWith(value) + }) +})