data.push({
a: i,
b: i * i,
- c: [-(i % 10), 'score' + (i % 16 + 6) ]
+ c: [-(i % 10), 'score' + (i % 16 + 6) ],
+ d: !(i % 2)
});
}
return data;
component.columns = [
{prop: 'a', name: 'Index'},
{prop: 'b', name: 'Power ofA'},
- {prop: 'c', name: 'Poker array'}
+ {prop: 'c', name: 'Poker array'},
+ {prop: 'd', name: 'Boolean value'}
];
});
});
it('should search for 13', () => {
- doSearch('13', 9, {a: 7, b: 49, c: [ -7, 'score13'] });
+ doSearch('13', 9, {a: 7, b: 49, c: [ -7, 'score13'], d: false});
expect(component.rows[1].a).toBe(13);
expect(component.rows[8].a).toBe(87);
});
+ it('should search for true', () => {
+ doSearch('true', 50, {a: 0, b: 0, c: [ -0, 'score6'], d: true});
+ expect(component.rows[0].d).toBe(true);
+ expect(component.rows[1].d).toBe(true);
+ });
+
+ it('should search for false', () => {
+ doSearch('false', 50, {a: 1, b: 1, c: [ -1, 'score7'], d: false});
+ expect(component.rows[0].d).toBe(false);
+ expect(component.rows[1].d).toBe(false);
+ });
+
it('should test search manipulation', () => {
let searchTerms = [];
spyOn(component, 'subSearch').and.callFake((d, search, c) => {
});
it('should search for multiple values', () => {
- doSearch('7 5 3', 5, {a: 57, b: 3249, c: [ -7, 'score15']});
+ doSearch('7 5 3', 5, {a: 57, b: 3249, c: [ -7, 'score15'], d: false});
});
it('should search with column filter', () => {
- doSearch('power:1369', 1, {a: 37, b: 1369, c: [ -7, 'score11']});
- doSearch('ndex:7 ofa:5 poker:3', 3, {a: 71, b: 5041, c: [-1, 'score13']});
+ doSearch('power:1369', 1, {a: 37, b: 1369, c: [ -7, 'score11'], d: false});
+ doSearch('ndex:7 ofa:5 poker:3', 3, {a: 71, b: 5041, c: [-1, 'score13'], d: false});
});
it('should search with through array', () => {
- doSearch('array:score21', 6, {a: 15, b: 225, c: [-5, 'score21']});
+ doSearch('array:score21', 6, {a: 15, b: 225, c: [-5, 'score21'], d: false});
});
it('should search with spaces', () => {
- doSearch('\'poker array\':score21', 6, {a: 15, b: 225, c: [-5, 'score21']});
- doSearch('"poker array":score21', 6, {a: 15, b: 225, c: [-5, 'score21']});
- doSearch('poker+array:score21', 6, {a: 15, b: 225, c: [-5, 'score21']});
+ doSearch('\'poker array\':score21', 6, {a: 15, b: 225, c: [-5, 'score21'], d: false});
+ doSearch('"poker array":score21', 6, {a: 15, b: 225, c: [-5, 'score21'], d: false});
+ doSearch('poker+array:score21', 6, {a: 15, b: 225, c: [-5, 'score21'], d: false});
});
it('should not search if column name is incomplete', () => {
- doSearch('\'poker array\'', 100, {a: 0, b: 0, c: [-0, 'score6']});
- doSearch('pok', 100, {a: 0, b: 0, c: [-0, 'score6']});
- doSearch('pok:', 100, {a: 0, b: 0, c: [-0, 'score6']});
+ doSearch('\'poker array\'', 100, {a: 0, b: 0, c: [-0, 'score6'], d: true});
+ doSearch('pok', 100, {a: 0, b: 0, c: [-0, 'score6'], d: true});
+ doSearch('pok:', 100, {a: 0, b: 0, c: [-0, 'score6'], d: true});
});
it('should restore full table after search', () => {
});
it('should have table columns', () => {
- expect(component.tableColumns.length).toBe(3);
+ expect(component.tableColumns.length).toBe(4);
expect(component.tableColumns).toEqual(component.columns);
});
it('should remove column "a"', () => {
toggleColumn('a', false);
expect(component.table.sorts[0].prop).toBe('b');
- expect(component.tableColumns.length).toBe(2);
+ expect(component.tableColumns.length).toBe(3);
});
it('should not be able to remove all columns', () => {
toggleColumn('a', false);
toggleColumn('b', false);
toggleColumn('c', false);
- expect(component.table.sorts[0].prop).toBe('c');
+ toggleColumn('d', false);
+ expect(component.table.sorts[0].prop).toBe('d');
expect(component.tableColumns.length).toBe(1);
});
toggleColumn('a', false);
toggleColumn('a', true);
expect(component.table.sorts[0].prop).toBe('b');
- expect(component.tableColumns.length).toBe(3);
+ expect(component.tableColumns.length).toBe(4);
});
});
});