cards/card.test.ts
Github Readme Stats Bot 63ea3ff952 Card and Pile tests
2026-01-17 18:10:52 -07:00

46 lines
1.1 KiB
TypeScript

import { describe, expect, test } from "bun:test"
import Card, { Index, Suit } from "./card"
describe('types', () => {
test('has expected indexes', () => {
[
Index.Joker,
Index.One,
Index.Two,
Index.Three,
Index.Four,
Index.Five,
Index.Six,
Index.Seven,
Index.Eight,
Index.Nine,
Index.Ten,
Index.Jack,
Index.Queen,
Index.King,
Index.Ace
].forEach((current, i) => expect(current).toBe(i))
})
test('has expected suits', () => {
[Suit.Diamond, Suit.Club, Suit.Heart, Suit.Spade]
.forEach((current, i) => expect(current).toBe(i))
})
})
describe('Card', () => {
test('can read simple data from a Card', () => {
const card = new Card(Index.Five, Suit.Diamond)
expect(card.prettyIndex).toBe('Five')
expect(card.prettySuit).toBe('♦')
expect(card.pretty).toBe('Five of ♦')
})
test('can read decimal data from a Card', () => {
const card = new Card(Index.Five, Suit.Club)
expect(card.decimalIndex).toBe('101')
expect(card.decimalSuit).toBe('01')
})
})