Skip to content
This repository has been archived by the owner on Jan 4, 2024. It is now read-only.

Commit

Permalink
Added documentation for new functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
rkalis committed Jun 17, 2018
1 parent fc846c1 commit 8ccff9a
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ To use this package, import it at the top of the Truffle test file:
const truffleAssert = require('truffle-assertions');
```

## Assertions
## Exported functions

### truffleAssert.eventEmitted(result, eventType, filter, message)
The `eventEmitted` assertion checks that an event with type eventType has been emitted by the transaction with result result. A filter function can be passed along to further specify requirements for the event arguments:
The `eventEmitted` assertion checks that an event with type `eventType` has been emitted by the transaction with result `result`. A filter function can be passed along to further specify requirements for the event arguments:

```javascript
truffleAssert.eventEmitted(result, 'TestEvent', (ev) => {
return ev.param1 === 10 && ev.param2 === ev.param3;
});
```

When the filter parameter is omitted or set to null, the assertion checks just for event type:
When the `filter` parameter is omitted or set to null, the assertion checks just for event type:

```javascript
truffleAssert.eventEmitted(result, 'TestEvent');
Expand All @@ -48,18 +48,18 @@ The default messages are
`Event of type ${eventType} was not emitted`
`Event filter for ${eventType} returned no results`
```
Depending on the reason for the assertion failure.
Depending on the reason for the assertion failure. The default message also includes a list of events that were emitted in the passed transaction.

### truffleAssert.eventNotEmitted(result, eventType, filter, message)
The `eventNotEmitted` assertion checks that an event with type eventType has not been emitted by the transaction with result result. A filter function can be passed along to further specify requirements for the event arguments:
The `eventNotEmitted` assertion checks that an event with type `eventType` has not been emitted by the transaction with result `result`. A filter function can be passed along to further specify requirements for the event arguments:

```javascript
truffleAssert.eventNotEmitted(result, 'TestEvent', (ev) => {
return ev.param1 === 10 && ev.param2 === ev.param3;
});
```

When the filter parameter is omitted or set to null, the assertion checks just for event type:
When the `filter` parameter is omitted or set to null, the assertion checks just for event type:

```javascript
truffleAssert.eventNotEmitted(result, 'TestEvent');
Expand All @@ -76,4 +76,18 @@ The default messages are
`Event of type ${eventType} was emitted`
`Event filter for ${eventType} returned results`
```
Depending on the reason for the assertion failure.
Depending on the reason for the assertion failure. The default message also includes a list of events that were emitted in the passed transaction.

### truffleAssert.prettyPrintEmittedEvents(result)

Pretty prints the full list of events with their parameters, that were emitted in transaction with result `result`

```
truffleAssert.prettyPrintEmittedEvents(result);
```
```
Events emitted in tx 0x7da28cf2bd52016ee91f10ec711edd8aa2716aac3ed453b0def0af59991d5120:
----------------------------------------------------------------------------------------
TestEvent(testAddress = 0xe04893f0a1bdb132d66b4e7279492fcfe602f0eb, testInt: 10)
----------------------------------------------------------------------------------------
```

0 comments on commit 8ccff9a

Please sign in to comment.