Skip to content

Commit

Permalink
docs: updated interface docs for clarity and to show the proper API
Browse files Browse the repository at this point in the history
  • Loading branch information
gregdardis committed Sep 29, 2018
1 parent c8c95a0 commit bb39a7a
Show file tree
Hide file tree
Showing 2 changed files with 199 additions and 82 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,19 @@ chai.spy.on(array, 'push', returns => 5);

#### spy.interface

This method allows to create mock (or spy object), basically an interface with fake implementation or without implementation at all:
This method creates a mock (or spy object): an interface with spies on each of the object's methods. The object's methods have either fake implementations or no implementation.

```js
const eventBus = chai.spy.interface(['on', 'off', 'emit']);
// with no implementation
const arrayLike = chai.spy.interface('arrayLike', ['push', 'pop', 'filter']);

// with implementation
// with fake implementation
const arrayLike = chai.spy.interface({
push(item) {
this.__items = this.__items || [];
return this.__items.push(item)
},
// other methods
// other method implementations
});

arrayLike.push(5);
Expand Down
Loading

0 comments on commit bb39a7a

Please sign in to comment.