mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-28 00:06:53 +01:00
67 lines
1.8 KiB
TypeScript
67 lines
1.8 KiB
TypeScript
|
import { getHighestChangeRequestEnv } from './useHighestPermissionChangeRequestEnvironment';
|
||
|
|
||
|
describe('Get the right change request env', () => {
|
||
|
it('gets a production env if present', () => {
|
||
|
const data = [
|
||
|
{
|
||
|
environment: 'x',
|
||
|
type: 'development',
|
||
|
changeRequestEnabled: true,
|
||
|
requiredApprovals: 1,
|
||
|
},
|
||
|
{
|
||
|
environment: 'y',
|
||
|
type: 'production',
|
||
|
changeRequestEnabled: true,
|
||
|
requiredApprovals: 1,
|
||
|
},
|
||
|
];
|
||
|
|
||
|
const result = getHighestChangeRequestEnv(data)();
|
||
|
|
||
|
expect(result).toBe('y');
|
||
|
});
|
||
|
|
||
|
it('gets a non-production env if no production envs have change requests enabled', () => {
|
||
|
const data = [
|
||
|
{
|
||
|
environment: 'x',
|
||
|
type: 'development',
|
||
|
changeRequestEnabled: true,
|
||
|
requiredApprovals: 1,
|
||
|
},
|
||
|
{
|
||
|
environment: 'y',
|
||
|
type: 'production',
|
||
|
changeRequestEnabled: false,
|
||
|
requiredApprovals: 1,
|
||
|
},
|
||
|
];
|
||
|
|
||
|
const result = getHighestChangeRequestEnv(data)();
|
||
|
|
||
|
expect(result).toBe('x');
|
||
|
});
|
||
|
|
||
|
it('returns undefined if no envs have change requests enabled', () => {
|
||
|
const data = [
|
||
|
{
|
||
|
environment: 'x',
|
||
|
type: 'development',
|
||
|
changeRequestEnabled: false,
|
||
|
requiredApprovals: 1,
|
||
|
},
|
||
|
{
|
||
|
environment: 'y',
|
||
|
type: 'production',
|
||
|
changeRequestEnabled: false,
|
||
|
requiredApprovals: 1,
|
||
|
},
|
||
|
];
|
||
|
|
||
|
const result = getHighestChangeRequestEnv(data)();
|
||
|
|
||
|
expect(result).toBe(undefined);
|
||
|
});
|
||
|
});
|