Beispiel #1
0
 it('parses queries with valid names from filepath', () => {
   expect(
     FindGraphQLTags.find(
       'graphql`query TestComponentQuery { me { id } }`;',
       './PathTo/SuperDuper/TestComponent.js',
       {validateNames: true},
     ),
   ).toEqual(['query TestComponentQuery { me { id } }']);
   expect(
     FindGraphQLTags.find(
       'graphql`query TestComponentQuery { me { id } }`;',
       './PathTo/SuperDuper/TestComponent.react.js',
       {validateNames: true},
     ),
   ).toEqual(['query TestComponentQuery { me { id } }']);
   expect(
     FindGraphQLTags.find(
       'graphql`query TestComponentQuery { me { id } }`;',
       './PathTo/SuperDuper/TestComponent.react.jsx',
       {validateNames: true},
     ),
   ).toEqual(['query TestComponentQuery { me { id } }']);
   expect(
     FindGraphQLTags.find(
       'graphql`query TestComponentQuery { me { id } }`;',
       './PathTo/SuperDuper/TestComponent/index.js',
       {validateNames: true},
     ),
   ).toEqual(['query TestComponentQuery { me { id } }']);
 });
Beispiel #2
0
 it('does not validate names when options is not set', () => {
   FindGraphQLTags.find(
     'graphql`query NotModuleName { me { id } }`;',
     '/path/to/FindGraphQLTags.js',
     {validateNames: false},
   );
 });
 it('parses queries with valid names from filepath', () => {
   expect(
     FindGraphQLTags.find(
       'graphql`query TestComponentQuery { me { id } }`;',
       './PathTo/SuperDuper/TestComponent.js',
     ),
   ).toEqual([
     {
       tag: 'graphql',
       template: 'query TestComponentQuery { me { id } }',
     },
   ]);
   expect(
     FindGraphQLTags.find(
       'graphql`query TestComponentQuery { me { id } }`;',
       './PathTo/SuperDuper/TestComponent.react.js',
     ),
   ).toEqual([
     {
       tag: 'graphql',
       template: 'query TestComponentQuery { me { id } }',
     },
   ]);
   expect(
     FindGraphQLTags.find(
       'graphql`query TestComponentQuery { me { id } }`;',
       './PathTo/SuperDuper/TestComponent.react.jsx',
     ),
   ).toEqual([
     {
       tag: 'graphql',
       template: 'query TestComponentQuery { me { id } }',
     },
   ]);
   expect(
     FindGraphQLTags.find(
       'graphql`query TestComponentQuery { me { id } }`;',
       './PathTo/SuperDuper/TestComponent/index.js',
     ),
   ).toEqual([
     {
       tag: 'graphql',
       template: 'query TestComponentQuery { me { id } }',
     },
   ]);
 });
 function find(text) {
   return FindGraphQLTags.find(text, '/path/to/FindGraphQLTags.js');
 }
Beispiel #5
0
 function find(text) {
   return FindGraphQLTags.find(text).map(tag => tag.template);
 }
Beispiel #6
0
 function find(text) {
   return FindGraphQLTags.find(text, '/path/to/FindGraphQLTags.js', {
     validateNames: true,
   });
 }
Beispiel #7
0
 expect(() =>
   FindGraphQLTags.find(
     'graphql`query NotModuleName { me { id } }`;',
     '/path/to/FindGraphQLTags.js',
     {validateNames: true},
   ),