Skip to content

Commit

Permalink
test: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mgjules committed May 15, 2022
1 parent c7ea205 commit 6e7f566
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions deck/deck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ var _ = Describe("Deck", func() {
}

Context("and with no codes", func() {
It("should return back a full list of cards in the correct order", func() {
d, err := deck.New(deck.WithComposition(composition.French))
Expect(err).ToNot(HaveOccurred())
Expect(d.Remaining()).To(Equal(52))
d, err := deck.New(deck.WithComposition(composition.French))
Expect(err).ToNot(HaveOccurred())
Expect(d.Remaining()).To(Equal(52))

raw, err := ioutil.ReadFile(testdataDir + "/full_french_cards.json")
Expect(err).ToNot(HaveOccurred())
raw, err := ioutil.ReadFile(testdataDir + "/full_french_cards.json")
Expect(err).ToNot(HaveOccurred())

var exp expected
err = json.Unmarshal(raw, &exp)
Expect(err).ToNot(HaveOccurred())
var exp expected
err = json.Unmarshal(raw, &exp)
Expect(err).ToNot(HaveOccurred())

It("should return back a full list of cards in the correct order", func() {
Expect(d.Remaining()).To(Equal(len(exp.Cards)))

for i, c := range d.Cards() {
Expand All @@ -48,21 +48,21 @@ var _ = Describe("Deck", func() {
})

Context("and with specific codes", func() {
It("should return back a partial list of cards in same order as codes", func() {
d, err := deck.New(
deck.WithComposition(composition.French),
deck.WithCodes("AS", "KD", "AC", "2C", "KH"),
)
Expect(err).ToNot(HaveOccurred())
Expect(d.Remaining()).To(Equal(5))
d, err := deck.New(
deck.WithComposition(composition.French),
deck.WithCodes("AS", "KD", "AC", "2C", "KH"),
)
Expect(err).ToNot(HaveOccurred())
Expect(d.Remaining()).To(Equal(5))

raw, err := ioutil.ReadFile(testdataDir + "/partial_french_cards.json")
Expect(err).ToNot(HaveOccurred())
raw, err := ioutil.ReadFile(testdataDir + "/partial_french_cards.json")
Expect(err).ToNot(HaveOccurred())

var exp expected
err = json.Unmarshal(raw, &exp)
Expect(err).ToNot(HaveOccurred())
var exp expected
err = json.Unmarshal(raw, &exp)
Expect(err).ToNot(HaveOccurred())

It("should return back a partial list of cards in same order as codes", func() {
Expect(d.Remaining()).To(Equal(len(exp.Cards)))

for i, c := range d.Cards() {
Expand Down

0 comments on commit 6e7f566

Please sign in to comment.