xunit.ts 1.0.1 → 1.0.2
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.
|
@@ -22,7 +22,7 @@ function InstanceOf(type, expression, message) {
|
|
|
22
22
|
}
|
|
23
23
|
throw new assert_1.AssertionError({
|
|
24
24
|
message: message || `Expected expression of type, but was ${typeof expression}`,
|
|
25
|
-
expected: type,
|
|
25
|
+
expected: type.name,
|
|
26
26
|
actual: typeof expression
|
|
27
27
|
});
|
|
28
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstanceOf.js","sourceRoot":"","sources":["../../../src/Assertions/InstanceOf.ts"],"names":[],"mappings":";;AAAA,mCAAwC;AAExC;;;;;;;;;;;;;;GAcG;AACH,SAAwB,UAAU,CAAI,IAAS,EAAE,UAAe,EAAE,OAAgB;
|
|
1
|
+
{"version":3,"file":"InstanceOf.js","sourceRoot":"","sources":["../../../src/Assertions/InstanceOf.ts"],"names":[],"mappings":";;AAAA,mCAAwC;AAExC;;;;;;;;;;;;;;GAcG;AACH,SAAwB,UAAU,CAAI,IAAS,EAAE,UAAe,EAAE,OAAgB;IACjF,IAAI,UAAU,YAAY,IAAI,EAAE;QAC/B,OAAO;KACP;IAED,MAAM,IAAI,uBAAc,CAAC;QACxB,OAAO,EAAE,OAAO,IAAI,wCAAwC,OAAO,UAAU,EAAE;QAC/E,QAAQ,EAAE,IAAI,CAAC,IAAI;QACnB,MAAM,EAAE,OAAO,UAAU;KACzB,CAAC,CAAA;AACH,CAAC;AAVD,6BAUC"}
|
package/package.json
CHANGED
|
@@ -2,27 +2,27 @@ import { AssertionError } from "assert";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Asserts that a value is an instance of a certain type
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* @remarks
|
|
7
7
|
* Passes if `object`'s type matches `type`
|
|
8
|
-
*
|
|
9
|
-
* Fails if `object`'s type does not match `type`
|
|
8
|
+
*
|
|
9
|
+
* Fails if `object`'s type does not match `type`
|
|
10
10
|
*
|
|
11
11
|
* @param type the expected type of the value
|
|
12
12
|
* @param expression the value to check
|
|
13
13
|
* @param message (optional) message to display on failure
|
|
14
|
-
*
|
|
14
|
+
*
|
|
15
15
|
* @example
|
|
16
16
|
* this.assert.instanceOf(type, object);
|
|
17
17
|
*/
|
|
18
18
|
export default function InstanceOf<T>(type: any, expression: any, message?: string) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
if (expression instanceof type) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
throw new AssertionError({
|
|
24
|
+
message: message || `Expected expression of type, but was ${typeof expression}`,
|
|
25
|
+
expected: type.name,
|
|
26
|
+
actual: typeof expression
|
|
27
|
+
})
|
|
28
28
|
}
|