Sammy/t 190 aau i see other filters city on people (#101)
* feature: add email filter * feature: add city filter * test: fix company search tests * test: use the right value in test * refactor: test all the filters in a loop
This commit is contained in:
@ -1,70 +1,92 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`PeopleFilter Company fitler should generate the where variable of the GQL call 1`] = `
|
||||
exports[`PeopleFilter should render the filter city 1`] = `
|
||||
Object {
|
||||
"city": Object {
|
||||
"_eq": "Paris",
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`PeopleFilter should render the filter city 2`] = `
|
||||
Object {
|
||||
"_not": Object {
|
||||
"city": Object {
|
||||
"_eq": "Paris",
|
||||
},
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`PeopleFilter should render the filter company_name 1`] = `
|
||||
Object {
|
||||
"company": Object {
|
||||
"name": Object {
|
||||
"_eq": "ACME",
|
||||
},
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`PeopleFilter should render the filter company_name 2`] = `
|
||||
Object {
|
||||
"_not": Object {
|
||||
"company": Object {
|
||||
"name": Object {
|
||||
"_eq": "ACME",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`PeopleFilter should render the filter email 1`] = `
|
||||
Object {
|
||||
"email": Object {
|
||||
"_eq": "john@linkedin.com",
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`PeopleFilter should render the filter email 2`] = `
|
||||
Object {
|
||||
"_not": Object {
|
||||
"email": Object {
|
||||
"_eq": "john@linkedin.com",
|
||||
},
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`PeopleFilter should render the filter fullname 1`] = `
|
||||
Object {
|
||||
"_and": Array [
|
||||
Object {
|
||||
"firstname": Object {
|
||||
"_eq": "undefined",
|
||||
"_eq": "John",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"lastname": Object {
|
||||
"_eq": "undefined",
|
||||
"_eq": "Doe",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`PeopleFilter Company fitler should generate the where variable of the GQL call 2`] = `
|
||||
exports[`PeopleFilter should render the filter fullname 2`] = `
|
||||
Object {
|
||||
"_not": Object {
|
||||
"_and": Array [
|
||||
Object {
|
||||
"firstname": Object {
|
||||
"_eq": "undefined",
|
||||
"_eq": "John",
|
||||
},
|
||||
},
|
||||
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",
|
||||
"_eq": "Doe",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@ -1,29 +1,37 @@
|
||||
import {
|
||||
assertFilterUseCompanySearch,
|
||||
assertFilterUsePeopleSearch,
|
||||
} from '../../../components/table/table-header/interface';
|
||||
import { GraphqlQueryPerson } from '../../../interfaces/person.interface';
|
||||
import { mockCompanyData } from '../../companies/__stories__/mock-data';
|
||||
import { defaultData } from '../default-data';
|
||||
import { companyFilter, fullnameFilter } from '../people-table';
|
||||
import { availableFilters } 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();
|
||||
}
|
||||
});
|
||||
for (const filter of availableFilters) {
|
||||
it(`should render the filter ${filter.key}`, () => {
|
||||
if (assertFilterUseCompanySearch(filter)) {
|
||||
const filterSelectedValue = filter.searchResultMapper(
|
||||
mockCompanyData[0],
|
||||
);
|
||||
for (const operand of filter.operands) {
|
||||
expect(
|
||||
filter.whereTemplate(operand, filterSelectedValue.value),
|
||||
).toMatchSnapshot();
|
||||
}
|
||||
}
|
||||
if (assertFilterUsePeopleSearch(filter)) {
|
||||
const filterSelectedValue = filter.searchResultMapper(JohnDoeUser);
|
||||
for (const operand of filter.operands) {
|
||||
expect(
|
||||
filter.whereTemplate(operand, filterSelectedValue.value),
|
||||
).toMatchSnapshot();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user