Skip to content

Commit

Permalink
Merge pull request #7524 from ckeditor/i/7456-docs
Browse files Browse the repository at this point in the history
Docs: Code style suggests to use `sinon-chai` and named spies. Closes #7456.
  • Loading branch information
pomek authored Jul 1, 2020
2 parents d40bd58 + fffdf52 commit c0742e3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/framework/guides/contributing/code-style.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,19 @@ There are some special rules and tips for tests.

Think about this — when you fix a bug by adding a parameter to an existing function call you do not affect code coverage (that line was called anyway). However, you had a bug, meaning that your test suite did not cover it. Therefore, a test must be created for that code change.
* It should be `expect( x ).to.equal( y )`. **NOT**: ~~`expect( x ).to.be.equal( y )`~~.
* When using Sinon spies, pay attention to the readability of assertions and failure messages.
* Use named spies, for example:

```js
const someCallbackSpy = sinon.spy().named( 'someCallback' );
const myMethodSpy = sinon.spy( obj, 'myMethod' );
```
* Use [sinon-chai assertions](https://www.chaijs.com/plugins/sinon-chai/)

```js
expect( myMethodSpy ).to.be.calledOnce
// expected myMethod to be called once but was called twice
```

## Naming

Expand Down

0 comments on commit c0742e3

Please sign in to comment.