Skip to content

Commit

Permalink
Feat(typegen): added tests for ignore tag
Browse files Browse the repository at this point in the history
  • Loading branch information
largis21 committed May 20, 2024
1 parent 8e5d493 commit f2b3598
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,41 @@ describe('findQueries', () => {
expect(queries.length).toBe(1)
expect(queries[0].result).toBe('*[_type == "foo bar"]')
})

test('will ignore declarations with ignore tag', () => {
const source = `
import { groq } from "groq";
// @sanity-typegen-ignore
const postQuery = groq\`*[_type == "foo"]\`
`

const queries = findQueriesInSource(source, __filename, undefined)
expect(queries.length).toBe(0)
})

test('will ignore export named declarations with ignore tag', () => {
const source = `
import { groq } from "groq";
// @sanity-typegen-ignore
export const postQuery = groq\`*[_type == "foo"]\`
`

const queries = findQueriesInSource(source, __filename, undefined)
expect(queries.length).toBe(0)
})

test('will ignore declarations with ignore tag, even with multiple comments above declaration', () => {
const source = `
import { groq } from "groq";
// This is a query that queries posts
// @sanity-typegen-ignore
export const postQuery = groq\`*[_type == "foo"]\`
`

const queries = findQueriesInSource(source, __filename, undefined)
expect(queries.length).toBe(0)
})
})

0 comments on commit f2b3598

Please sign in to comment.