Fix failing tests
This commit is contained in:
@@ -1,13 +1,8 @@
|
||||
import { describe, it, expect, beforeEach, afterEach } from "bun:test";
|
||||
import { describe, it, expect, afterEach } from "bun:test";
|
||||
import isDevelopment from "../../utils/is-development";
|
||||
|
||||
const originalEnv = process.env.NODE_ENV;
|
||||
|
||||
beforeEach(() => {
|
||||
// Reset global config before each test
|
||||
(global as any).CONFIG = {};
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
process.env.NODE_ENV = originalEnv;
|
||||
});
|
||||
@@ -15,25 +10,21 @@ afterEach(() => {
|
||||
describe("isDevelopment", () => {
|
||||
it("returns false when NODE_ENV is production", () => {
|
||||
process.env.NODE_ENV = "production";
|
||||
(global as any).CONFIG = { development: true };
|
||||
expect(isDevelopment()).toBe(false);
|
||||
});
|
||||
|
||||
it("returns true when config.development is true and NODE_ENV is not production", () => {
|
||||
it("returns true when NODE_ENV is development", () => {
|
||||
process.env.NODE_ENV = "development";
|
||||
(global as any).CONFIG = { development: true };
|
||||
expect(isDevelopment()).toBe(true);
|
||||
});
|
||||
|
||||
it("returns false when config.development is false", () => {
|
||||
process.env.NODE_ENV = "development";
|
||||
(global as any).CONFIG = { development: false };
|
||||
expect(isDevelopment()).toBe(false);
|
||||
it("returns true when NODE_ENV is unset", () => {
|
||||
delete process.env.NODE_ENV;
|
||||
expect(isDevelopment()).toBe(true);
|
||||
});
|
||||
|
||||
it("returns false when config.development is undefined", () => {
|
||||
process.env.NODE_ENV = "development";
|
||||
(global as any).CONFIG = {};
|
||||
expect(isDevelopment()).toBe(false);
|
||||
it("returns true for any other NODE_ENV value", () => {
|
||||
process.env.NODE_ENV = "test";
|
||||
expect(isDevelopment()).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user