diff --git a/packages/astro-ghostcms/src/api/invariant.test.ts b/packages/astro-ghostcms/src/api/invariant.test.ts index 6473c384..c6eb1224 100644 --- a/packages/astro-ghostcms/src/api/invariant.test.ts +++ b/packages/astro-ghostcms/src/api/invariant.test.ts @@ -1,36 +1,34 @@ import { describe, expect, it } from "vitest"; +// Modified version of invariant script to allow tests const isProduction= false; const prefix: string = 'Invariant failed'; - -const testTrue = true; -const testFalse = false; - -function invariant( - // biome-ignore lint/suspicious/noExplicitAny: we know what we are doing -condition: any, - message?: string | (() => string), -) { +function invariant( // biome-ignore lint/suspicious/noExplicitAny: we know what we are doing +condition: any, message?: string | (() => string), ) { if (condition) { return; } if (isProduction) { throw new Error(prefix); } - const provided: string | undefined = typeof message === 'function' ? message() : message; - const value: string = provided ? `${prefix}: ${provided}` : prefix; return value; } +// TEST SECTION +const testTrue = true; +const testFalse = false; describe('test invariant', () => { - it('Test `true` value', () => { - invariant(testTrue, "This should not error") - expect(null) - }) - it('Test `false` value', () => { - invariant(testFalse, "This should Error") - expect(String("Invariant failed")) - }) + + it('Test `true` value', () => { + invariant(testTrue, "This should not error") + expect(null) + }) + + it('Test `false` value', () => { + invariant(testFalse, "This should Error") + expect(String("Invariant failed")) + }) + }) \ No newline at end of file