Refactor Filter type to accept Is, Is Not, Contains, Does not Contain (#128)

* Refactor Filter type to accept Is, Is Not, Contains, Does not Contain

* Remove any and add tests
This commit is contained in:
Charles Bochet
2023-05-18 15:32:57 +02:00
committed by GitHub
parent 4211d5872b
commit 5286dfd695
20 changed files with 241 additions and 336 deletions

View File

@ -1,6 +1,6 @@
import { GraphqlQueryPerson } from '../../../../interfaces/person.interface';
import { GraphqlQueryPerson } from '../../../../interfaces/entities/person.interface';
export const mockData: Array<GraphqlQueryPerson> = [
export const mockPeopleData: Array<GraphqlQueryPerson> = [
{
id: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6b',
__typename: 'Person',

View File

@ -1,9 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`PeopleFilter should render the filter city 1`] = `
exports[`PeopleFilter should render the filter city which is text search 1`] = `
Object {
"city": Object {
"_eq": "Paris",
"_ilike": "%Paris%",
},
}
`;
exports[`PeopleFilter should render the filter company_name which relation search 1`] = `
Object {
"company": Object {
"name": Object {
"_eq": "test-name",
},
},
}
`;

View File

@ -1,20 +1,18 @@
import { cityFilter } from '../people-filters';
import { cityFilter, companyFilter } from '../people-filters';
describe('PeopleFilter', () => {
it(`should render the filter ${cityFilter.key}`, () => {
it(`should render the filter ${companyFilter.key} which relation search`, () => {
expect(
cityFilter.operands[0].whereTemplate({
companyFilter.operands[0].whereTemplate({
id: 'test-id',
city: 'Paris',
email: 'john@doe.com',
firstname: 'John',
lastname: 'Doe',
phone: '0123456789',
creationDate: new Date(),
pipes: [],
company: null,
__typename: 'people',
name: 'test-name',
domainName: 'test-domain-name',
__typename: 'companies',
}),
).toMatchSnapshot();
});
it(`should render the filter ${cityFilter.key} which is text search`, () => {
expect(cityFilter.operands[0].whereTemplate('Paris')).toMatchSnapshot();
});
});