File tree Expand file tree Collapse file tree 4 files changed +111
-0
lines changed Expand file tree Collapse file tree 4 files changed +111
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ layout : default
3
+ title : false
4
+ description : A strict boolean false comparison.
5
+ categories :
6
+ - assert
7
+ ---
8
+
9
+ ## ` false( actual [, message ] ) `
10
+
11
+ A boolean check, equivalent to JUnit's ` assertFalse() ` . Passes if the first argument is false.
12
+
13
+ | name | description |
14
+ | --------------------| --------------------------------------|
15
+ | ` actual ` | Expression being tested |
16
+ | ` message ` (string) | A short description of the assertion |
17
+
18
+ ### Description
19
+
20
+ ` false() ` requires just one argument. If the argument evaluates to false, the assertion passes; otherwise, it fails.
21
+
22
+ [ ` true() ` ] ( /assert/true ) can be used to explicitly test for a true value.
23
+
24
+ ### Examples
25
+
26
+ ``` js
27
+ QUnit .test ( " false test" , function ( assert ) {
28
+ assert .false ( false , " false succeeds" );
29
+
30
+ assert .false ( " not-empty" , " not-empty string fails" );
31
+ assert .false ( " " , " empty string fails" );
32
+ assert .false ( 0 , " 0 fails" );
33
+ assert .false ( true , " true fails" );
34
+ assert .false ( NaN , " NaN fails" );
35
+ assert .false ( null , " null fails" );
36
+ assert .false ( undefined , " undefined fails" );
37
+ });
38
+ ```
Original file line number Diff line number Diff line change
1
+ ---
2
+ layout : default
3
+ title : true
4
+ description : A strict boolean true comparison.
5
+ categories :
6
+ - assert
7
+ ---
8
+
9
+ ## ` true( actual [, message ] ) `
10
+
11
+ A boolean check, equivalent to JUnit's ` assertTrue() ` . Passes if the first argument is ` true ` .
12
+
13
+ | name | description |
14
+ | --------------------| --------------------------------------|
15
+ | ` actual ` | Expression being tested |
16
+ | ` message ` (string) | A short description of the assertion |
17
+
18
+ ### Description
19
+
20
+ ` true() ` requires just one argument. If the argument evaluates to true, the assertion passes; otherwise, it fails.
21
+
22
+ [ ` false() ` ] ( /assert/false ) can be used to explicitly test for a false value.
23
+
24
+ ### Examples
25
+
26
+ ``` js
27
+ QUnit .test ( " true test" , function ( assert ) {
28
+ assert .true ( true , " true succeeds" );
29
+
30
+ assert .true ( " non-empty" , " non-empty string fails" );
31
+ assert .true ( " " , " empty string fails" );
32
+ assert .true ( 1 , " 1 fails" );
33
+ assert .true ( false , " false fails" );
34
+ assert .true ( NaN , " NaN fails" );
35
+ assert .true ( null , " null fails" );
36
+ assert .true ( undefined , " undefined fails" );
37
+ });
38
+ ```
39
+
Original file line number Diff line number Diff line change @@ -173,6 +173,24 @@ class Assert {
173
173
} ) ;
174
174
}
175
175
176
+ true ( result , message ) {
177
+ this . pushResult ( {
178
+ result : result === true ,
179
+ actual : result ,
180
+ expected : true ,
181
+ message
182
+ } ) ;
183
+ }
184
+
185
+ false ( result , message ) {
186
+ this . pushResult ( {
187
+ result : result === false ,
188
+ actual : result ,
189
+ expected : false ,
190
+ message
191
+ } ) ;
192
+ }
193
+
176
194
equal ( actual , expected , message ) {
177
195
178
196
// eslint-disable-next-line eqeqeq
Original file line number Diff line number Diff line change @@ -38,6 +38,22 @@ QUnit.test( "notOk", function( assert ) {
38
38
assert . notOk ( NaN ) ;
39
39
} ) ;
40
40
41
+ QUnit . test ( "true" , function ( assert ) {
42
+ function functionThatReturnsTrue ( ) {
43
+ return true ;
44
+ }
45
+ assert . true ( true ) ;
46
+ assert . true ( functionThatReturnsTrue ( ) ) ;
47
+ } ) ;
48
+
49
+ QUnit . test ( "false" , function ( assert ) {
50
+ function functionThatReturnsFalse ( ) {
51
+ return false ;
52
+ }
53
+ assert . false ( false ) ;
54
+ assert . false ( functionThatReturnsFalse ( ) ) ;
55
+ } ) ;
56
+
41
57
QUnit . test ( "equal" , function ( assert ) {
42
58
assert . equal ( 1 , 1 ) ;
43
59
assert . equal ( "foo" , "foo" ) ;
You can’t perform that action at this time.
0 commit comments