@7365admin1/module-hygiene 4.29.1-staging.13 → 4.29.1-staging.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.changeset/area-import-unit-ids.md +5 -0
- package/dist/index.js +271 -265
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +271 -265
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/test/area-import-unit-id.test.mjs +18 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@7365admin1/module-hygiene",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "4.29.1-staging.
|
|
4
|
+
"version": "4.29.1-staging.14",
|
|
5
5
|
"author": "7365admin1",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.mjs",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
14
14
|
"release": "yarn run build && changeset publish",
|
|
15
15
|
"lint": "tsc",
|
|
16
|
-
"test": "tsup src/utils/hygiene-dashboard-metrics.util.ts src/utils/hygiene-checkout-decision.util.ts src/utils/completion-photo.util.ts --format esm --out-dir test/.build --no-dts --silent && node --test \"test/*.test.mjs\""
|
|
16
|
+
"test": "tsup src/utils/hygiene-dashboard-metrics.util.ts src/utils/hygiene-checkout-decision.util.ts src/utils/completion-photo.util.ts src/utils/area-unit.util.ts --format esm --out-dir test/.build --no-dts --silent && node --test \"test/*.test.mjs\""
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@changesets/cli": "^2.26.0",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { ObjectId } from "mongodb";
|
|
4
|
+
import { areaUnitSchema, toAreaUnit } from "./.build/area-unit.util.mjs";
|
|
5
|
+
|
|
6
|
+
// The area import found (or created) each unit and passed its ObjectId to the
|
|
7
|
+
// area schema, which only takes a hex string - so every imported area that
|
|
8
|
+
// listed units was refused. toAreaUnit gives the schema what it takes, and the
|
|
9
|
+
// area model validates units with this same areaUnitSchema.
|
|
10
|
+
test("an imported area's units pass the area's unit schema", () => {
|
|
11
|
+
const found = [{ _id: new ObjectId(), name: "Toilet Bowl" }, { _id: new ObjectId().toString(), name: "Sink" }];
|
|
12
|
+
for (const unit of found) assert.equal(areaUnitSchema.validate(toAreaUnit(unit)).error, undefined);
|
|
13
|
+
assert.deepEqual(found.map(toAreaUnit).map((u) => u.unit), found.map((f) => String(f._id)));
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test("the ObjectId the import used to pass is what the schema refused", () => {
|
|
17
|
+
assert.match(String(areaUnitSchema.validate({ unit: new ObjectId(), name: "Floor" }).error?.message), /must be a string/);
|
|
18
|
+
});
|