@@ -104,6 +104,19 @@ func TestAppQuit(t *testing.T) {
104104 assert .Equal (t , tea .Quit (), cmd ())
105105 }
106106 })
107+
108+ t .Run ("q" , func (t * testing.T ) {
109+ t .Parallel ()
110+
111+ _ , cmd := toAppModel (appModel .Update (tea.KeyMsg {
112+ Type : tea .KeyRunes ,
113+ Runes : []rune {'q' },
114+ }))
115+
116+ if assert .NotNil (t , cmd ) {
117+ assert .Equal (t , tea .Quit (), cmd ())
118+ }
119+ })
107120}
108121
109122func newTestModel (tb testing.TB , content []byte ) app.Model {
@@ -124,3 +137,26 @@ func toAppModel(teaModel tea.Model, cmd tea.Cmd) (app.Model, tea.Cmd) {
124137
125138 return appModel , cmd
126139}
140+
141+ func TestAppViewFiltereRunes (t * testing.T ) {
142+ appModel := newTestModel (t , assets .ExampleJSONLog ())
143+
144+ appModel , _ = toAppModel (appModel .Update (tea.KeyMsg {
145+ Type : tea .KeyRunes ,
146+ Runes : []rune {'f' },
147+ }))
148+ assert .True (t , appModel .IsFilterShown (), appModel .View ())
149+
150+ appModel , cmd := toAppModel (appModel .Update (tea.KeyMsg {
151+ Type : tea .KeyRunes ,
152+ Runes : []rune {'q' },
153+ }))
154+ assert .NotEqual (t , tea .Quit (), cmd ())
155+
156+ appModel , cmd = toAppModel (appModel .Update (tea.KeyMsg {
157+ Type : tea .KeyRunes ,
158+ Runes : []rune {'f' },
159+ }))
160+ assert .NotEqual (t , tea .Quit (), cmd ())
161+ assert .True (t , appModel .IsFilterShown (), appModel .View ())
162+ }
0 commit comments