AdithyaSK's picture
AdithyaSK HF Staff
Add files using upload-large-folder tool
29fc4be verified
Raw
History Blame Contribute Delete
2.04 kB
diff --git a/test/types/schema.test.ts b/test/types/schema.test.ts
index fc0204e2a..fc7ae0fa0 100644
--- a/test/types/schema.test.ts
+++ b/test/types/schema.test.ts
@@ -1230,3 +1230,51 @@ async function gh13797() {
expectType<IUser>(this); return '';
} } });
}
+
+function gh13900StringMapOfNumber() {
+ const schema = new Schema({
+ myMap: { type: 'Map', of: Number, required: true }
+ });
+ const Test = model('Test_gh13900_num', schema);
+
+ const doc = new Test({ myMap: { answer: 42 } });
+ expectType<Map<string, number>>(doc.myMap);
+ expectType<number | undefined>(doc.myMap!.get('answer'));
+}
+
+function gh13900StringMapOfString() {
+ const schema = new Schema({
+ myMap: { type: 'Map', of: String, required: true }
+ });
+ const Test = model('Test_gh13900_str', schema);
+
+ const doc = new Test({ myMap: { answer: 'hi' } });
+ expectType<Map<string, string>>(doc.myMap);
+ expectType<string | undefined>(doc.myMap!.get('answer'));
+}
+
+function gh13900StringMapOfMixed() {
+
+ const schema = new Schema({
+ instance: {
+ type: 'Map',
+ of: Schema.Types.Mixed,
+ required: true
+ }
+ });
+ const Test = model('Test_gh13900_mixed', schema);
+
+ const doc = new Test({ instance: { foo: 1 } });
+ expectType<Map<string, any>>(doc.instance);
+}
+
+function gh13900StringMapPreservesConstructorBehavior() {
+
+ const schema = new Schema({
+ myMap: { type: Map, of: Number, required: true }
+ });
+ const Test = model('Test_gh13900_ctor', schema);
+
+ const doc = new Test({ myMap: { x: 1 } });
+ expectType<Map<string, number>>(doc.myMap);
+}
diff --git a/test_commands.json b/test_commands.json
new file mode 100644
index 000000000..0f7dbefd0
--- /dev/null
+++ b/test_commands.json
@@ -0,0 +1,3 @@
+{
+ "test_commands": ["npx tsd"]
+}
diff --git a/mimo_test_command.sh b/mimo_test_command.sh
new file mode 100755
--- /dev/null
+++ b/mimo_test_command.sh
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+
+set -uo pipefail
+cd /testbed
+rc=0
+npx tsd
+rc=$(( rc | $? ))
+exit $rc