aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/pipes/searchFilter/search-filter.pipe.spec.ts
blob: 2567cbf2745c00894ce90bf2051a087735faa068 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import {SearchFilterPipe} from "./search-filter.pipe";
import * as _ from 'lodash';

describe('Search filter pipe', () => {

  const items= [{'id':1, 'name': 'aaa'},
    {'id':12, 'name': 'bbb', 'children':{'first': 155, 'second': 2, 'third': 3}},
    {'id':3, 'name': 'ccc', 'children':{'first': 1, 'BbB': 'BbB', 'third': 3}},
    {'id':4, 'name': 'aad', 'children':{'first': 1, 'second': 2, 'third': 3}}];

  test('should return items contains substring bb', () => {
    let filter = new SearchFilterPipe();
    let res:any[] = filter.transform(items,'bb');
    expect(_.map(res, 'name' )).toEqual(['bbb','ccc']);
  });

});