Exemplo n.º 1
0
func TestView_Unmount(t *testing.T) {
	m := gomock.NewController(t)
	defer m.Finish()
	ctx := context.Background()
	app := mock_flux.NewMockAppInterface(m)
	app.EXPECT().Watch("a", notif1{})
	v := NewTestView(ctx, app, true)
	v.Body = vecty.Nil()
	app.EXPECT().Delete(nil)
	v.Unmount()
}
Exemplo n.º 2
0
func TestNewView(t *testing.T) {
	m := gomock.NewController(t)
	defer m.Finish()
	ctx := context.Background()
	app := mock_flux.NewMockAppInterface(m)
	v := NewTestView(ctx, app, false)
	require.NotNil(t, v.Composite)
	v.Body = vecty.Nil()
	require.IsType(t, elem.Div(), v.RenderFunc())
	v.Unmount()
	require.IsType(t, vecty.Nil(), v.RenderFunc())
}
Exemplo n.º 3
0
func TestView_Receive(t *testing.T) {
	m := gomock.NewController(t)
	defer m.Finish()
	ctx := context.Background()
	app := mock_flux.NewMockAppInterface(m)
	c := make(chan flux.NotifPayload)
	app.EXPECT().Watch("a", notif1{}).Return(c)
	v := NewTestView(ctx, app, true)
	v.Body = vecty.Nil()
	np := flux.NotifPayload{Done: make(chan struct{}, 1)}
	v.Notifs[0] <- np
	<-np.Done
	require.True(t, v.received)
}