File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,19 @@ export class Assertion<T> {
60
60
this . not = new Proxy ( this , { get : this . proxyInverter ( true ) } ) ;
61
61
}
62
62
63
+ /**
64
+ * A convenience method to normalize the assertion instance. If it was
65
+ * inverted with `.not`, it'll return it back to the previous non-inverted
66
+ * state. Otherwise, it returns the same instance.
67
+ *
68
+ * @returns the normalized assertion instance
69
+ */
70
+ protected normalized ( ) : this {
71
+ return this . inverted
72
+ ? new Proxy ( this , { get : this . proxyInverter ( false ) } )
73
+ : this ;
74
+ }
75
+
63
76
/**
64
77
* A convenience method to execute the assertion. The inversion logic for
65
78
* `.not` is already embedded in this method, so this should always be used
@@ -79,9 +92,7 @@ export class Assertion<T> {
79
92
throw invertedError ;
80
93
}
81
94
82
- return this . inverted
83
- ? new Proxy ( this , { get : this . proxyInverter ( false ) } )
84
- : this ;
95
+ return this . normalized ( ) ;
85
96
}
86
97
87
98
private proxyInverter ( isInverted : boolean ) : ProxyHandler < this> [ "get" ] {
You can’t perform that action at this time.
0 commit comments