Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 0 additions & 64 deletions __tests__/keywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { postsFixture } from './fixture/post';
import { DataSource } from 'typeorm';
import createOrGetConnection from '../src/db';
import { updateFlagsStatement } from '../src/common';
import { keywordsFixture } from './fixture/keywords';

let con: DataSource;
let state: GraphQLTestingState;
Expand Down Expand Up @@ -433,66 +432,3 @@ describe('keywords flags field', () => {
expect(keyword?.flags).toEqual({});
});
});

describe('query autocompleteKeywords', () => {
const QUERY = /* GraphQL */ `
query AutocompleteKeywords($query: String!, $limit: Int) {
autocompleteKeywords(query: $query, limit: $limit) {
keyword
title
}
}
`;

beforeEach(async () => {
await saveFixtures(con, Keyword, keywordsFixture);
});

it('should return autocomplete allowed keywords when not logged in', async () => {
const res = await client.query(QUERY, {
variables: {
query: 'dev',
},
});
expect(res.errors).toBeFalsy();
expect(res.data.autocompleteKeywords).toEqual(
expect.arrayContaining([
{ keyword: 'webdev', title: 'Web Development' },
{ keyword: 'development', title: null },
]),
);
});

it('should return autocomplete results', async () => {
loggedUser = '1';

const res = await client.query(QUERY, {
variables: {
query: 'dev',
},
});
expect(res.errors).toBeFalsy();
expect(res.data.autocompleteKeywords).toEqual(
expect.arrayContaining([
{ keyword: 'webdev', title: 'Web Development' },
{ keyword: 'web-development', title: null },
{ keyword: 'development', title: null },
]),
);
});

it('should limit autocomplete results', async () => {
loggedUser = '1';

const res = await client.query(QUERY, {
variables: {
query: 'dev',
limit: 1,
},
});
expect(res.errors).toBeFalsy();
expect(res.data.autocompleteKeywords).toEqual([
{ keyword: 'development', title: null },
]);
});
});
Loading