From db6bbad60885fe076674a09e1e4270daa0cb8118 Mon Sep 17 00:00:00 2001 From: wuxh Date: Thu, 7 Mar 2024 13:30:52 +0800 Subject: [PATCH] test: add unit test --- tests/__snapshots__/export.test.tsx.snap | 21 ++++++++++++++++ tests/export.test.tsx | 32 ++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 tests/__snapshots__/export.test.tsx.snap create mode 100644 tests/export.test.tsx diff --git a/tests/__snapshots__/export.test.tsx.snap b/tests/__snapshots__/export.test.tsx.snap new file mode 100644 index 0000000..b21e529 --- /dev/null +++ b/tests/__snapshots__/export.test.tsx.snap @@ -0,0 +1,21 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`export > should work 1`] = ` +[ + "useBoolean", + "useLatestFunc", + "useModalEnhanced", + "has", + "omit", + "isElement", + "isDOMTypeElement", + "AntdMobile", + "DragModal", + "Drawer", + "EasyAntdModalProvider", + "Modal", + "useEasyAntdModal", + "default", + "Antd", +] +`; diff --git a/tests/export.test.tsx b/tests/export.test.tsx new file mode 100644 index 0000000..e7b9b70 --- /dev/null +++ b/tests/export.test.tsx @@ -0,0 +1,32 @@ +describe('export', () => { + it('should work', async () => { + const all = await import('easy-antd-modal'); + + expect(Object.keys(all)).toMatchSnapshot(); + }); + + it('should export all hooks', async () => { + const hooks = await import('easy-antd-modal/hooks'); + + expect(Object.keys(hooks)).toMatchInlineSnapshot(` + [ + "useBoolean", + "useLatestFunc", + "useModalEnhanced", + ] + `); + }); + + it('should export all utils', async () => { + const types = await import('easy-antd-modal/util'); + + expect(Object.keys(types)).toMatchInlineSnapshot(` + [ + "has", + "omit", + "isElement", + "isDOMTypeElement", + ] + `); + }); +});