Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"excel-builder-webpacker": "^1.0.6",
"flatpickr": "^4.6.9",
"font-awesome": "^4.7.0",
"jquery": "^3.5.1",
"jquery": "~3.5.1",
"jquery-ui-dist": "^1.12.1",
"moment-mini": "^2.24.0",
"rxjs": "^6.3.3",
Expand Down Expand Up @@ -177,4 +177,4 @@
"yargs": "^16.2.0",
"zone.js": "~0.9.1"
}
}
}
1 change: 1 addition & 0 deletions src/app/modules/angular-slickgrid/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class Constants {
TEXT_LAST_UPDATE: 'Last Update',
TEXT_LESS_THAN: 'Less than',
TEXT_LESS_THAN_OR_EQUAL_TO: 'Less than or equal to',
TEXT_NOT_CONTAINS: 'Not contains',
TEXT_NOT_EQUAL_TO: 'Not equal to',
TEXT_PAGE: 'Page',
TEXT_REFRESH_DATASET: 'Refresh Dataset',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { FieldType, FilterConditionOption, OperatorType } from '../../models/index';
import { FieldType, FilterConditionOption, OperatorType, SearchTerm } from '../../models/index';
import { executeFilterConditionTest } from '../filterConditionProcesses';
import { executeStringFilterCondition, getFilterParsedText } from '../stringFilterCondition';

describe('executeStringFilterCondition method', () => {
it('should return True when no cell input value is provided which is equal to the default search term, neither search terms', () => {
const searchTerms = [];
const searchTerms: SearchTerm[] = [];
const options = { dataKey: '', operator: 'EQ', cellValue: '', fieldType: FieldType.string } as FilterConditionOption;
const output = executeStringFilterCondition(options, getFilterParsedText(searchTerms));
expect(output).toBe(true);
});

it('should return True when cell input value is null and is equal to the default search term, neither search terms', () => {
const searchTerms = [];
const searchTerms: SearchTerm[] = [];
const options = { dataKey: '', operator: 'EQ', cellValue: null, fieldType: FieldType.string } as FilterConditionOption;
const output = executeStringFilterCondition(options, getFilterParsedText(searchTerms));
expect(output).toBe(true);
Expand All @@ -25,7 +25,7 @@ describe('executeStringFilterCondition method', () => {
});

it('should return False when any cell input value is provided without any search terms', () => {
const searchTerms = [];
const searchTerms: SearchTerm[] = [];
const options = { dataKey: '', operator: 'EQ', cellValue: 'foo', fieldType: FieldType.string } as FilterConditionOption;
const output = executeStringFilterCondition(options, getFilterParsedText(searchTerms));
expect(output).toBe(false);
Expand Down Expand Up @@ -60,7 +60,7 @@ describe('executeStringFilterCondition method', () => {
});

it('should return False when the cell value is equal to at least 1 of the searchTerms', () => {
const searchTerms = [];
const searchTerms: SearchTerm[] = [];
const options = { dataKey: '', operator: 'EQ', cellValue: 'foo', fieldType: FieldType.string, searchTerms: ['bar', 'foo', 'John'] } as FilterConditionOption;
const output = executeStringFilterCondition(options, getFilterParsedText(searchTerms));
expect(output).toBe(false);
Expand Down Expand Up @@ -94,6 +94,20 @@ describe('executeStringFilterCondition method', () => {
expect(output).toBe(true);
});

it('should return False when search term is a substring of the cell value and the operator is "<>" (not contains)', () => {
const searchTerms = ['bost'];
const options = { dataKey: '', operator: '<>', cellValue: 'abbostford', fieldType: FieldType.string, searchTerms } as FilterConditionOption;
const output = executeStringFilterCondition(options, getFilterParsedText(searchTerms));
expect(output).toBe(false);
});

it('should return True when search term is a substring of the cell value and the operator is "!=" (not contains) because "!=" compares agains the entire string', () => {
const searchTerms = ['bost'];
const options = { dataKey: '', operator: '!=', cellValue: 'abbostford', fieldType: FieldType.string, searchTerms } as FilterConditionOption;
const output = executeStringFilterCondition(options, getFilterParsedText(searchTerms));
expect(output).toBe(true);
});

it('should return True when input value provided starts with same substring and the operator is empty string', () => {
const searchTerms = ['abb'];
const options = { dataKey: '', operator: '', cellValue: 'abbostford', fieldType: FieldType.string, searchTerms } as FilterConditionOption;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export const executeStringFilterCondition: FilterCondition = ((options: FilterCo
return cellValue.startsWith(parsedSearchValue);
} else if (options.operator === '' || options.operator === OperatorType.contains) {
return (cellValue.indexOf(parsedSearchValue) > -1);
} else if (options.operator === '<>' || options.operator === OperatorType.notContains) {
return (cellValue.indexOf(parsedSearchValue) === -1);
}
return testFilterCondition(options.operator || '==', cellValue, parsedSearchValue);
}) as FilterCondition;
Expand Down
Loading