Add expect.js

This commit is contained in:
Rico Sta. Cruz 2015-07-04 12:01:04 +08:00
parent e8b82b1ec9
commit ee7f668741
1 changed files with 29 additions and 0 deletions

29
expectjs.md Normal file
View File

@ -0,0 +1,29 @@
---
title: expect.js
---
```js
expect(x).toBe(y)
.toBe(val)
.toEqual(val)
.toThrow(err)
.toExist
.toBeA(constructor)
.toBeA('string')
.toMatch(/expr/)
.toBeLessThan(n)
.toBeGreaterThan(n)
.toInclude(val)
.toExclude(val)
```
```js
spy = expect.spyOn(video, 'play')
expect(spy.calls.length).toEqual(1);
expect(spy.calls[0].context).toBe(video);
expect(spy.calls[0].arguments).toEqual([ 'some', 'args' ]);
expect(spy).toHaveBeenCalled();
expect(spy).toHaveBeenCalledWith('some', 'args');
```
https://www.npmjs.com/package/expect