organization?: { key: string };
property?: string;
query: { [x: string]: any };
- value?: Array<string>;
+ value?: string[];
}
-const LIST_SIZE = 10;
-
export default class LanguagesFilter extends React.Component<Props> {
static contextTypes = {
languages: PropTypes.object.isRequired
if (this.props.facet) {
languageKeys = difference(languageKeys, Object.keys(this.props.facet));
}
- return languageKeys
- .slice(0, LIST_SIZE)
- .map(key => ({ label: this.context.languages[key].name, value: key }));
+ return languageKeys.map(key => ({ label: this.context.languages[key].name, value: key }));
};
getSortedOptions = (facet: Facet = {}) =>
expect(wrapper).toMatchSnapshot();
expect(wrapper.find('Filter').shallow()).toMatchSnapshot();
});
-
-it('should render maximum 10 languages in the searchbox results', () => {
- const manyLanguages = {
- ...languages,
- c: { key: 'c', name: 'c' },
- d: { key: 'd', name: 'd' },
- e: { key: 'e', name: 'e' },
- f: { key: 'f', name: 'f' },
- g: { key: 'g', name: 'g' },
- h: { key: 'h', name: 'h' },
- i: { key: 'i', name: 'i' },
- k: { key: 'k', name: 'k' },
- l: { key: 'l', name: 'l' }
- };
- const wrapper = shallow(
- <LanguagesFilter
- query={{ languages: ['java', 'g'] }}
- value={['java', 'g']}
- facet={{ ...languagesFacet, g: 1 }}
- isFavorite={true}
- />,
- { context: { languages: manyLanguages } }
- );
- expect(wrapper).toMatchSnapshot();
-});
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`should render maximum 10 languages in the searchbox results 1`] = `
-<Filter
- facet={
- Object {
- "cs": 4,
- "g": 1,
- "java": 39,
- "js": 1,
- }
- }
- footer={
- <SearchableFilterFooter
- isFavorite={true}
- options={
- Array [
- Object {
- "label": "Flex",
- "value": "flex",
- },
- Object {
- "label": "PHP",
- "value": "php",
- },
- Object {
- "label": "Python",
- "value": "py",
- },
- Object {
- "label": "c",
- "value": "c",
- },
- Object {
- "label": "d",
- "value": "d",
- },
- Object {
- "label": "e",
- "value": "e",
- },
- Object {
- "label": "f",
- "value": "f",
- },
- Object {
- "label": "h",
- "value": "h",
- },
- Object {
- "label": "i",
- "value": "i",
- },
- Object {
- "label": "k",
- "value": "k",
- },
- ]
- }
- property="languages"
- query={
- Object {
- "languages": Array [
- "java",
- "g",
- ],
- }
- }
- />
- }
- getFacetValueForOption={[Function]}
- header={
- <FilterHeader
- name="projects.facets.languages"
- />
- }
- isFavorite={true}
- options={
- Array [
- "java",
- "cs",
- "g",
- "js",
- ]
- }
- property="languages"
- query={
- Object {
- "languages": Array [
- "java",
- "g",
- ],
- }
- }
- renderOption={[Function]}
- value={
- Array [
- "java",
- "g",
- ]
- }
-/>
-`;
-
exports[`should render the languages facet with the selected languages 1`] = `
<Filter
facet={