0
조롱 된 데이터 (트리)로 배열 된 경우 필터에서 동일한 결과가 나타날 것으로 예상하는 방법. 내 사용자 정의 필터는 트리와 쿼리라는 두 개의 매개 변수를 사용합니다. 쿼리가 '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]
});
});