与expect.js设置等价

时间:2012-04-29 23:42:31

标签: node.js testing

我使用expect.js,我想测试设置等值

Error: expected [ [ 1, 2 ], [ 2, 1 ], [ 0, 1 ], [ 1, 0 ] ] to sort of equal [ [ 1, 2 ], [ 2, 1 ], [ 1, 0 ], [ 0, 1 ] ]

^这应该是真的。

我找到this,但如何将其整合到expect.js

1 个答案:

答案 0 :(得分:1)

你可以通过排序数组来作弊..(下面是coffeescript)

 describe 'test', ->
  it 'should match', ->

    a = [ [ 1, 2 ], [ 2, 1 ], [ 0, 1 ], [ 1, 0 ] ]
    b = [ [ 1, 2 ], [ 2, 1 ], [ 1, 0 ], [ 0, 1 ] ]

    expect(a.sort()).to.eql b.sort()