Skip to content

Commit

Permalink
fix: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
acao committed May 1, 2024
1 parent 274674f commit 3d9df81
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 29 deletions.
2 changes: 0 additions & 2 deletions examples/monaco-graphql-react-vite/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import monacoEditorPlugin from 'vite-plugin-monaco-editor';
import { resolve } from 'node:path';
import { realpathSync } from 'node:fs';

export default defineConfig({
build: {
Expand Down
32 changes: 16 additions & 16 deletions packages/codemirror-graphql/src/__tests__/hint-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ function getExpectedSuggestions(list: IHint[]) {
}

describe('graphql-hint', () => {
it.skip('attaches a GraphQL hint function with correct mode/hint options', () => {
it('attaches a GraphQL hint function with correct mode/hint options', () => {
const editor = createEditorWithHint();
expect(editor.getHelpers(editor.getCursor(), 'hint')).not.toHaveLength(0);
});

it.skip('provides correct initial keywords for executable definitions', async () => {
it('provides correct initial keywords for executable definitions', async () => {
const suggestions = await getHintSuggestions(
'',
{ line: 0, ch: 0 },
Expand All @@ -104,7 +104,7 @@ describe('graphql-hint', () => {
expect(suggestions?.list).toEqual(expectedSuggestions);
});

it.skip('provides correct initial keywords for unknown definitions', async () => {
it('provides correct initial keywords for unknown definitions', async () => {
const suggestions = await getHintSuggestions('', { line: 0, ch: 0 });
const list = [
{ text: 'extend' },
Expand All @@ -124,14 +124,14 @@ describe('graphql-hint', () => {
expect(suggestions?.list).toEqual(expectedSuggestions);
});

it.skip('provides correct initial keywords after filtered', async () => {
it('provides correct initial keywords after filtered', async () => {
const suggestions = await getHintSuggestions('q', { line: 0, ch: 1 });
const list = [{ text: '{' }, { text: 'query' }];
const expectedSuggestions = getExpectedSuggestions(list);
expect(suggestions?.list).toEqual(expectedSuggestions);
});

it.skip('provides correct field name suggestions', async () => {
it('provides correct field name suggestions', async () => {
const suggestions = await getHintSuggestions('{ ', { line: 0, ch: 2 });
const list = [
{
Expand Down Expand Up @@ -187,7 +187,7 @@ describe('graphql-hint', () => {
expect(suggestions?.list).toEqual(expectedSuggestions);
});

it.skip('provides correct field name suggestions after filtered', async () => {
it('provides correct field name suggestions after filtered', async () => {
const suggestions = await getHintSuggestions('{ i', { line: 0, ch: 3 });
const list = [
{
Expand Down Expand Up @@ -215,7 +215,7 @@ describe('graphql-hint', () => {
expect(suggestions?.list).toEqual(expectedSuggestions);
});

it.skip('provides correct field name suggestions when using aliases', async () => {
it('provides correct field name suggestions when using aliases', async () => {
const suggestions = await getHintSuggestions('{ aliasTest: first { ', {
line: 0,
ch: 21,
Expand Down Expand Up @@ -247,7 +247,7 @@ describe('graphql-hint', () => {
expect(suggestions?.list).toEqual(expectedSuggestions);
});

it.skip('provides correct field name suggestion indentation', async () => {
it('provides correct field name suggestion indentation', async () => {
const suggestions = await getHintSuggestions('{\n ', { line: 1, ch: 2 });
expect(suggestions?.from).toEqual({ line: 1, ch: 2, sticky: null });
expect(suggestions?.to).toEqual({ line: 1, ch: 2, sticky: null });
Expand Down Expand Up @@ -863,7 +863,7 @@ describe('graphql-hint', () => {
expect(suggestions?.list).toEqual(expectedSuggestions);
});

it.skip('provides correct field name suggestion inside type-less inline fragment', async () => {
it('provides correct field name suggestion inside type-less inline fragment', async () => {
const suggestions = await getHintSuggestions(
'fragment Foo on First { ... { ',
{ line: 0, ch: 30 },
Expand Down Expand Up @@ -896,7 +896,7 @@ describe('graphql-hint', () => {
expect(suggestions?.list).toEqual(expectedSuggestions);
});

it.skip('provides correct boolean suggestions', async () => {
it('provides correct boolean suggestions', async () => {
const suggestions1 = await getHintSuggestions('{ hasArgs(listBoolean: [ ', {
line: 0,
ch: 27,
Expand Down Expand Up @@ -945,7 +945,7 @@ describe('graphql-hint', () => {
expect(suggestions3?.list).toEqual(expectedSuggestions3);
});

it.skip('provides correct variable type suggestions', async () => {
it('provides correct variable type suggestions', async () => {
const suggestions = await getHintSuggestions('query($foo: ', {
line: 0,
ch: 12,
Expand Down Expand Up @@ -992,7 +992,7 @@ describe('graphql-hint', () => {
expect(suggestions?.list).toEqual(expectedSuggestions);
});

it.skip('provides correct variable type suggestions inside list type', async () => {
it('provides correct variable type suggestions inside list type', async () => {
const suggestions = await getHintSuggestions('query($foo: [ ', {
line: 0,
ch: 14,
Expand Down Expand Up @@ -1038,7 +1038,7 @@ describe('graphql-hint', () => {
const expectedSuggestions = getExpectedSuggestions(list);
expect(suggestions?.list).toEqual(expectedSuggestions);
});
it.skip('provides no suggestions', async () => {
it('provides no suggestions', async () => {
const list: IHint[] = [];
const expectedSuggestions = getExpectedSuggestions(list);

Expand Down Expand Up @@ -1093,7 +1093,7 @@ describe('graphql-hint', () => {
);
expect(suggestions7?.list).toEqual(expectedSuggestions);
});
it.skip('provides variable completion for arguments', async () => {
it('provides variable completion for arguments', async () => {
const expectedSuggestions = getExpectedSuggestions([
{ text: 'string', type: GraphQLString },
{ text: 'listString', type: new GraphQLList(GraphQLString) },
Expand All @@ -1108,7 +1108,7 @@ describe('graphql-hint', () => {
);
expect(suggestions9?.list).toEqual(expectedSuggestions);
});
it.skip('provides variable completion for arguments with $', async () => {
it('provides variable completion for arguments with $', async () => {
const expectedSuggestions = getExpectedSuggestions([
{ text: 'string', type: GraphQLString },
{ text: 'listString', type: new GraphQLList(GraphQLString) },
Expand All @@ -1123,7 +1123,7 @@ describe('graphql-hint', () => {
);
expect(suggestions9?.list).toEqual(expectedSuggestions);
});
it.skip('provides correct field name suggestions for an interface type', async () => {
it('provides correct field name suggestions for an interface type', async () => {
const suggestions = await getHintSuggestions(
'{ first { ... on TestInterface { ',
{
Expand Down
4 changes: 2 additions & 2 deletions packages/codemirror-graphql/src/hint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ CodeMirror.registerHelper(
editor: CodeMirror.Editor,
options: GraphQLHintOptions,
): IHints | undefined => {
const { schema, externalFragments } = options;
const { schema, externalFragments, autocompleteOptions } = options;
if (!schema) {
return;
}
Expand All @@ -95,7 +95,7 @@ CodeMirror.registerHelper(
position,
token,
externalFragments,
options?.autocompleteOptions,
autocompleteOptions,
);

const results = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ query Test {
...FragmentsComment
}
}
`);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,6 @@ export function findGraphQLTags(
const getReplacementString = (quasi: string, nextQuasi: string) => {
const trimmed = quasi.trimEnd();
const trimmedNext = nextQuasi.trimStart();
console.log({
trimmed,
trimmedNext,
endsWith: trimmed.endsWith('{'),
startsWith: trimmedNext.startsWith('}'),
});
// only actually empty leaf field expressions
if (trimmed.endsWith('{') && trimmedNext.startsWith('}')) {
return quasi + '__typename';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ const typeSystemKinds: Kind[] = [

const getParsedMode = (sdl: string | undefined): GraphQLDocumentMode => {
let mode = GraphQLDocumentMode.UNKNOWN;
console.log(mode);
if (sdl) {
try {
visit(parse(sdl), {
Expand Down Expand Up @@ -199,7 +198,6 @@ export function getAutocompleteSuggestions(

const state =
token.state.kind === 'Invalid' ? token.state.prevState : token.state;
console.log(token.state.kind);
// relieve flow errors by checking if `state` exists
if (!state) {
return [];
Expand Down

0 comments on commit 3d9df81

Please sign in to comment.