fix: Enhancement: Add test case for null containerId validation in cargo m… (#66679)

This commit is contained in:
Shikhar Yadav
2026-03-30 16:06:50 +05:30
committed by GitHub
parent f4bd4781e8
commit 508aaf22ec

View File

@@ -262,6 +262,7 @@ Calling `validateManifest()` with `{}` should return the new object `{ container
```js
const testObj = {
};
const expected = {
@@ -279,6 +280,27 @@ assert.notStrictEqual(copy, testObj, "validateManifest() should return a new obj
assert.equal(Object.keys(testObj).length, 0, "validateManifest() should return a new object, not mutate the original")
```
Calling `validateManifest()` with `{ containerId: null, destination: "Santa Cruz", weight: 304, unit: "kg", hazmat: false }` should return the new object `{ containerId: "Invalid" }` without mutating the source input.
```js
const testObj = {
containerId: null,
destination: "Santa Cruz",
weight: 304,
unit: "kg",
hazmat: false
};
const expected = {
containerId: "Invalid"
};
const copy = validateManifest(testObj);
assert.isObject(copy);
assert.deepEqual(copy, expected, "validateManifest() did not return the expected object for null containerId");
assert.notStrictEqual(copy, testObj, "validateManifest() should return a new object, not mutate the original");
```
Calling `validateManifest()` with `{ containerId: 0, destination: 405, weight: -84, unit: "pounds", hazmat: "no" }` should return the new object `{ containerId: "Invalid", destination: "Invalid", weight: "Invalid", unit: "Invalid", hazmat: "Invalid" }` without mutating the source input.
```js