Files
supabase/apps/studio/lib/isNonNullable.test.ts
Drake Costa ca4b3bc624 Refactor Storage Create/Edit/Empty/Delete Modals to use Shadcn components (#37517)
* Refactor `StorageMenu` modals to replace deprecated patterns

* add test for `DeleteBucketModal` and update test setup

Note: Because this component uses `useParams`, it's necessary to have the dynamic route segment passed to `next-router-mock`'s `createDynamicRouteParser`. In order not to have to manually list all of these as the application grows, I added a glob utility that uses the `pages/` directory  to automatically generate an array of dynamic route paths in this case.

* add test for `EmptyBucketModal`

* add test for `EditBucketModal` and add `isNonNullable` utility function

* add test for `CreateBucketModal`

* implement requested changes

* implement visual fixes
2025-08-14 21:23:08 +02:00

27 lines
576 B
TypeScript

import { describe, it, expect } from 'vitest'
import { isNonNullable } from './isNonNullable.js'
describe(`isNonNullable`, () => {
it.each([
[null, false],
[undefined, false],
// void
[(() => {})(), false],
// Truthy
[`string`, true],
[1, true],
[true, true],
// Falsy
[``, true],
[NaN, true],
[0, true],
[0, true],
[false, true],
// Type coercion
[[], true],
[{}, true],
])(`correctly matches against nullish values`, (val, expected) => {
expect(isNonNullable(val)).toStrictEqual(expected)
})
})