This repository has been archived by the owner on Mar 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
Gene Refine price fixes #406
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4b1a0d9
Initial work on price fixes for Gene
orta a969f79
Merge branch 'master' of https://github.com/artsy/emission into more-…
orta 60ffa51
Make master green, and remove all console errors
orta 3f4cd18
Remove any possible .00's from strings coming in as options for price…
orta 0408e54
Merge branch 'master' into more-gene-refine
orta 3ad6c82
Ensure that the gene refine metadata doesn't push off the refine button
orta fe4204b
Changelog
orta 3751058
Merge master
orta 2c28874
Fix readme
orta 7475f77
Prepare for refine
orta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -198,15 +198,55 @@ exports[`test looks like expected 1`] = ` | |
}, | ||
Object { | ||
"fontStyle": "italic", | ||
"marginTop": 4, | ||
"marginTop": 2, | ||
"maxWidth": 245, | ||
}, | ||
Object { | ||
"fontFamily": "AGaramondPro-Regular", | ||
}, | ||
] | ||
}> | ||
12 works ・ | ||
12 works ・ Painting ・ Below $100,000 | ||
</Text> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. previously it was undefined, so it didn't show up on the bar |
||
<TouchableHighlight | ||
activeOpacity={1} | ||
onPress={[Function]} | ||
style={ | ||
Object { | ||
"alignItems": "center", | ||
"backgroundColor": "rgba(255, 255, 255, 1)", | ||
"borderColor": "#e5e5e5", | ||
"borderWidth": 1, | ||
"height": 26, | ||
"justifyContent": "center", | ||
"width": 80, | ||
} | ||
} | ||
underlayColor="#6e1fff"> | ||
<View> | ||
<Text | ||
accessible={true} | ||
allowFontScaling={true} | ||
ellipsizeMode="tail" | ||
style={ | ||
Array [ | ||
Object { | ||
"fontSize": 12, | ||
}, | ||
Object { | ||
"color": "black", | ||
"fontFamily": "AGaramondPro-Regular", | ||
"opacity": 1, | ||
}, | ||
Object { | ||
"fontFamily": "Avant Garde Gothic ITCW01Dm", | ||
}, | ||
] | ||
}> | ||
REFINE | ||
</Text> | ||
</View> | ||
</TouchableHighlight> | ||
</View> | ||
<View | ||
style={ | ||
|
@@ -276,9 +316,9 @@ exports[`test looks like expected 1`] = ` | |
} | ||
queryState={ | ||
Object { | ||
"selectedMedium": undefined, | ||
"selectedPriceRange": undefined, | ||
"sort": "-year", | ||
"selectedMedium": "painting", | ||
"selectedPriceRange": "*-100000", | ||
"sort": "-partner_updated_at", | ||
} | ||
} | ||
resolveQuery={[Function]} /> | ||
|
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 |
---|---|---|
|
@@ -5,6 +5,9 @@ import 'react-native' | |
import React from 'react' | ||
import renderer from 'react-test-renderer' | ||
|
||
var refineCallbackPromise = () => Promise.resolve() | ||
jest.mock('../../native_modules/refine_callback.js', () => { return { triggerRefine: () => refineCallbackPromise() }}) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. replaces the function which normally triggers the native code with our own instantly resolved promise |
||
// Stub out these views for simplicities sake | ||
jest.mock('../../components/gene/header', () => 'Header') | ||
jest.mock('../../components/gene/artworks', () => 'Artworks') | ||
|
@@ -16,6 +19,83 @@ jest.mock('../../components/switch_view', () => 'Spinner') | |
|
||
import Gene from '../gene' | ||
|
||
describe('state', () => { | ||
it('sets up the initial state in componentWillMount', () => { | ||
const gene = new Gene() | ||
gene.props = { | ||
medium: 'glitch', | ||
price_range: '*-*' | ||
} | ||
|
||
gene.componentWillMount() | ||
|
||
expect(gene.state).toEqual({ | ||
selectedTabIndex: 0, | ||
showingStickyHeader: true, | ||
sort: '-partner_updated_at', | ||
selectedMedium: 'glitch', | ||
selectedPriceRange: '*-*', | ||
}) | ||
}) | ||
|
||
it('updates from the switch change the selectedTabIndex', ()=> { | ||
const gene = new Gene() | ||
const switchEvent = { | ||
nativeEvent: { | ||
selectedIndex: 23 | ||
} | ||
} | ||
|
||
gene.setState = jest.fn() | ||
gene.switchSelectionDidChange(switchEvent) | ||
|
||
expect(gene.setState).lastCalledWith({selectedTabIndex: 23}) | ||
}) | ||
|
||
// OK, this is a long one, but it's important. | ||
|
||
it('updates the state with new data from Eigen', () => { | ||
// Setup a Gene Component like normal | ||
const gene = new Gene() | ||
gene.setState = jest.fn() | ||
gene.props = { | ||
medium: 'glitch', | ||
price_range: '*-*', | ||
relay: { setVariables: jest.fn() }, | ||
gene: { filtered_artworks: { aggregations: []} } | ||
} | ||
|
||
// The data we expect back from Eigen when you've hit the refine button, | ||
// this is a promise that Eigen would normally resolve (via the modal) | ||
refineCallbackPromise = () => Promise.resolve({ | ||
medium: 'porcupines', | ||
selectedPrice: '1000-80000', | ||
sort: '-desc' | ||
}) | ||
|
||
// Mount it to set up initial state | ||
gene.componentWillMount() | ||
|
||
// Then when the gene has been tapped, it returns the refine data above | ||
return gene.refineTapped().then(() => { | ||
|
||
// This should trigger new state inside the component | ||
expect(gene.setState).lastCalledWith({ | ||
selectedMedium: 'porcupines', | ||
selectedPriceRange: '1000-80000', | ||
sort: '-desc' | ||
}) | ||
|
||
// As well as trigger new state for Relay ( triggering a new call to metaphysics ) | ||
expect(gene.props.relay.setVariables).lastCalledWith({ | ||
medium: 'porcupines', | ||
price_range: '1000-80000', | ||
sort: '-desc' | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
describe('handling price ranges', () => { | ||
it('is empty when *-*', () => { | ||
const gene = new Gene() | ||
|
@@ -72,7 +152,7 @@ it('looks like expected', () => { | |
} | ||
} | ||
const tree = renderer.create( | ||
<Gene geneID={props.gene.name} gene={props.gene}/> | ||
<Gene geneID={props.gene.name} medium="painting" price_range="*-100000" gene={props.gene}/> | ||
).toJSON() | ||
expect(tree).toMatchSnapshot() | ||
}) |
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 |
---|---|---|
|
@@ -80,4 +80,4 @@ | |
"peerDependencies": { | ||
"babel-relay-plugin": "^0.9.0" | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was planning on adding this to vscode-jest, but for now this is a pretty good tool for poking around at the state of your tests.