segmentio/analytics.js-integrations — pull request #223 by lancejpollard (2014-06-17 22:21:39+00:00)
Title: refactor tests to dsl

@ianstormtaylor here is another bit of tests ported to the DSL, with a few new cases to resolve. what would you recommend? There are some inline comments with `XXX` too.

---

```js
it('should push a refresh event', function(){
test.page();
var item = window._qevents[1];
assert(item.event === 'refresh');
});
```

one option, somehow skipping the first step by only saying it was called, but not specifying the arguments, but this wouldn't technically work (something like it may tho):

```js
beforeEach(function(){
test.spy(window._qevents, 'push');
});

it('should push a refresh event', function(){
test
.page()
.called(window._qevents.push)
.called(window._qevents.push, { event: 'refresh' });
});
```

another option, specify the index:

```js
it('should push a refresh event', function(){
test
.page()
.called(window._qevents.push, { event: 'refresh' })
.index(1);
});
```

or

```js
it('should push a refresh event', function(){
test
.page()
.called(1, window._qevents.push, { event: 'refresh' });
});
```

Don't like either of those b/c they're confusing?

Another option is to just test for the first item as well, which might be better (and would be helpful for future people).

```js
it('should push a refresh event', function(){
test
.page()
.called(window._qevents.push, { some: user });
.called(window._qevents.push, { event: 'refresh' });
});
```