/* eslint-disable no-console */ /* eslint-disable prefer-arrow-callback */ import expect from 'expect'; import { createTestClient } from 'apollo-server-testing'; import ggl from 'graphql-tag'; import config from '../../../config'; import { createServer } from '../../../src/server'; import { createTestApiServer } from '../../utils'; import { fixtures } from './fixtures'; describe('[queries] channel search queries', function () { before('create graphql server', async function () { const { apollo, server } = await createServer(); this.apollo = apollo; this.server = server; this.client = createTestClient(this.apollo); }); before('create api server', async function () { const { server } = await createTestApiServer(config.aurum); this.apiServer = server; }); after('stop server', async function () { await this.server.close(); await this.apiServer.close(); }); describe('with channel insights field', function () { before('reset api calls', function () { this.apiServer.reset(); }); before('setup aurum calls', function () { this.apiServer.mockResponse({ method: 'GET', url: '/v2/channels/search', response: { statusCode: 200, data: fixtures.aurum.instagram, }, }); }); before('execute query', async function () { const { client: { query }, } = this; const QUERY = ggl` query channelSearch( $page: Int = 1, $query: ChannelSearchQuery, $sort: ChannelSearchSort ) { channelSearch(page: $page, query: $query, sort: $sort) { data { id insights { ... on PlatformInsights { followedBy follows media } } } } } `; this.response = await query({ query: QUERY, variables: { query: { platforms: ['platform'] }, sort: { createdAt: -1 }, }, }); }); it('should not have errors', function () { expect(this.response.errors).toNotExist(); }); it('should have correct api requests', function () { expect(this.aurumServer.requests()).toMatchSnapshot(this); }); it('should have correct response', function () { expect(this.response).toMatchSnapshot(this); }); }); });