Skip to content

Commit

Permalink
adds/rearranges tests for "comment line handling"
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanawesome committed Dec 8, 2022
1 parent ea9ede7 commit d57212f
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions packages/graphiql-react/src/editor/__tests__/tabs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,27 @@ describe('fuzzyExtractionOperationTitle', () => {
it('should return null for anonymous queries', () => {
expect(fuzzyExtractOperationName('{}')).toBeNull();
});
it('should not extract query names with comments', () => {
expect(
fuzzyExtractOperationName('# query My_3ExampleQuery() {}'),
).toBeNull();

describe('comment line handling', () => {
it('should not extract query names within commented out lines', () => {
expect(
fuzzyExtractOperationName('# query My_3ExampleQuery() {}'),
).toBeNull();
});
it('should extract query names when there is a single leading comment line', () => {
expect(
fuzzyExtractOperationName(
'# comment line 1 \n query MyExampleQueryWithSingleCommentLine() {}',
),
).toEqual('MyExampleQueryWithSingleCommentLine');
});
it('should extract query names when there are more than one leading comment lines', () => {
expect(
fuzzyExtractOperationName(
'# comment line 1 \n # comment line 2 \n query MyExampleQueryWithMultipleCommentLines() {}',
),
).toEqual('MyExampleQueryWithMultipleCommentLines');
});
});
});

Expand Down

0 comments on commit d57212f

Please sign in to comment.