Methods
(static) singletonEnd() → {Sandbox}
- Source:
Destroys the current sandbox singleton
Throws:
-
If the Sandbox Singleton hasn't been created yet (i.e. - through
singletonStart
) - Type
- Error
Returns:
The current sandbox singleton
- Type
- Sandbox
(static) singletonGetCurrent() → {Sandbox}
- Source:
Retreives the current sandbox singleton
Throws:
-
If the Snadbox Singleton hasn't been created yet (i.e. - through
singletonStart
) - Type
- Error
Returns:
The current sandbox singleton
- Type
- Sandbox
(static) singletonStart() → {Sandbox}
- Source:
Creates a Sandbox singleton. Future calls to Sandbox.singletonGetCurrent
will retrieve the
singletone. Makes it easy to work with the same Sandbox
across multiple contexts.
Throws:
-
If the Sandbox Singleton has already been created.
- Type
- Error
Returns:
The Sandbox singleton, a single global singleton.
- Type
- Sandbox
(static) test(fn)
- Source:
Creates a testing context, is designed to be passed to something like (Mocha's)[https://mochajs.org/]
it()
functions. The this
context of the callback function will have a .sandbox
value
that will be a Sandbox
for creating new wrappers. Any wrappers created with this.sandbox.newWrapper()
will be automatically unwrapped when the test ends.
Example
it("does a test", Sandbox.test(function() {
this.sandbox.newWrapper(...);
}))
// all wrappers are unwrapped when the sandbox exists
Parameters:
Name | Type | Description |
---|---|---|
fn |
function | The callback function that will be executed. |
(static) testAsync(fn)
- Source:
This is the same as test, but expects a done callback.
Example
it("does a test", Sandbox.test(function(done) {
this.sandbox.newWrapper(...);
done();
}))
// all wrappers are unwrapped when the sandbox exists
Parameters:
Name | Type | Description |
---|---|---|
fn |
function | The callback function that will be executed. |
destroy()
- Source:
Destroys a Sandbox, unwrapping all the wrappers that belong to it.
newWrapper()
- Source: