Skip to content

Commit

Permalink
Merge pull request #1519 from fatso83/sandbox-wrong-config-passed
Browse files Browse the repository at this point in the history
Update docs for sandbox config
  • Loading branch information
fatso83 committed Aug 8, 2017
2 parents 1f2d2e3 + f8b4ea1 commit af6348c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
6 changes: 5 additions & 1 deletion docs/_releases/v3.0.0/migrating-to-3.0.md
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 `sinon@1.x` and have been removed in `sinon@3`:
Expand Down
5 changes: 3 additions & 2 deletions docs/_releases/v3.0.0/sandbox.md
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
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 `sinon@1.x` and have been removed in `sinon@3`:
Expand Down
21 changes: 11 additions & 10 deletions docs/release-source/release/sandbox.md
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

0 comments on commit af6348c

Please sign in to comment.