From cf1473cde7f765308fd8a4806604ad24ef94bbea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=A0=E4=B8=8B=20=E5=85=8B=E5=BD=A6?= Date: Tue, 16 Jul 2024 20:48:38 +0900 Subject: [PATCH] remove test cases for optional.appendTo --- tests/focus-setter.spec.tsx | 51 +------------------------------------ 1 file changed, 1 insertion(+), 50 deletions(-) diff --git a/tests/focus-setter.spec.tsx b/tests/focus-setter.spec.tsx index 926c7a2..6fe94b4 100644 --- a/tests/focus-setter.spec.tsx +++ b/tests/focus-setter.spec.tsx @@ -1,13 +1,11 @@ import { afterEach, test } from 'vitest'; import { StrictMode, Suspense } from 'react'; import { cleanup, fireEvent, render } from '@testing-library/react'; -import { expectType } from 'ts-expect'; import { useAtom } from 'jotai/react'; import { atom } from 'jotai/vanilla'; -import type { SetStateAction, WritableAtom } from 'jotai/vanilla'; +import type { SetStateAction } from 'jotai/vanilla'; import * as O from 'optics-ts'; import { focusAtom } from 'jotai-optics'; -import type { NotAnArrayType } from 'node_modules/optics-ts/utils.js'; import { useSetAtom } from 'jotai'; afterEach(cleanup); @@ -145,50 +143,3 @@ test('focus on async atom works', async () => { await findByText('baseAtom: [0,1,2,3]'); await findByText('asyncAtom: [0,1,2,3]'); }); - -type BillingData = { - id: string; -}; - -type CustomerData = { - id: string; - billing: BillingData[]; - someOtherData: string; -}; - -test('typescript should accept "undefined" as valid value for lens', async () => { - const customerListAtom = atom([]); - - const foundCustomerAtom = focusAtom(customerListAtom, (optic) => - optic.find((el) => el.id === 'some-invalid-id'), - ); - - const derivedLens = focusAtom(foundCustomerAtom, (optic) => optic.appendTo()); - - expectType< - WritableAtom], void> - >(derivedLens); -}); - -test('should work with promise based atoms with "undefined" value', async () => { - const customerBaseAtom = atom(undefined); - - const asyncCustomerDataAtom = atom( - async (get) => get(customerBaseAtom), - async (_, set, nextValue: Promise) => { - set(customerBaseAtom, await nextValue); - }, - ); - - const focusedPromiseAtom = focusAtom(asyncCustomerDataAtom, (optic) => - optic.appendTo(), - ); - - expectType< - WritableAtom< - Promise, - [NotAnArrayType], - Promise - > - >(focusedPromiseAtom); -});