// Given no items added // Expect Items() returns an empty list func TestItems_GivenNoItemsAdded_ExpectEmptyListReturned(t *testing.T) { ctx := setup() if err := testutils.ExpectCount(0, len(ctx.ui.Items())); err != nil { t.Fatal(err) } }
func expectItemListsEq(exp, act []*Item) error { // compare lengths if err := testutils.ExpectCount(len(exp), len(act)); err != nil { return err } // compare items in each list for i := 0; i < len(exp); i++ { if !eq(exp[i], act[i]) { return fmt.Errorf("Expected %v; Got %v", exp, act) } } return nil }
// Given no items added // When item added // Expect Items() returns a 1-length list // And expect added item is the first item in that list func TestAddItem_GivenNoItemsAdded_ExpectItemAdded(t *testing.T) { ctx := setup() item := NewItem("Added item") // When item added ctx.ui.AddItem(item) // Expect Items() returns a 1-length list items := ctx.ui.Items() if err := testutils.ExpectCount(1, len(items)); err != nil { t.Fatal(err) } if err := testutils.Expect(item, items[0]); err != nil { t.Fatal(err) } }