From f037f6c2a481361205f2455489a234312e35a2a4 Mon Sep 17 00:00:00 2001 From: Jeroen Claassens Date: Fri, 5 Mar 2021 23:04:30 +0100 Subject: [PATCH] test: fixed commonJs test suite --- __tests__/commonJs.test.js | 33 ++++++++++++++++++++++----------- jest.config.ts | 2 +- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/__tests__/commonJs.test.js b/__tests__/commonJs.test.js index e2f270cd..8eef827a 100644 --- a/__tests__/commonJs.test.js +++ b/__tests__/commonJs.test.js @@ -1,17 +1,28 @@ /* eslint-disable @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports */ -const { getGamesAmerica } = require('../src'); +const { getQueriedGamesAmerica } = require('../src'); -describe('getGamesAmerica - CommonJS', () => { - test('should allow custom limit', async () => { - const data = await getGamesAmerica({ limit: 1 }); - expect(data).toBeInstanceOf(Object); - expect(data).toHaveLength(1); - }); +describe('CommonJS Require test', () => { + test('GIVEN Pokemon THEN returns results with some known games', async () => { + const data = await getQueriedGamesAmerica('Pokemon'); - test('should allow unfiltered shop', async () => { - jest.setTimeout(60000); - const data = await getGamesAmerica(); expect(data).toBeInstanceOf(Object); - expect(data.length).toBeGreaterThanOrEqual(1500); + expect(data.length).toBeGreaterThanOrEqual(20); + + expect(data).toEqual( + expect.arrayContaining([ + // Expect Pokémon™ Legends: Arceus to be in the data + expect.objectContaining({ + title: 'Pokémon™ Legends: Arceus' + }), + // Expect Pokémon™ Brilliant Diamond to be in the data + expect.objectContaining({ + title: 'Pokémon™ Brilliant Diamond' + }), + // Expect New Pokémon Snap to be in the data + expect.objectContaining({ + title: 'New Pokémon Snap™' + }) + ]) + ); }); }); diff --git a/jest.config.ts b/jest.config.ts index d108dc34..6e5844a9 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -6,7 +6,7 @@ export default async (): Promise => ({ preset: 'ts-jest', testEnvironment: 'node', testRunner: 'jest-circus/runner', - testMatch: ['/__tests__/*.test.ts'], + testMatch: ['/__tests__/*.test.{js,ts}'], setupFilesAfterEnv: ['/__tests__/jest.setup.ts'], globals: { 'ts-jest': {