Skip to content

Commit

Permalink
Add Swift code generation test that verifies that, when there are nes…
Browse files Browse the repository at this point in the history
…ted fragment refrences, the correct source + fragments is generated for the operation id mapping file
  • Loading branch information
Paul Kompfner committed Jun 28, 2017
1 parent c77c7f0 commit c59e7e8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/swift/__snapshots__/codeGeneration.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,21 @@ exports[`Swift code generation #classDeclarationForOperation() when generateOper
}"
`;
exports[`Swift code generation #classDeclarationForOperation() when generateOperationIds is specified should generate appropriate operation id mapping source when there are nested fragment references 1`] = `
"query Hero {
hero {
...HeroDetails
}
}
fragment HeroDetails on Character {
...HeroName
appearsIn
}
fragment HeroName on Character {
name
}"
`;
exports[`Swift code generation #initializerDeclarationForProperties() should generate initializer for a property 1`] = `
"public init(episode: Episode) {
self.episode = episode
Expand Down
20 changes: 20 additions & 0 deletions test/swift/codeGeneration.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,26 @@ describe('Swift code generation', function() {

expect(output1).toBe(output2);
});

test(`should generate appropriate operation id mapping source when there are nested fragment references`, function() {
const source = `
query Hero {
hero {
...HeroDetails
}
}
fragment HeroName on Character {
name
}
fragment HeroDetails on Character {
...HeroName
appearsIn
}
`;
const context = compileFromSource(source, true);
expect(context.operations['Hero'].sourceWithFragments).toMatchSnapshot();
});

});
});

Expand Down

0 comments on commit c59e7e8

Please sign in to comment.