Sammy/t 192 aau whan i select does not include it is (#99)
* feature: add operand list to filters * feature: implement not include * feature: add operand on filters * feature: use filters operand instead of defaults * test: adapt test with new operands * refactor: remove useless %% in gql where * test: test fullname filter * test: add test for where rendering of filters
This commit is contained in:
@ -0,0 +1,73 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`PeopleFilter Company fitler should generate the where variable of the GQL call 1`] = `
|
||||
Object {
|
||||
"_and": Array [
|
||||
Object {
|
||||
"firstname": Object {
|
||||
"_eq": "undefined",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"lastname": Object {
|
||||
"_eq": "undefined",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`PeopleFilter Company fitler should generate the where variable of the GQL call 2`] = `
|
||||
Object {
|
||||
"_not": Object {
|
||||
"_and": Array [
|
||||
Object {
|
||||
"firstname": Object {
|
||||
"_eq": "undefined",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"lastname": Object {
|
||||
"_eq": "undefined",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`PeopleFilter Fullname filter should generate the where variable of the GQL call 1`] = `
|
||||
Object {
|
||||
"_and": Array [
|
||||
Object {
|
||||
"firstname": Object {
|
||||
"_eq": "undefined",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"lastname": Object {
|
||||
"_eq": "undefined",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`PeopleFilter Fullname filter should generate the where variable of the GQL call 2`] = `
|
||||
Object {
|
||||
"_not": Object {
|
||||
"_and": Array [
|
||||
Object {
|
||||
"firstname": Object {
|
||||
"_eq": "undefined",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"lastname": Object {
|
||||
"_eq": "undefined",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
`;
|
||||
29
front/src/pages/people/__tests__/people-filter.test.ts
Normal file
29
front/src/pages/people/__tests__/people-filter.test.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { GraphqlQueryPerson } from '../../../interfaces/person.interface';
|
||||
import { mockCompanyData } from '../../companies/__stories__/mock-data';
|
||||
import { defaultData } from '../default-data';
|
||||
import { companyFilter, fullnameFilter } from '../people-table';
|
||||
|
||||
const JohnDoeUser = defaultData.find(
|
||||
(user) => user.email === 'john@linkedin.com',
|
||||
) as GraphqlQueryPerson;
|
||||
|
||||
describe('PeopleFilter', () => {
|
||||
it('Fullname filter should generate the where variable of the GQL call', () => {
|
||||
const filterSelectedValue = fullnameFilter.searchResultMapper(JohnDoeUser);
|
||||
for (const operand of fullnameFilter.operands) {
|
||||
expect(
|
||||
fullnameFilter.whereTemplate(operand, filterSelectedValue),
|
||||
).toMatchSnapshot();
|
||||
}
|
||||
});
|
||||
it('Company fitler should generate the where variable of the GQL call', () => {
|
||||
const filterSelectedValue = companyFilter.searchResultMapper(
|
||||
mockCompanyData[0],
|
||||
);
|
||||
for (const operand of companyFilter.operands) {
|
||||
expect(
|
||||
fullnameFilter.whereTemplate(operand, filterSelectedValue),
|
||||
).toMatchSnapshot();
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user