@@ -27,9 +27,9 @@ type MethodNames<T> = {
27
27
} [ keyof T ] ;
28
28
29
29
const getDefaultValue = < T > ( assertion : Assertion < T > ) : Assertion < T > => {
30
- var newAssertion = Assertion . create < T > ( ) ;
31
- util . transferFlags ( assertion , newAssertion ) ;
32
- return newAssertion ;
30
+ var newAssertion = Assertion . create < T > ( ) ;
31
+ util . transferFlags ( assertion , newAssertion ) ;
32
+ return newAssertion ;
33
33
} ;
34
34
35
35
/*!
@@ -71,7 +71,10 @@ const getDefaultValue = <T>(assertion: Assertion<T>): Assertion<T> => {
71
71
* @param {boolean } lockSsfi (optional) whether or not the ssfi flag is locked
72
72
* @private
73
73
*/
74
- export class Assertion < T , TFlags extends AssertionFlags < T > = AssertionFlags < T > > {
74
+ export class Assertion <
75
+ T ,
76
+ TFlags extends AssertionFlags < T > = AssertionFlags < T >
77
+ > {
75
78
declare public __flags : TFlags ;
76
79
public __methods : Record < string , ChainableBehavior > = { } ;
77
80
@@ -94,50 +97,52 @@ export class Assertion<T, TFlags extends AssertionFlags<T> = AssertionFlags<T>>
94
97
ssfi ?: Function ,
95
98
lockSsfi ?: boolean
96
99
) : Assertion < TObj > {
97
- return util . proxify ( new Assertion < TObj > (
98
- obj ,
99
- msg ,
100
- ssfi ,
101
- lockSsfi
102
- ) ) ;
100
+ return util . proxify ( new Assertion < TObj > ( obj , msg , ssfi , lockSsfi ) ) ;
103
101
}
104
102
105
103
public static get includeStack ( ) : boolean {
106
- console . warn ( 'Assertion.includeStack is deprecated, use chai.config.includeStack instead.' ) ;
104
+ console . warn (
105
+ 'Assertion.includeStack is deprecated, use chai.config.includeStack instead.'
106
+ ) ;
107
107
return config . includeStack ;
108
108
}
109
109
110
110
public static set includeStack ( value : boolean ) {
111
- console . warn ( 'Assertion.includeStack is deprecated, use chai.config.includeStack instead.' ) ;
111
+ console . warn (
112
+ 'Assertion.includeStack is deprecated, use chai.config.includeStack instead.'
113
+ ) ;
112
114
config . includeStack = value ;
113
115
}
114
116
115
117
public static get showDiff ( ) : boolean {
116
- console . warn ( 'Assertion.showDiff is deprecated, use chai.config.showDiff instead.' ) ;
118
+ console . warn (
119
+ 'Assertion.showDiff is deprecated, use chai.config.showDiff instead.'
120
+ ) ;
117
121
return config . showDiff ;
118
122
}
119
123
120
124
public static set showDiff ( value : boolean ) {
121
- console . warn ( 'Assertion.showDiff is deprecated, use chai.config.showDiff instead.' ) ;
125
+ console . warn (
126
+ 'Assertion.showDiff is deprecated, use chai.config.showDiff instead.'
127
+ ) ;
122
128
config . showDiff = value ;
123
129
}
124
130
125
- public static addProperty ( name : string , fn ?: ( this : Assertion < unknown > ) => unknown ) : void {
131
+ public static addProperty (
132
+ name : string ,
133
+ fn ?: ( this : Assertion < unknown > ) => unknown
134
+ ) : void {
126
135
util . addProperty ( this . prototype , name , fn , getDefaultValue ) ;
127
136
}
128
137
129
- public static addMethod <
130
- TKey extends PropertyKey
131
- > (
138
+ public static addMethod < TKey extends PropertyKey > (
132
139
name : TKey ,
133
- fn : TKey extends MethodNames < Assertion < unknown > > ?
134
- (
135
- this : Assertion < unknown > ,
136
- ...args : Parameters < Assertion < unknown > [ TKey ] >
137
- ) => (
138
- ReturnType < Assertion < unknown > [ TKey ] > | void
139
- ) :
140
- ( ( this : Assertion < unknown > , ...args : never ) => unknown )
140
+ fn : TKey extends MethodNames < Assertion < unknown > >
141
+ ? (
142
+ this : Assertion < unknown > ,
143
+ ...args : Parameters < Assertion < unknown > [ TKey ] >
144
+ ) => ReturnType < Assertion < unknown > [ TKey ] > | void
145
+ : ( this : Assertion < unknown > , ...args : never ) => unknown
141
146
) : void {
142
147
util . addMethod ( this . prototype , name , fn , getDefaultValue ) ;
143
148
}
@@ -164,8 +169,18 @@ export class Assertion<T, TFlags extends AssertionFlags<T> = AssertionFlags<T>>
164
169
util . overwriteMethod ( this . prototype , name , fn , getDefaultValue ) ;
165
170
}
166
171
167
- public static overwriteChainableMethod ( name : string , fn : Function , chainingBehavior : Function ) : void {
168
- util . overwriteChainableMethod ( this . prototype , name , fn , chainingBehavior , getDefaultValue ) ;
172
+ public static overwriteChainableMethod (
173
+ name : string ,
174
+ fn : Function ,
175
+ chainingBehavior : Function
176
+ ) : void {
177
+ util . overwriteChainableMethod (
178
+ this . prototype ,
179
+ name ,
180
+ fn ,
181
+ chainingBehavior ,
182
+ getDefaultValue
183
+ ) ;
169
184
}
170
185
171
186
/**
@@ -199,10 +214,10 @@ export class Assertion<T, TFlags extends AssertionFlags<T> = AssertionFlags<T>>
199
214
msg = util . getMessage ( this , arguments ) ;
200
215
var actual = util . getActual ( this , arguments ) ;
201
216
var assertionErrorObjectProperties : Record < string , unknown > = {
202
- actual : actual
203
- , expected : expected
204
- , showDiff : showDiff
205
- , operator : undefined
217
+ actual : actual ,
218
+ expected : expected ,
219
+ showDiff : showDiff ,
220
+ operator : undefined
206
221
} ;
207
222
208
223
var operator = util . getOperator ( this , arguments ) ;
@@ -213,7 +228,8 @@ export class Assertion<T, TFlags extends AssertionFlags<T> = AssertionFlags<T>>
213
228
throw new AssertionError (
214
229
msg ,
215
230
assertionErrorObjectProperties ,
216
- ( config . includeStack ) ? this . assert : util . flag ( this , 'ssfi' ) ) ;
231
+ config . includeStack ? this . assert : util . flag ( this , 'ssfi' )
232
+ ) ;
217
233
}
218
234
}
219
235
0 commit comments