|
|
@@ -1,6 +1,49 @@
|
|
|
package buggo
|
|
|
|
|
|
-import "testing"
|
|
|
+import (
|
|
|
+ "strings"
|
|
|
+ "testing"
|
|
|
|
|
|
-func TestNothing(t *testing.T) {
|
|
|
+ tea "github.com/charmbracelet/bubbletea"
|
|
|
+ "github.com/stretchr/testify/assert"
|
|
|
+)
|
|
|
+
|
|
|
+func Test_Model_Init(t *testing.T) {
|
|
|
+ assert.Nil(t, Model{}.Init())
|
|
|
+}
|
|
|
+
|
|
|
+func Test_Model_Update_quit_on_keymsg(t *testing.T) {
|
|
|
+ testBug, _ := Bug.NewFromPath(Bug{}, "tests/bugs/test-1")
|
|
|
+ testModel := Model{Bug: testBug}
|
|
|
+ testMsg := tea.KeyMsg{}
|
|
|
+
|
|
|
+ model, cmd := testModel.Update(testMsg)
|
|
|
+ assert.Equal(t, testModel, model)
|
|
|
+
|
|
|
+ cmdValue := cmd()
|
|
|
+ assert.IsType(t, tea.QuitMsg{}, cmdValue)
|
|
|
+}
|
|
|
+func Test_Model_Update_do_nothing(t *testing.T) {
|
|
|
+ testBug, _ := Bug.NewFromPath(Bug{}, "tests/bugs/test-1")
|
|
|
+ testModel := Model{Bug: testBug}
|
|
|
+ var testMsg int
|
|
|
+
|
|
|
+ model, cmd := testModel.Update(testMsg)
|
|
|
+ assert.Equal(t, testModel, model)
|
|
|
+
|
|
|
+ assert.Nil(t, cmd)
|
|
|
+}
|
|
|
+
|
|
|
+func Test_Model_renderBug(t *testing.T) {
|
|
|
+ testBug, _ := Bug.NewFromPath(Bug{}, "tests/bugs/test-1")
|
|
|
+ testRender := Model{Bug: testBug}.renderBug()
|
|
|
+
|
|
|
+ assert.True(t, strings.Contains(testRender, "test description"))
|
|
|
+}
|
|
|
+
|
|
|
+func Test_Model_View(t *testing.T) {
|
|
|
+ testBug, _ := Bug.NewFromPath(Bug{}, "tests/bugs/test-1")
|
|
|
+ testRender := Model{Bug: testBug}.View()
|
|
|
+
|
|
|
+ assert.True(t, strings.Contains(testRender, "test description"))
|
|
|
}
|