From 03e186a0cc3380f01282c05476494f23672a446b Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Fri, 19 Apr 2019 09:28:14 -0700 Subject: [PATCH] WTF-400 Make ChecklistItem tests pass again --- checklist/checklist_item.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/checklist/checklist_item.go b/checklist/checklist_item.go index e574ba92..40cfafb8 100644 --- a/checklist/checklist_item.go +++ b/checklist/checklist_item.go @@ -24,6 +24,8 @@ func NewChecklistItem(checked bool, text string, checkedIcon, uncheckedIcon stri // CheckMark returns the string used to indicate a ChecklistItem is checked or unchecked func (item *ChecklistItem) CheckMark() string { + item.ensureItemIcons() + if item.Checked { return item.CheckedIcon } @@ -36,3 +38,15 @@ func (item *ChecklistItem) CheckMark() string { func (item *ChecklistItem) Toggle() { item.Checked = !item.Checked } + +/* -------------------- Unexported Functions -------------------- */ + +func (item *ChecklistItem) ensureItemIcons() { + if item.CheckedIcon == "" { + item.CheckedIcon = "x" + } + + if item.UncheckedIcon == "" { + item.UncheckedIcon = " " + } +}