Created
January 18, 2018 00:02
-
-
Save jamesreggio/6f1c0dd668cac26fd437ba8af22951de to your computer and use it in GitHub Desktop.
Regression test for loss of data with overlapping fragments in apollo-cache-hermes
This file contains hidden or 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
import { GraphSnapshot } from '../../../../../src/GraphSnapshot'; | |
import { createSnapshot } from '../../../../helpers'; | |
describe(`overlapping fragments`, () => { | |
let snapshot: GraphSnapshot; | |
beforeAll(() => { | |
const cyclicRefQuery = ` | |
query { | |
myDetailedBar { | |
...DetailedBarFragment | |
} | |
myFooOrBar { | |
...FooFragment | |
...BarFragment | |
} | |
} | |
fragment FooFragment on Foo { | |
id | |
payload | |
} | |
fragment BarFragment on Bar { | |
id | |
fizz | |
} | |
fragment DetailedBarFragment on Bar { | |
...BarFragment | |
payload | |
} | |
`; | |
const result = createSnapshot( | |
{ | |
myDetailedBar: { | |
id: 'Bar:1', | |
fizz: 'buzz', | |
payload: 'huge', | |
}, | |
myFooOrBar: { | |
id: 'Bar:1', | |
fizz: 'buzz', | |
}, | |
}, | |
cyclicRefQuery | |
); | |
snapshot = result.snapshot; | |
}); | |
it(`writing an entity with overlapping fragment fields should not lose data`, () => { | |
const bar = snapshot.getNodeData('Bar:1'); | |
expect(bar.id).to.eq('Bar:1'); | |
expect(bar.fizz).to.eq('buzz'); | |
expect(bar.payload).to.eq('huge'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment