1
1
package io .scalajs .nodejs
2
2
3
+ import com .thoughtworks .enableIf
3
4
import io .scalajs .nodejs .events .IEventEmitter
4
5
5
6
import scala .scalajs .js
6
7
import scala .scalajs .js .annotation .JSImport
8
+ import scala .scalajs .js .|
7
9
8
10
/**
9
11
* The assert module provides a simple set of assertion tests that can be used to test invariants. The module is
@@ -23,13 +25,7 @@ trait Assert extends IEventEmitter {
23
25
*/
24
26
def apply (expression : js.Any , message : String = js.native): Unit = js.native
25
27
26
- /**
27
- * Tests for deep equality between the actual and expected parameters. Primitive values are compared with the equal
28
- * comparison operator ( == ). Only enumerable "own" properties are considered. The deepEqual() implementation does
29
- * not test object prototypes, attached symbols, or non-enumerable properties. This can lead to some potentially
30
- * surprising results.
31
- * @example assert.deepEqual(actual, expected[, message])
32
- */
28
+ @ deprecated(" Use assert.deepStrictEqual() instead." , " stability 0" )
33
29
def deepEqual (actual : js.Any , expected : js.Any , message : String = js.native): Unit = js.native
34
30
35
31
/**
@@ -39,14 +35,10 @@ trait Assert extends IEventEmitter {
39
35
*/
40
36
def deepStrictEqual (actual : js.Any , expected : js.Any , message : String ): Unit = js.native
41
37
42
- /**
43
- * Asserts that the function block does not throw an error. See assert.throws() for more details.
44
- * When assert.doesNotThrow() is called, it will immediately call the block function. If an error is thrown
45
- * and it is the same type as that specified by the error parameter, then an AssertionError is thrown. If the
46
- * error is of a different type, or if the error parameter is undefined, the error is propagated back to the caller.
47
- * @example assert.doesNotThrow(block[, error][, message])
48
- */
49
- def doesNotThrow (block : js.Function , error : js.Any , message : String ): Unit = js.native
38
+ @ enableIf(io.scalajs.nodejs.CompilerSwitches .gteNodeJs10)
39
+ def doesNotReject (asyncFn : js.Function | js.Promise [_],
40
+ error : js.RegExp | js.Function = js.native,
41
+ message : String = js.native): Unit = js.native
50
42
51
43
/**
52
44
* Asserts that the function block does not throw an error. See assert.throws() for more details.
@@ -55,28 +47,26 @@ trait Assert extends IEventEmitter {
55
47
* error is of a different type, or if the error parameter is undefined, the error is propagated back to the caller.
56
48
* @example assert.doesNotThrow(block[, error][, message])
57
49
*/
58
- def doesNotThrow (block : js.Function , message : String ): Unit = js.native
50
+ def doesNotThrow (block : js.Function , error : js.RegExp | js.Function = js.native, message : String = js.native): Unit =
51
+ js.native
59
52
60
53
/**
61
- * Asserts that the function block does not throw an error. See assert.throws() for more details.
62
- * When assert.doesNotThrow() is called, it will immediately call the block function. If an error is thrown
63
- * and it is the same type as that specified by the error parameter, then an AssertionError is thrown. If the
64
- * error is of a different type, or if the error parameter is undefined, the error is propagated back to the caller.
65
- * @example assert.doesNotThrow(block[, error][, message])
54
+ * @see https://nodejs.org/api/assert.html#assert_assert_equal_actual_expected_message
66
55
*/
67
- def doesNotThrow (block : js.Function , error : js.Any = js.native): Unit = js.native
56
+ @ deprecated(" Use assert.strictEqual() instead." , " stability 0" )
57
+ def equal (actual : js.Any , expected : js.Any , message : String = js.native): Unit = js.native
68
58
69
59
/**
70
- * Tests shallow, coercive equality between the actual and expected parameters using the equal comparison operator ( == ).
71
- * @example assert.equal(actual, expected[, message])
60
+ * @see https://nodejs.org/api/assert.html#assert_assert_fail_message
72
61
*/
73
- def equal ( actual : js. Any , expected : js. Any , message : String = js.native ): Unit = js.native
62
+ def fail ( message : String ): Unit = js.native
74
63
75
64
/**
76
- * Throws an AssertionError. If message is falsy, the error message is set as the values of actual and expected
77
- * separated by the provided operator. Otherwise, the error message is the value of message.
78
- * @example assert.fail(actual, expected, message, operator)
65
+ * @see https://nodejs.org/api/assert.html#assert_assert_fail_message
79
66
*/
67
+ def fail (message : js.Error ): Unit = js.native
68
+
69
+ @ deprecated(" Use assert.fail([message]) or other assert functions instead." , " Node.js v10.0.0" )
80
70
def fail (actual : js.Any , expected : js.Any , message : String , operator : String ): Unit = js.native
81
71
82
72
/**
@@ -85,10 +75,7 @@ trait Assert extends IEventEmitter {
85
75
*/
86
76
def ifError (value : js.Any ): Unit = js.native
87
77
88
- /**
89
- * Tests for any deep inequality. Opposite of assert.deepEqual().
90
- * @example assert.notDeepEqual(actual, expected[, message])
91
- */
78
+ @ deprecated(" Use assert.notDeepStrictEqual() instead." , " stability 0" )
92
79
def notDeepEqual (actual : js.Any , expected : js.Any , message : String = js.native): Unit = js.native
93
80
94
81
/**
@@ -97,10 +84,7 @@ trait Assert extends IEventEmitter {
97
84
*/
98
85
def notDeepStrictEqual (actual : js.Any , expected : js.Any , message : String = js.native): Unit = js.native
99
86
100
- /**
101
- * Tests shallow, coercive inequality with the not equal comparison operator ( != ).
102
- * @example assert.notEqual(actual, expected[, message])
103
- */
87
+ @ deprecated(" Use assert.notStrictEqual() instead." , " stability 0" )
104
88
def notEqual (actual : js.Any , expected : js.Any , message : String = js.native): Unit = js.native
105
89
106
90
/**
@@ -127,13 +111,22 @@ trait Assert extends IEventEmitter {
127
111
* of the message parameter. If the message parameter is undefined, a default error message is assigned.
128
112
* @example assert.throws(block[, error][, message])
129
113
*/
130
- def throws (block : js.Function , error : js.Any , message : String = js.native): Unit = js.native
114
+ def throws (block : js.Function ,
115
+ error : js.RegExp | js.Function | js.Object | Error ,
116
+ message : String = js.native): Unit = js.native
131
117
118
+ @ enableIf(io.scalajs.nodejs.CompilerSwitches .gteNodeJs10)
119
+ def rejects (asyncFn : js.Function | js.Promise [_],
120
+ error : js.RegExp | js.Function | js.Object | Error = js.native,
121
+ message : String = js.native): Unit = js.native
132
122
}
133
123
134
124
/**
135
125
* Assert Singleton
136
126
*/
137
127
@ js.native
138
128
@ JSImport (" assert" , JSImport .Namespace )
139
- object Assert extends Assert
129
+ object Assert extends Assert {
130
+ @ enableIf(io.scalajs.nodejs.CompilerSwitches .gteNodeJs10)
131
+ val strict : Assert = js.native
132
+ }
0 commit comments