From 1033ad9dc22b99a3126573d25c240a39d90c8989 Mon Sep 17 00:00:00 2001 From: Tee Date: Sun, 14 Mar 2021 21:33:46 -0400 Subject: [PATCH] Add tests for card enums --- test/cardService.test.ts | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/test/cardService.test.ts b/test/cardService.test.ts index 06b82bf..7a711e8 100644 --- a/test/cardService.test.ts +++ b/test/cardService.test.ts @@ -1,6 +1,10 @@ -import { findCardByID, findCardsByQueries, getAllCards } from '../src/services/cardService'; +import { findCardByID, findCardsByQueries, getAllCards, getSupertypes, getSubtypes, getTypes, getRarities } from "../src/services/cardService"; import { Query } from "../src/interfaces/query"; import { Card } from "../src/interfaces/card"; +import { Type } from '../src/enums/type'; +import { Supertype } from '../src/enums/supertype'; +import { Subtype } from '../src/enums/subtype'; +import { Rarity } from '../src/enums/rarity'; describe('Card Service', () => { it('should get a single card using query parameters', async () => { @@ -22,4 +26,36 @@ describe('Card Service', () => { const results: Card[] = await getAllCards(); expect(results).toHaveLength(250); }); + + it('should get a list of card supertypes', async () => { + const expected: string[] = Object.values(Supertype); + const result: Supertype[] = await getSupertypes(); + + expect(expected.sort()).toEqual(result.sort()); + + }); + + it('should get a list of card subtypes', async () => { + const expected: string[] = Object.values(Subtype); + const result: Subtype[] = await getSubtypes(); + console.log(expected); + expect(expected.sort()).toEqual(result.sort()); + + }); + + it('should get a list of card rarities', async () => { + const expected: string[] = Object.values(Rarity); + const result: Rarity[] = await getRarities(); + + expect(expected.sort()).toEqual(result.sort()); + + }); + + it('should get a list of card types', async () => { + const expected: string[] = Object.values(Type); + const result: Type[] = await getTypes(); + + expect(expected.sort()).toEqual(result.sort()); + + }); }) \ No newline at end of file