0
フィルタリングされたデータ(ツリー)で配列すると、フィルタからの等しい結果を期待する方法。 私のカスタムフィルタは、treeとqueryの2つのパラメータをとります。クエリは「foo」である場合、フィルタからの結果は次のようになります。単体テストで結果フォームフィルタを期待する方法
{
nodes: [
{
label: 'foo1'
},
{
label: 'foo2'
}
],
label: 'foo'
}
嘲笑ツリーと同等の配列内の任意の要素を期待しますか?
マイユニットテスト:
describe('customFilter', function() {
'use strict';
var definitionSearch,
tree;
beforeEach(module('myApp'));
beforeEach(inject(function ($filter) {
customFilter= $filter('customFilter');
tree = [
{
nodes: [
{
label: 'foo1'
},
{
label: 'foo2'
}
],
label: 'foo'
},
{
nodes: [
{
label: 'bar1'
}
],
label: 'bar'
}
];
}));
it('should find name', function() {
var query = 'foo'
expect(customFilter(tree, query)).toEqual(/* what should be here*/);
//customFilter(tree, query) ===> tree[0]
});
});