1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-06 00:07:44 +01:00
unleash.unleash/frontend/src/component/project/ProjectEnvironment/getEnabledEnvs.test.ts
Christopher Kolstad 53354224fc
chore: Bump biome and configure husky (#6589)
Upgrades biome to 1.6.1, and updates husky pre-commit hook.

Most changes here are making type imports explicit.
2024-03-18 13:58:05 +01:00

48 lines
1.2 KiB
TypeScript

import type { IProjectEnvironment } from 'interfaces/environments';
import { getEnabledEnvs } from './helpers';
const generateEnv = (enabled: boolean, name: string): IProjectEnvironment => {
return {
name,
type: 'development',
createdAt: new Date().toISOString(),
lastSeenAt: new Date().toISOString(),
sortOrder: 0,
protected: false,
enabled,
};
};
test('it returns 1 when one environment is enabled', () => {
const input = [
generateEnv(true, 'test1'),
generateEnv(false, 'test2'),
generateEnv(false, 'test3'),
];
const enabledEnvs = getEnabledEnvs(input);
expect(enabledEnvs).toBe(1);
});
test('it returns 3 when three environments are enabled', () => {
const input = [
generateEnv(true, 'test1'),
generateEnv(true, 'test2'),
generateEnv(true, 'test3'),
];
const enabledEnvs = getEnabledEnvs(input);
expect(enabledEnvs).toBe(3);
});
test('it returns 2 when tw environments are enabled', () => {
const input = [
generateEnv(true, 'test1'),
generateEnv(true, 'test2'),
generateEnv(false, 'test3'),
];
const enabledEnvs = getEnabledEnvs(input);
expect(enabledEnvs).toBe(2);
});