Skip to content
Snippets Groups Projects
Commit 2f1ed9c6 authored by Reinder Kraaij's avatar Reinder Kraaij :eye:
Browse files

add jest to env for babel

parent f5317959
No related branches found
No related tags found
1 merge request!1188TMSS-2810 "Multiple TMSS FrontEnd Unit tests Fixed"
module.exports = { module.exports = {
"env": { "env": {
"browser": true, "browser": true,
"es2021": true "es2021": true,
"node": true,
"jasmine": true,
"jest": true,
"es6": true
},
}, },
"extends": ["eslint:recommended", "plugin:react/recommended"], "extends": ["eslint:recommended", "plugin:react/recommended"],
"plugins": [ "plugins": [
......
...@@ -5,6 +5,7 @@ import { ...@@ -5,6 +5,7 @@ import {
splitObjectIfSpanIsMultipleDays splitObjectIfSpanIsMultipleDays
} from "./filters.helper"; } from "./filters.helper";
import moment from "moment/moment"; import moment from "moment/moment";
import renderer from 'react-test-renderer';
jest.mock('moment', () => { jest.mock('moment', () => {
const originalMoment = jest.requireActual('moment'); const originalMoment = jest.requireActual('moment');
...@@ -176,7 +177,7 @@ describe("getTimelineItem", () => { ...@@ -176,7 +177,7 @@ describe("getTimelineItem", () => {
const suBlueprint = { const suBlueprint = {
id: "blueprint-id", id: "blueprint-id",
description:"test blueprint", description: "test blueprint",
process_start_time: "2023-07-06T10:00:00Z", process_start_time: "2023-07-06T10:00:00Z",
on_sky_start_time: "2023-07-06T10:00:00Z", on_sky_start_time: "2023-07-06T10:00:00Z",
tasks: tasks, tasks: tasks,
...@@ -188,12 +189,12 @@ describe("getTimelineItem", () => { ...@@ -188,12 +189,12 @@ describe("getTimelineItem", () => {
process_stop_time: "2023-07-06T12:00:00Z", process_stop_time: "2023-07-06T12:00:00Z",
on_sky_stop_time: "2023-07-06T12:00:00Z", on_sky_stop_time: "2023-07-06T12:00:00Z",
real_start_time: "2023-07-06T12:01:00Z", real_start_time: "2023-07-06T12:01:00Z",
real_end_time:"2023-07-06T12:02:00Z", real_end_time: "2023-07-06T12:02:00Z",
placed: true, placed: true,
unschedulable_reason: "none", unschedulable_reason: "none",
scheduling_constraints_doc: { scheduler: "fixed" }, scheduling_constraints_doc: { scheduler: "fixed" },
antenna_set:"antenna_set_value", antenna_set: "antenna_set_value",
scheduler:"fixed" scheduler: "fixed"
}; };
const displayDate = moment("2023-07-06", "YYYY-MM-DD") const displayDate = moment("2023-07-06", "YYYY-MM-DD")
...@@ -205,8 +206,8 @@ describe("getTimelineItem", () => { ...@@ -205,8 +206,8 @@ describe("getTimelineItem", () => {
id: "blueprint-id-27: Jul 06 - Thu", id: "blueprint-id-27: Jul 06 - Thu",
suId: "blueprint-id", suId: "blueprint-id",
group: "27: Jul 06 - Thu", group: "27: Jul 06 - Thu",
band :"antenna", band: "antenna",
desc:"test blueprint", desc: "test blueprint",
title: "", title: "",
project: "bugs", project: "bugs",
name: "the_fix_1", name: "the_fix_1",
...@@ -216,8 +217,8 @@ describe("getTimelineItem", () => { ...@@ -216,8 +217,8 @@ describe("getTimelineItem", () => {
start_time: moment("2023-07-06 10:00:00Z"), start_time: moment("2023-07-06 10:00:00Z"),
end_time: moment("2023-07-06 12:00:00Z"), end_time: moment("2023-07-06 12:00:00Z"),
real_start_time: "2023-07-06T12:01:00Z", real_start_time: "2023-07-06T12:01:00Z",
real_end_time:"2023-07-06T12:02:00Z", real_end_time: "2023-07-06T12:02:00Z",
stations:"-", stations: "-",
type: "SCHEDULE", type: "SCHEDULE",
status: "defined", status: "defined",
scheduler: "fixed", scheduler: "fixed",
...@@ -226,7 +227,7 @@ describe("getTimelineItem", () => { ...@@ -226,7 +227,7 @@ describe("getTimelineItem", () => {
}); });
it("returns the correct item object when antenna set is not provided", () => { it("returns the correct item object when antenna set is not provided", () => {
let suBlueprintWithoutAntennaSet = { let suBlueprintWithoutAntennaSet = {
...suBlueprint, ...suBlueprint,
...@@ -239,14 +240,14 @@ describe("getTimelineItem", () => { ...@@ -239,14 +240,14 @@ describe("getTimelineItem", () => {
} }
] ]
}; };
suBlueprintWithoutAntennaSet.antenna_set=undefined; suBlueprintWithoutAntennaSet.antenna_set = undefined;
const item = getTimelineItem(suBlueprintWithoutAntennaSet, displayDate); const item = getTimelineItem(suBlueprintWithoutAntennaSet, displayDate);
expect(item).toEqual({ expect(item).toEqual({
id: "blueprint-id-27: Jul 06 - Thu", id: "blueprint-id-27: Jul 06 - Thu",
suId: "blueprint-id", suId: "blueprint-id",
band :undefined, band: undefined,
desc:"test blueprint", desc: "test blueprint",
group: "27: Jul 06 - Thu", group: "27: Jul 06 - Thu",
title: "", title: "",
project: "bugs", project: "bugs",
...@@ -254,22 +255,24 @@ describe("getTimelineItem", () => { ...@@ -254,22 +255,24 @@ describe("getTimelineItem", () => {
antenna_set: undefined, antenna_set: undefined,
scheduler: "fixed", scheduler: "fixed",
duration: "1.00Hrs", duration: "1.00Hrs",
stations:"-", stations: "-",
on_sky_duration: "2.00Hrs", on_sky_duration: "2.00Hrs",
start_time: moment("2023-07-06 10:00:00Z"), start_time: moment("2023-07-06 10:00:00Z"),
end_time: moment("2023-07-06 12:00:00Z"), end_time: moment("2023-07-06 12:00:00Z"),
real_start_time: "2023-07-06T12:01:00Z", real_start_time: "2023-07-06T12:01:00Z",
real_end_time:"2023-07-06T12:02:00Z", real_end_time: "2023-07-06T12:02:00Z",
type: "SCHEDULE", type: "SCHEDULE",
status: "defined", status: "defined",
unschedulable_reason: "none" unschedulable_reason: "none"
}); });
}); });
}); });
describe('getReservationItem', () => { describe('getReservationItem', () => {
let reservation = { let reservation = {
id: '1', id: '1',
name: 'green grass', name: 'green grass',
...@@ -289,6 +292,7 @@ describe('getReservationItem', () => { ...@@ -289,6 +292,7 @@ describe('getReservationItem', () => {
description: 'with a grass mower' description: 'with a grass mower'
}; };
let expectedItem = { let expectedItem = {
id: "Res-1-Aug 08 - Tue", id: "Res-1-Aug 08 - Tue",
start_time: moment('2023-08-08 10:00:00'), start_time: moment('2023-08-08 10:00:00'),
...@@ -307,6 +311,7 @@ describe('getReservationItem', () => { ...@@ -307,6 +311,7 @@ describe('getReservationItem', () => {
stations: '-' stations: '-'
}; };
const displayDate = moment('2023-08-08', 'YYYY-MM-DD'); const displayDate = moment('2023-08-08', 'YYYY-MM-DD');
// TODO : Fix Unit Test should return the correct reservation item (no stations) // TODO : Fix Unit Test should return the correct reservation item (no stations)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment