Add tests for card enums

This commit is contained in:
Tee
2021-03-14 21:33:46 -04:00
parent 1bcdd1d990
commit 1033ad9dc2

View File

@ -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());
});
})