From b97f089bacb830febaf5c2707e9815a1c727e68b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E6=A0=91=E4=BA=BA?= Date: Mon, 5 Jun 2023 00:04:33 +0100 Subject: [PATCH] test: added test for enumObject. --- src/util/__tests__/enumObject.test.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/util/__tests__/enumObject.test.ts diff --git a/src/util/__tests__/enumObject.test.ts b/src/util/__tests__/enumObject.test.ts new file mode 100644 index 0000000..64ab335 --- /dev/null +++ b/src/util/__tests__/enumObject.test.ts @@ -0,0 +1,24 @@ +import { enumObject } from '../objects'; + +test('it should ignore and not crash with non-object', () => { + expect(Array.from(enumObject('string' as never))).toEqual([]); +}); + +test('it should ignore and not crash with null', () => { + expect(Array.from(enumObject(null))).toEqual([]); +}); + +test('it be able to iterate object', () => { + expect(Array.from(enumObject({ a: '1', b: '2' }))).toMatchInlineSnapshot(` + [ + [ + "a", + "1", + ], + [ + "b", + "2", + ], + ] + `); +});