Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs for sandbox config #1519

Merged
merged 3 commits into from
Aug 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/_releases/v3.0.0/migrating-to-3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ Codemod available at https://github.com/hurrymaplelad/sinon-codemod
Calling `sinon.stub` with three arguments will throw an Error. This was deprecated with `sinon@2` and has been removed with `sinon@3`

## `sinon.useFakeTimers([now, ]prop1, prop2, ...)` - Removed
`sinon.useFakeTimers()` signature has [changed](./fake-timers). To define which methods to fake, please use `config.toFake`. Other options are now available when configuring `useFakeTimers`. Please consult the [documentation](./fake-timers) for more information.
`sinon.useFakeTimers()` signature has [changed](../fake-timers). To define which methods to fake, please use `config.toFake`. Other options are now available when configuring `useFakeTimers`. Please consult the [documentation](../fake-timers) for more information.

## `sinon.sandbox.create(config)` - Config changes
The [changes in configuration](../fake-timers) for fake timers implicitly affect sandbox creation. If your config used to look like `{ useFaketimers: ["setTimeout", "setInterval"]}`, you
will now need to change it to `{ useFaketimers: { toFake: ["setTimeout", "setInterval"] }}`.

## Removal of internal helpers
The following internal functions were deprecated as of `[email protected]` and have been removed in `sinon@3`:
Expand Down
5 changes: 3 additions & 2 deletions docs/_releases/v3.0.0/sandbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ have to set `useFakeServer` to `true`.

##### useFakeTimers

If `true`, the sandbox will have a `clock` property. Can also be an `Array` of
timer properties to fake.
If set to `true`, the sandbox will have a `clock` property. You can optionally pass
in a configuration object that follows the [specification for fake timers](../fake-timers),
such as `{ toFake: ["setTimeout", "setInterval"] }`.

##### useFakeServer

Expand Down
6 changes: 5 additions & 1 deletion docs/release-source/release/migrating-to-3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ Codemod available at https://github.com/hurrymaplelad/sinon-codemod
Calling `sinon.stub` with three arguments will throw an Error. This was deprecated with `sinon@2` and has been removed with `sinon@3`

## `sinon.useFakeTimers([now, ]prop1, prop2, ...)` - Removed
`sinon.useFakeTimers()` signature has [changed](./fake-timers). To define which methods to fake, please use `config.toFake`. Other options are now available when configuring `useFakeTimers`. Please consult the [documentation](./fake-timers) for more information.
`sinon.useFakeTimers()` signature has [changed](../fake-timers). To define which methods to fake, please use `config.toFake`. Other options are now available when configuring `useFakeTimers`. Please consult the [documentation](../fake-timers) for more information.

## `sinon.sandbox.create(config)` - Config changes
The [changes in configuration](../fake-timers) for fake timers implicitly affect sandbox creation. If your config used to look like `{ useFaketimers: ["setTimeout", "setInterval"]}`, you
will now need to change it to `{ useFaketimers: { toFake: ["setTimeout", "setInterval"] }}`.

## Removal of internal helpers
The following internal functions were deprecated as of `[email protected]` and have been removed in `sinon@3`:
Expand Down
21 changes: 11 additions & 10 deletions docs/release-source/release/sandbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Sandboxes removes the need to keep track of every fake created, which greatly si
var sinon = require('sinon');

var myAPI = { hello: function () {} };
var sandbox = sinon.createSandbox();
var sandbox = sinon.sandbox.create();

describe('myAPI.hello method', function () {

Expand Down Expand Up @@ -39,25 +39,25 @@ describe('myAPI.hello method', function () {

## Sandbox API

#### `var sandbox = sinon.createSandbox();`
#### `var sandbox = sinon.sandbox.create();`

Creates a sandbox object with spies, stubs, and mocks.


#### `var sandbox = sinon.createSandbox(config);`
#### `var sandbox = sinon.sandbox.create(config);`

The `sinon.createSandbox(config)` method is often an integration feature, and can be used for scenarios including a global object to coordinate all fakes through.
The `sinon.sandbox.create(config)` method is often an integration feature, and can be used for scenarios including a global object to coordinate all fakes through.

Sandboxes are partially configured by default such that calling:

```javascript
var sandbox = sinon.createSandbox({});
var sandbox = sinon.sandbox.create({});
```

will merge in extra defaults analogous to:

```javascript
var sandbox = sinon.createSandbox({
var sandbox = sinon.sandbox.create({
// ...
injectInto: null,
properties: ["spy", "stub", "mock"],
Expand All @@ -82,10 +82,10 @@ To get a full sandbox with stubs, spies, etc. **and** fake timers and servers, y

```javascript
// Inject the sinon defaults explicitly.
var sandbox = sinon.createSandbox(sinon.defaultConfig);
var sandbox = sinon.sandbox.create(sinon.defaultConfig);

// (OR) Add the extra properties that differ from the sinon defaults.
var sandbox = sinon.createSandbox({
var sandbox = sinon.sandbox.create({
useFakeTimers: true
useFakeServer: true
});
Expand All @@ -104,8 +104,9 @@ have to set `useFakeServer` to `true`.

##### useFakeTimers

If `true`, the sandbox will have a `clock` property. Can also be an `Array` of
timer properties to fake.
If set to `true`, the sandbox will have a `clock` property. You can optionally pass
in a configuration object that follows the [specification for fake timers](../fake-timers),
such as `{ toFake: ["setTimeout", "setInterval"] }`.

##### useFakeServer

Expand Down