mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-31 18:01:36 -04:00
fix: Enhancement: Add test case for null containerId validation in cargo m… (#66679)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user