|
| 1 | +import assert from 'node:assert/strict'; |
| 2 | +import test from 'node:test'; |
| 3 | +import { main } from '../../src/index.js'; |
| 4 | +import * as graphqlCodegen from '../../src/plugins/graphql-codegen/index.js'; |
| 5 | +import { resolve, join } from '../../src/util/path.js'; |
| 6 | +import baseArguments from '../helpers/baseArguments.js'; |
| 7 | +import baseCounters from '../helpers/baseCounters.js'; |
| 8 | +import { getManifest, pluginConfig as config } from '../helpers/index.js'; |
| 9 | + |
| 10 | +const cwd = resolve('fixtures/plugins/graphql-codegen'); |
| 11 | +const manifest = getManifest(cwd); |
| 12 | + |
| 13 | +test('Find dependencies in graphql-codegen configuration (json)', async () => { |
| 14 | + const configFilePath = join(cwd, 'package.json'); |
| 15 | + const dependencies = await graphqlCodegen.findDependencies(configFilePath, { manifest, config }); |
| 16 | + assert.deepEqual(dependencies, ['@graphql-codegen/client-preset']); |
| 17 | +}); |
| 18 | + |
| 19 | +test('Find dependencies in graphql-codegen configuration (codegen.ts)', async () => { |
| 20 | + const configFilePath = join(cwd, 'codegen.ts'); |
| 21 | + const dependencies = await graphqlCodegen.findDependencies(configFilePath, { manifest, config }); |
| 22 | + assert.deepEqual(dependencies, [ |
| 23 | + '@graphql-codegen/near-operation-file-preset', |
| 24 | + '@graphql-codegen/schema-ast', |
| 25 | + '@graphql-codegen/introspection', |
| 26 | + '@graphql-codegen/typescript', |
| 27 | + '@graphql-codegen/typescript-operations', |
| 28 | + '@graphql-codegen/typescript-urql', |
| 29 | + '@graphql-codegen/typescript-operations', |
| 30 | + '@graphql-codegen/typescript-msw', |
| 31 | + ]); |
| 32 | +}); |
| 33 | + |
| 34 | +test('Find dependencies in graphql-codegen configuration (codegen.ts function)', async () => { |
| 35 | + const { issues, counters } = await main({ |
| 36 | + ...baseArguments, |
| 37 | + cwd, |
| 38 | + }); |
| 39 | + |
| 40 | + assert(issues.unlisted['codegen.ts']['@graphql-codegen/near-operation-file-preset']); |
| 41 | + assert(issues.unlisted['codegen.ts']['@graphql-codegen/schema-ast']); |
| 42 | + assert(issues.unlisted['codegen.ts']['@graphql-codegen/introspection']); |
| 43 | + assert(issues.unlisted['codegen.ts']['@graphql-codegen/typescript']); |
| 44 | + assert(issues.unlisted['codegen.ts']['@graphql-codegen/typescript-operations']); |
| 45 | + assert(issues.unlisted['codegen.ts']['@graphql-codegen/typescript-urql']); |
| 46 | + assert(issues.unlisted['codegen.ts']['@graphql-codegen/typescript-msw']); |
| 47 | + assert(issues.unlisted['package.json']['@graphql-codegen/client-preset']); |
| 48 | + |
| 49 | + assert.deepEqual(counters, { |
| 50 | + ...baseCounters, |
| 51 | + unlisted: 8, |
| 52 | + devDependencies: 1, |
| 53 | + processed: 1, |
| 54 | + total: 1, |
| 55 | + }); |
| 56 | +}); |
0 commit comments