-
Notifications
You must be signed in to change notification settings - Fork 749
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 563 - Resources Filtering (#1200)
- Loading branch information
1 parent
a1d7844
commit 81816fc
Showing
6 changed files
with
166 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// @flow | ||
import { mount } from 'enzyme'; | ||
import React from 'react'; | ||
import { Resources } from '../index'; | ||
|
||
const component = ( | ||
<Resources | ||
resources={[ | ||
{ | ||
name: '7 Cups', | ||
link: 'https://www.7cups.com', | ||
tags: [ | ||
'therapy', | ||
'counseling', | ||
'paid', | ||
'free', | ||
'texting', | ||
'android', | ||
'iOS', | ||
], | ||
languages: ['English', 'Español'], | ||
type: 'Services', | ||
}, | ||
{ | ||
name: 'A Canvas of the Minds', | ||
link: 'https://acanvasoftheminds.com/', | ||
tags: ['free', 'blog'], | ||
languages: ['English'], | ||
type: 'Communities', | ||
}, | ||
]} | ||
/> | ||
); | ||
|
||
describe('Resources', () => { | ||
it('filters when tag selected', () => { | ||
const wrapper = mount(component); | ||
expect(wrapper.find('.resource').length).toEqual(2); | ||
wrapper.find('.tagAutocomplete').simulate('focus'); | ||
expect(wrapper.find('.tagMenu').exists()).toEqual(true); | ||
const id = wrapper | ||
.find('.tagLabel') | ||
.at(0) | ||
.text(); | ||
wrapper | ||
.find('.tagLabel') | ||
.at(0) | ||
.simulate('click'); | ||
expect(wrapper.find('.checkboxLabel').text()).toEqual(id); | ||
expect(wrapper.find('.resource').length).toEqual(1); | ||
expect(wrapper.find('.tag').findWhere(t => t.text() === id).length).toEqual(1); | ||
}); | ||
|
||
it('unfilters when tag unselected', () => { | ||
const wrapper = mount(component); | ||
expect(wrapper.find('.resource').length).toEqual(2); | ||
wrapper.find('.tagAutocomplete').simulate('focus'); | ||
const id = wrapper | ||
.find('.tagLabel') | ||
.at(0) | ||
.text(); | ||
wrapper | ||
.find('.tagLabel') | ||
.at(0) | ||
.simulate('click'); | ||
expect(wrapper.find('.resource').length).toEqual(1); | ||
wrapper.find(`input#${id}`).prop('onChange')({ | ||
currentTarget: { checked: false }, | ||
}); | ||
wrapper.update(); | ||
expect(wrapper.find('.resource').length).toEqual(2); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters