Constructor
new Operation(wrapper, desc)
- Source:
Creates a new Operation
Parameters:
Name | Type | Description |
---|---|---|
wrapper |
Wrapper | The |
desc |
Object | The default values of the Operation |
Members
argList :any
- Source:
The arguments that were or will be passed to the function call. Only applies to functions.
Type:
- any
context :any
- Source:
The this
value that was or will be used for the function call. Only applies to functions.
Type:
- any
exception :Error|null
- Source:
The Error
that was or will be thrown. If null, there was no Error
.
Type:
- Error | null
getOrSet :String
- Source:
Whether this was a property "set" (assignment) or a property "get" (retreiving the value). Only applies to properties.
Type:
- String
postCall :Boolean
- Source:
Set by a Trigger to be true
if the operation record is in it's "post-call" phase.
Type:
- Boolean
preCall :Boolean
- Source:
Set by a Trigger to be true
if the operation record is currently in it's "pre-call" phase -- that is before the call to the wrapped thing has actually happened.
Type:
- Boolean
retVal :any
- Source:
The value that was or will be returned.
Type:
- any
setVal :any
- Source:
The value that was or will be used for a property "set". Only applies to properties.
Type:
- any
type :String
- Source:
The type of operation record this is, either "function" or "property"
Type:
- String
wrapper :Wrapper
- Source:
The Wrapper that created this call
Type:
Methods
(static) expectCallArgs(…args) → {Trigger|Boolean}
- Source:
Evaluates whether the arguments to a function match the ...args
.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
args |
any |
<repeatable> |
The list of arguments to validate for the function call. |
Throws:
-
-
If called with more or less than one argument
- Type
- TypeError
-
-
-
If called by a
Trigger
that doesn't match the expected return value - Type
- ExpectError
-
Returns:
When called on a Trigger, the expectation is stored for future evaluation and the Trigger
value is returned to make this chainable.
When called on a Operation, the expectation is evaluated immediately and true
is returned if the expectation passed; false
if it failed.
- Type
- Trigger | Boolean
(static) expectCallContext(context) → {Trigger|Boolean}
- Source:
Evaluates whether the context (this
) of a function call matches the context
parameter.
Parameters:
Name | Type | Description |
---|---|---|
context |
Object | The expected |
Throws:
-
-
If called on a wrapped function, or with more or less than one argument
- Type
- TypeError
-
-
-
If called by a
Trigger
that doesn't match the expected call context (this
value) - Type
- ExpectError
-
Returns:
When called on a Trigger, the expectation is stored for future evaluation and the Trigger
value is returned to make this chainable.
When called on a Operation, the expectation is evaluated immediately and true
is returned if the expectation passed; false
if it failed.
- Type
- Trigger | Boolean
(static) expectCustom(cb) → {Trigger|Boolean}
- Source:
Evaluates the callback function
Parameters:
Name | Type | Description |
---|---|---|
cb |
Operation~customExpectCallback | Callback function that will determine whether the expecation passes or fails. See customExpectCallback for more details. |
Throws:
-
-
If called with more or less than one argument, or the first argument isn't a
Function
- Type
- TypeError
-
-
-
If called by a
Trigger
and the custom function returns anError
or aString
- Type
- ExpectError
-
Returns:
When called on a Trigger, the expectation is stored for future evaluation and the Trigger
value is returned to make this chainable.
When called on a Operation, the expectation is evaluated immediately and true
is returned if the expectation passed; false
if it failed.
- Type
- Trigger | Boolean
(static) expectException(exception) → {Trigger|Boolean}
- Source:
Expects that the function call or property set / get threw an Error
that strictly matches the exception
arguemnt.
Parameters:
Name | Type | Description |
---|---|---|
exception |
Error | null | The |
Throws:
-
-
If called with more or less than one argument, or with an argument that isn't an
Error
ornull
- Type
- TypeError
-
-
-
If called by a
Trigger
that doesn't throw the expected exception (Error
) or throwns an unexpected exception (if the expected exception wasnull
) - Type
- ExpectError
-
Returns:
When called on a Trigger, the expectation is stored for future evaluation and the Trigger
value is returned to make this chainable.
When called on a Operation, the expectation is evaluated immediately and true
is returned if the expectation passed; false
if it failed.
- Type
- Trigger | Boolean
(static) expectReturn(retVal) → {Trigger|Boolean}
- Source:
Evaluates whether the call
or get
returned the value retVal
.
Parameters:
Name | Type | Description |
---|---|---|
retVal |
any | The value that is expected to be returned from the function call or property getter. |
Throws:
-
-
If called with more or less than one argument
- Type
- TypeError
-
-
-
If called by a
Trigger
that doesn't match the expected return value - Type
- ExpectError
-
Returns:
When called on a Trigger, the expectation is stored for future evaluation and the Trigger
value is returned to make this chainable.
When called on a Operation, the expectation is evaluated immediately and true
is returned if the expectation passed; false
if it failed.
- Type
- Trigger | Boolean
(static) expectSetVal(setVal) → {Trigger|Boolean}
- Source:
Evaluates the value that is set on a property during assignment (e.g. - obj.prop = setVal
) and expects the value to
strictly equal the setVal
argument.
Parameters:
Name | Type | Description |
---|---|---|
setVal |
any | The value that is expected to be set on the property. An |
Throws:
-
-
If called with more or less than one argument
- Type
- TypeError
-
-
-
If called by a
Trigger
that doesn't receive the expected set argument - Type
- ExpectError
-
Returns:
When called on a Trigger, the expectation is stored for future evaluation and the Trigger
value is returned to make this chainable.
When called on a Operation, the expectation is evaluated immediately and true
is returned if the expectation passed; false
if it failed.
- Type
- Trigger | Boolean
Type Definitions
customExpectCallback(curr) → {null|ExpectError}
- Source:
This is a description of the callback used by expectCustom.
Parameters:
Name | Type | Description |
---|---|---|
curr |
Operation | The current function call or property / set get. |
Returns:
null
if expectation was successful. Returns ExpectError containing the message for the failed expectation otherwise.
- Type
- null | ExpectError