Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
acao committed Jan 24, 2024
1 parent 739256b commit e2179ab
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ export class MessageProcessor {
}

async _updateGraphQLConfig() {
console.log('updating config');
const settings = await this._connection.workspace.getConfiguration({
section: 'graphql-config',
});
Expand Down Expand Up @@ -237,7 +236,6 @@ export class MessageProcessor {
rootDir,
};
try {
console.log(this._loadConfigOptions);
// reload the graphql cache
this._graphQLCache = await getGraphQLCache({
parser: this._parser,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ import { NoopLogger } from '../Logger';
import { pathToFileURL } from 'node:url';
import mockfs from 'mock-fs';
import { join } from 'node:path';
import { mock } from 'fetch-mock';
import e from 'express';
import { readFileSync, readdirSync } from 'node:fs';

jest.mock('node:fs', () => ({
...jest.requireActual<typeof import('fs')>('fs'),
Expand Down Expand Up @@ -546,7 +543,7 @@ describe('MessageProcessor with no config', () => {
),
);
});
it.skip('initializes when presented with a valid config later', async () => {
it('initializes when presented with a valid config later', async () => {
mockProcessor('query { foo }');
await messageProcessor.handleInitializeRequest(
// @ts-ignore
Expand All @@ -564,36 +561,36 @@ describe('MessageProcessor with no config', () => {
},
});
expect(messageProcessor._isInitialized).toEqual(false);
mockfs.restore();
expect(loggerSpy).toHaveBeenCalledTimes(1);

mockfs({
[mockRoot]: mockfs.directory({
mode: 0o755,
items: {
'schema.graphql':
'type Query { foo: String }\nschema { query: Query }',
'graphql.config.js': mockfs.file({
content: 'module.exports = { schema: "schema.graphql" };',
mode: 0o644,
}),
'query.graphql': 'query { foo }',
// 'node_modules/graphql-config/node_modules': mockfs.load(
// 'node_modules/graphql-config/node_modules',
// ),
},
}),
});
// console.log(readdirSync(`${mockRoot}`));
await messageProcessor.handleDidOpenOrSaveNotification({
textDocument: {
text: 'module.exports = { schema: `schema.graphql` }',
uri: `${mockRoot}/graphql.config.js`,
version: 2,
},
});

expect(messageProcessor._isGraphQLConfigMissing).toEqual(false);
// todo: get mockfs working with in-test file changes
// mockfs.restore();
// mockfs({
// [mockRoot]: mockfs.directory({
// mode: 0o755,
// items: {
// 'schema.graphql':
// 'type Query { foo: String }\nschema { query: Query }',
// 'graphql.config.js': mockfs.file({
// content: 'module.exports = { schema: "schema.graphql" };',
// mode: 0o644,
// }),
// 'query.graphql': 'query { foo }',
// // 'node_modules/graphql-config/node_modules': mockfs.load(
// // 'node_modules/graphql-config/node_modules',
// // ),
// },
// }),
// });
// // console.log(readdirSync(`${mockRoot}`));
// await messageProcessor.handleDidOpenOrSaveNotification({
// textDocument: {
// text: 'module.exports = { schema: `schema.graphql` }',
// uri: `${mockRoot}/graphql.config.js`,
// version: 2,
// },
// });

// expect(messageProcessor._isGraphQLConfigMissing).toEqual(false);

// expect(loggerSpy).toHaveBeenCalledWith(
// expect.stringMatching(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ describe('findGraphQLTags', () => {
const findGraphQLTags = (text: string, ext: SupportedExtensionsEnum) =>
baseFindGraphQLTags(text, ext, '', logger);

it('returns empty for files without asts', () => {
const text = '// just a comment';
const contents = findGraphQLTags(text, '.js');
expect(contents.length).toEqual(0);
});

it('finds queries in tagged templates', async () => {
const text = `
// @flow
Expand Down

0 comments on commit e2179ab

Please sign in to comment.