0

我使用expect.js并且我想测试集合等价性

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

^ 这应该是真的。

我找到了这个,但我如何将它整合到expect.js

4

1 回答 1

1

您可以通过对数组进行排序来作弊..(以下是咖啡脚本)

 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()
于 2012-04-30T00:32:32.363 回答