Skip to content

Commit cf1473c

Browse files
committed
remove test cases for optional.appendTo
1 parent 5edde72 commit cf1473c

File tree

1 file changed

+1
-50
lines changed

1 file changed

+1
-50
lines changed

tests/focus-setter.spec.tsx

+1-50
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import { afterEach, test } from 'vitest';
22
import { StrictMode, Suspense } from 'react';
33
import { cleanup, fireEvent, render } from '@testing-library/react';
4-
import { expectType } from 'ts-expect';
54
import { useAtom } from 'jotai/react';
65
import { atom } from 'jotai/vanilla';
7-
import type { SetStateAction, WritableAtom } from 'jotai/vanilla';
6+
import type { SetStateAction } from 'jotai/vanilla';
87
import * as O from 'optics-ts';
98
import { focusAtom } from 'jotai-optics';
10-
import type { NotAnArrayType } from 'node_modules/optics-ts/utils.js';
119
import { useSetAtom } from 'jotai';
1210

1311
afterEach(cleanup);
@@ -145,50 +143,3 @@ test('focus on async atom works', async () => {
145143
await findByText('baseAtom: [0,1,2,3]');
146144
await findByText('asyncAtom: [0,1,2,3]');
147145
});
148-
149-
type BillingData = {
150-
id: string;
151-
};
152-
153-
type CustomerData = {
154-
id: string;
155-
billing: BillingData[];
156-
someOtherData: string;
157-
};
158-
159-
test('typescript should accept "undefined" as valid value for lens', async () => {
160-
const customerListAtom = atom<CustomerData[]>([]);
161-
162-
const foundCustomerAtom = focusAtom(customerListAtom, (optic) =>
163-
optic.find((el) => el.id === 'some-invalid-id'),
164-
);
165-
166-
const derivedLens = focusAtom(foundCustomerAtom, (optic) => optic.appendTo());
167-
168-
expectType<
169-
WritableAtom<void, [NotAnArrayType<CustomerData | undefined>], void>
170-
>(derivedLens);
171-
});
172-
173-
test('should work with promise based atoms with "undefined" value', async () => {
174-
const customerBaseAtom = atom<CustomerData | undefined>(undefined);
175-
176-
const asyncCustomerDataAtom = atom(
177-
async (get) => get(customerBaseAtom),
178-
async (_, set, nextValue: Promise<CustomerData>) => {
179-
set(customerBaseAtom, await nextValue);
180-
},
181-
);
182-
183-
const focusedPromiseAtom = focusAtom(asyncCustomerDataAtom, (optic) =>
184-
optic.appendTo(),
185-
);
186-
187-
expectType<
188-
WritableAtom<
189-
Promise<void>,
190-
[NotAnArrayType<CustomerData | undefined>],
191-
Promise<void>
192-
>
193-
>(focusedPromiseAtom);
194-
});

0 commit comments

Comments
 (0)