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
andreas-unleash f3b11b89bb
Feat: last seen by env UI (#4439)
Implements last seen by environment UI


Closes #
[1-1182](https://linear.app/unleash/issue/1-1182/ui-for-last-seen-per-environment)

![Screenshot 2023-08-08 at 10 30
56](https://github.com/Unleash/unleash/assets/104830839/b70bf63e-8e58-4678-9be4-0fe40c873d29)
![Screenshot 2023-08-08 at 10 31
24](https://github.com/Unleash/unleash/assets/104830839/4ec74030-9425-4254-ad02-b8101e131774)

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
2023-08-08 12:32:33 +03:00

48 lines
1.2 KiB
TypeScript

import { 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);
});