@@ -96,6 +96,8 @@ func TestStateFiltering(t *testing.T) {
9696}
9797
9898func TestStateFilteringReset (t * testing.T ) {
99+ t .Parallel ()
100+
99101 const termIncluded = "included"
100102
101103 const jsonFile = `
@@ -128,24 +130,42 @@ func TestStateFilteringReset(t *testing.T) {
128130 _ , ok = model .(app.StateFiltered )
129131 assert .Truef (t , ok , "%s" , model )
130132
131- rendered = model .View ()
133+ t .Run ("record_not_included" , func (t * testing.T ) {
134+ t .Parallel ()
135+
136+ rendered := model .View ()
132137
133- index := strings .Index (rendered , "filtered by:" )
134- if index > 0 {
135- rendered = rendered [:index ]
136- }
138+ index := strings .Index (rendered , "filtered by:" )
139+ if assert . Greater ( t , index , 0 ) {
140+ rendered = rendered [:index ]
141+ }
137142
138- assert .NotContains (t , rendered , termIncluded )
143+ assert .NotContains (t , rendered , termIncluded )
139144
140- // Come back
141- model = handleUpdate (model , tea.KeyMsg {
142- Type : tea .KeyEsc ,
145+ // Come back
146+ model := handleUpdate (model , tea.KeyMsg {
147+ Type : tea .KeyEsc ,
148+ })
149+
150+ _ , ok = model .(app.StateLoaded )
151+ assert .Truef (t , ok , "%s" , model )
152+
153+ // Assert.
154+ rendered = model .View ()
155+ assert .Contains (t , rendered , termIncluded )
143156 })
144157
145- _ , ok = model .(app. StateLoaded )
146- assert . Truef ( t , ok , "%s" , model )
158+ t . Run ( "record_not_included" , func ( t * testing. T ) {
159+ t . Parallel ( )
147160
148- // Assert.
149- rendered = model .View ()
150- assert .Contains (t , rendered , termIncluded )
161+ // Try to open a record where there are no records.
162+ model := handleUpdate (model , tea.KeyMsg {
163+ Type : tea .KeyEnter ,
164+ })
165+
166+ assert .NotNil (t , model )
167+
168+ _ , ok := model .(app.StateLoaded )
169+ assert .Truef (t , ok , "%s" , model )
170+ })
151171}
0 commit comments