-
Notifications
You must be signed in to change notification settings - Fork 0
/
async-testing-spec.ls
57 lines (40 loc) · 1.3 KB
/
async-testing-spec.ls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
Feature: asynchronous testing
As a developer testing my code
I want to be able to verify complex values in async tests asynchronously
So that jsdiff-console calls the "done" method for me automatically.
- call "jsdiff-console actual, expected, done" to diff the given hash asynchronously
*/
require! {
'../src/jsdiff-console' : jsdiff-console
'chai' : {expect}
'chalk' : {green, grey, red}
}
describe 'asynchronous testing of data', ->
context 'matching data', (...) ->
before-each (done) ->
data =
first-name: 'Jean-Luc'
last-name: 'Picard'
jsdiff-console data, data, (@err) ~>
done!
it 'calls the given callback with no error', ->
expect(@err).to.be.undefined
context 'mismatching data', (...) ->
before-each (done) ->
expected =
first-name: 'Jean-Luc'
last-name: 'Picard'
actual =
first-name: 'Captain'
last-name: 'Picard'
jsdiff-console actual, expected, (@err) ~>
done!
it 'calls the given callback with an error that includes the diff', ->
expect(@err).to.eql "
mismatching records:\n\n
#{grey '{\n'}
#{red ' "firstName": "Jean-Luc",\n'}
#{green ' "firstName": "Captain",\n'}
#{grey ' "lastName": "Picard"\n}'}
"