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> {
6060 this . not = new Proxy ( this , { get : this . proxyInverter ( true ) } ) ;
6161 }
6262
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+
6376 /**
6477 * A convenience method to execute the assertion. The inversion logic for
6578 * `.not` is already embedded in this method, so this should always be used
@@ -79,9 +92,7 @@ export class Assertion<T> {
7992 throw invertedError ;
8093 }
8194
82- return this . inverted
83- ? new Proxy ( this , { get : this . proxyInverter ( false ) } )
84- : this ;
95+ return this . normalized ( ) ;
8596 }
8697
8798 private proxyInverter ( isInverted : boolean ) : ProxyHandler < this> [ "get" ] {
You can’t perform that action at this time.
0 commit comments