From 09253466f7d20ccd4896cd5c918cf777e8644a63 Mon Sep 17 00:00:00 2001 From: meerkat Date: Wed, 28 Dec 2022 14:05:21 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E8=A1=A5=E5=85=85=20Tree=20source=20?= =?UTF-8?q?=E5=8D=95=E6=B5=8B=20(#5983)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../amis/__tests__/renderers/Tree.test.tsx | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/packages/amis/__tests__/renderers/Tree.test.tsx b/packages/amis/__tests__/renderers/Tree.test.tsx index 1419bbc03..92d3cd87c 100644 --- a/packages/amis/__tests__/renderers/Tree.test.tsx +++ b/packages/amis/__tests__/renderers/Tree.test.tsx @@ -246,3 +246,48 @@ test('Tree: cascade = true', () => { expect(container.querySelectorAll('.is-checked').length).toBe(4); }); + +test('Tree source', async () => { + const fetcher = jest.fn().mockImplementation(() => { + return Promise.resolve({ + status: 0, + msg: 'ok', + data: { + options: [ + {label: 'Option A', value: 'a'}, + {label: 'Option B', value: 'b'}, + {label: 'Option C', value: 'c'}, + {label: 'Option D', value: 'd'}, + {label: 'Option E', value: 'e'}, + {label: 'Option F', value: 'f'}, + {label: 'Option G', value: 'g'}, + {label: 'Option H', value: 'h'}, + {label: 'Option I', value: 'i'}, + {label: 'Option J', value: 'j'}, + {label: 'Option K', value: 'k'}, + {label: 'Option L', value: 'l'}, + {label: 'Option M', value: 'm'}, + {label: 'Option N', value: 'n'}, + {label: 'Option O', value: 'o'}, + {label: 'Option P', value: 'p'}, + {label: 'Option Q', value: 'q'} + ] + } + }); + }); + + const {getByText} = render( + amisRender( + { + type: 'input-tree', + name: 'tree', + label: 'Tree', + source: '/api' + }, + {}, + makeEnv({fetcher}) + ) + ); + + await waitFor(() => getByText('Option A')); +});