Skip to content

Commit

Permalink
(chore) fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
thehighestprimenumber committed Sep 6, 2024
1 parent 27ba6d6 commit 029edb0
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/tests/api/activity_value.jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ describe("Activity Value API", () => {
if (db.sequelize) await db.sequelize.close();
});

it("should not create an activity value with invalid data", async () => {
it.skip("should not create an activity value with invalid data", async () => {
const req = mockRequest(invalidCreateActivity);
const res = await createActivityValue(req, {
params: { inventory: inventory.inventoryId },
Expand Down
48 changes: 48 additions & 0 deletions app/tests/api/activity_value.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,44 @@ const updatedActivityValue: CreateActivityValueRequest = {
],
};

const invalidCreateActivity: CreateActivityValueRequest = {
activityData: {
"form-test-input1": 40.4,
"form-test-input2": "132894729485739867398473321",
"form-test-input3": "agriculture-forestry",
},
metadata: {
"active-selection": "test1",
},
dataSource: {
sourceType: "",
dataQuality: "high",
notes: "Some notes regarding the data source",
},
gasValues: [
{
id: "123e4567-e89b-12d3-a456-426614174001",
gas: "CO2",
gasAmount: 1000n,
emissionsFactor: {
emissionsPerActivity: 50.5,
gas: "CO2",
units: "kg",
},
},
{
id: "123e4567-e89b-12d3-a456-426614174003",
gas: "CH4",
gasAmount: 2000n,
emissionsFactor: {
emissionsPerActivity: 25.0,
gas: "CH4",
units: "kg",
},
},
],
};

const activityUnits = "UNITS";
const activityValue = 1000;
const co2eq = 44000n;
Expand Down Expand Up @@ -255,6 +293,16 @@ describe("Activity Value API", () => {
if (db.sequelize) await db.sequelize.close();
});

it("should not create an activity value with invalid data", async () => {
const req = mockRequest(invalidCreateActivity);
const res = await createActivityValue(req, {
params: {
inventory: inventory.inventoryId,
},
});
assert.equal(res.status, 400);
});

it("should create an activity, creating an inventory value with inventoryValue params", async () => {
const findInventory = await db.models.Inventory.findOne({
where: {
Expand Down

0 comments on commit 029edb0

Please sign in to comment.