Skip to content
This repository has been archived by the owner on Nov 6, 2021. It is now read-only.

Commit

Permalink
test: fixed commonJs test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
favna committed Mar 5, 2021
1 parent b58a3aa commit f037f6c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
33 changes: 22 additions & 11 deletions __tests__/commonJs.test.js
Original file line number Diff line number Diff line change
@@ -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™'
})
])
);
});
});
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default async (): Promise<Config.InitialOptions> => ({
preset: 'ts-jest',
testEnvironment: 'node',
testRunner: 'jest-circus/runner',
testMatch: ['<rootDir>/__tests__/*.test.ts'],
testMatch: ['<rootDir>/__tests__/*.test.{js,ts}'],
setupFilesAfterEnv: ['<rootDir>/__tests__/jest.setup.ts'],
globals: {
'ts-jest': {
Expand Down

0 comments on commit f037f6c

Please sign in to comment.