Skip to content

Instantly share code, notes, and snippets.

@jeznag jeznag/test-for-mutation

Last active Aug 14, 2018
What would you like to do?
it('should trigger mutation when submit button clicked', async () => {
// NB submit button relies on the redux store having valid data
// which is why I set it here
set('reduxState', {
selectedMeters: [123],
selectedMeasurements: ['elec_power_real'],
exportParameters: {
dateRange: {
start: new Date(Date.UTC(2017, 0, 1)),
finish: new Date(Date.UTC(2018, 0, 1))
availableOptions: {
availableAggregationLevels: ['123'],
availableTimeAggregationLevels: ['sdfs'],
availableFileTypes: ['basd'],
availableTimeZones: ['45']
const button = getWrapper('button');
// NB - without this, the mutation will still be processing when the expectation fires
// This is a technique from the official Apollo guide:
await wait(0);
// pretty hacky but the best I could come up with
const result = JSON.parse(
expect(; //tslint:disable-line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.