1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Simplify ChecklistItem tests

This commit is contained in:
Chris Cummer 2019-08-04 08:42:32 -07:00
parent b0c175dd57
commit e1ad1f3065
2 changed files with 36 additions and 31 deletions

View File

@ -0,0 +1,36 @@
package checklist
import (
"testing"
. "github.com/stretchr/testify/assert"
)
func testChecklistItem() *ChecklistItem {
item := NewChecklistItem(
false,
"test",
"x",
" ",
)
return item
}
func Test_CheckMark(t *testing.T) {
item := testChecklistItem()
Equal(t, " ", item.CheckMark())
item.Toggle()
Equal(t, "x", item.CheckMark())
}
func Test_Toggle(t *testing.T) {
item := testChecklistItem()
Equal(t, false, item.Checked)
item.Toggle()
Equal(t, true, item.Checked)
item.Toggle()
Equal(t, false, item.Checked)
}

View File

@ -1,31 +0,0 @@
package wtftests
import (
"testing"
. "github.com/stretchr/testify/assert"
. "github.com/wtfutil/wtf/checklist"
)
/* -------------------- CheckMark -------------------- */
func TestCheckMark(t *testing.T) {
item := ChecklistItem{}
Equal(t, " ", item.CheckMark())
item = ChecklistItem{Checked: true}
Equal(t, "x", item.CheckMark())
}
/* -------------------- Toggle -------------------- */
func TestToggle(t *testing.T) {
item := ChecklistItem{}
Equal(t, false, item.Checked)
item.Toggle()
Equal(t, true, item.Checked)
item.Toggle()
Equal(t, false, item.Checked)
}