mirror of
https://github.com/Unleash/unleash.git
synced 2025-08-23 13:46:45 +02:00
fix tests
This commit is contained in:
parent
9336801e87
commit
bd4ebebf65
@ -111,60 +111,63 @@ test('returns success for stages other than Rejected in Rejected state', () => {
|
|||||||
|
|
||||||
describe('changeRequestScheduleProps', () => {
|
describe('changeRequestScheduleProps', () => {
|
||||||
test('returns correct props for a pending schedule', () => {
|
test('returns correct props for a pending schedule', () => {
|
||||||
|
const date = new Date();
|
||||||
const schedule = {
|
const schedule = {
|
||||||
scheduledAt: new Date().toISOString(),
|
scheduledAt: date.toISOString(),
|
||||||
status: 'pending' as const,
|
status: 'pending' as const,
|
||||||
};
|
};
|
||||||
|
|
||||||
const time = 'some time string';
|
const { title, subtitle, color, reason } = getScheduleProps(schedule);
|
||||||
|
|
||||||
const { title, subtitle, color, reason } = getScheduleProps(
|
|
||||||
schedule,
|
|
||||||
time,
|
|
||||||
);
|
|
||||||
expect(title).toBe('Scheduled');
|
expect(title).toBe('Scheduled');
|
||||||
expect(subtitle).toBe(`for ${time}`);
|
|
||||||
expect(color).toBe('warning');
|
expect(color).toBe('warning');
|
||||||
expect(reason).toBeNull();
|
expect(reason).toBeNull();
|
||||||
|
|
||||||
|
render(subtitle);
|
||||||
|
screen.getByText('for');
|
||||||
|
const timeElement = screen.getByRole('time');
|
||||||
|
const datetime = timeElement.getAttribute('datetime');
|
||||||
|
expect(new Date(datetime || 1)).toEqual(date);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns correct props for a failed schedule', () => {
|
test('returns correct props for a failed schedule', () => {
|
||||||
|
const date = new Date();
|
||||||
const schedule = {
|
const schedule = {
|
||||||
scheduledAt: new Date().toISOString(),
|
scheduledAt: date.toISOString(),
|
||||||
status: 'failed' as const,
|
status: 'failed' as const,
|
||||||
reason: 'reason',
|
reason: 'reason',
|
||||||
failureReason: 'failure reason',
|
failureReason: 'failure reason',
|
||||||
};
|
};
|
||||||
|
|
||||||
const time = 'some time string';
|
const { title, subtitle, color, reason } = getScheduleProps(schedule);
|
||||||
|
|
||||||
const { title, subtitle, color, reason } = getScheduleProps(
|
|
||||||
schedule,
|
|
||||||
time,
|
|
||||||
);
|
|
||||||
expect(title).toBe('Schedule failed');
|
expect(title).toBe('Schedule failed');
|
||||||
expect(subtitle).toBe(`at ${time}`);
|
|
||||||
expect(color).toBe('error');
|
expect(color).toBe('error');
|
||||||
expect(reason).toBeTruthy();
|
expect(reason).toBeTruthy();
|
||||||
|
|
||||||
|
render(subtitle);
|
||||||
|
screen.getByText('at');
|
||||||
|
const timeElement = screen.getByRole('time');
|
||||||
|
const datetime = timeElement.getAttribute('datetime');
|
||||||
|
expect(new Date(datetime || 1)).toEqual(date);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns correct props for a suspended schedule', () => {
|
test('returns correct props for a suspended schedule', () => {
|
||||||
|
const date = new Date();
|
||||||
const schedule = {
|
const schedule = {
|
||||||
scheduledAt: new Date().toISOString(),
|
scheduledAt: date.toISOString(),
|
||||||
status: 'suspended' as const,
|
status: 'suspended' as const,
|
||||||
reason: 'reason',
|
reason: 'reason',
|
||||||
};
|
};
|
||||||
|
|
||||||
const time = 'some time string';
|
const { title, subtitle, color, reason } = getScheduleProps(schedule);
|
||||||
|
|
||||||
const { title, subtitle, color, reason } = getScheduleProps(
|
|
||||||
schedule,
|
|
||||||
time,
|
|
||||||
);
|
|
||||||
expect(title).toBe('Schedule suspended');
|
expect(title).toBe('Schedule suspended');
|
||||||
expect(subtitle).toBe(`was ${time}`);
|
|
||||||
expect(color).toBe('grey');
|
expect(color).toBe('grey');
|
||||||
expect(reason).toBeTruthy();
|
expect(reason).toBeTruthy();
|
||||||
|
|
||||||
|
render(subtitle);
|
||||||
|
screen.getByText('was');
|
||||||
|
const timeElement = screen.getByRole('time');
|
||||||
|
const datetime = timeElement.getAttribute('datetime');
|
||||||
|
expect(new Date(datetime || 1)).toEqual(date);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user