Пример #1
0
func TestBranchNotifySelectFileClick(t *testing.T) {
	cb := ctests.New(t).SetApp(true, false, false)
	defer cb.Finish()

	setupForSuccessfulFileLoad(t, cb)

	m := models.NewBranchModel(cb.Ctx(), &models.AsyncContents{FileContents: models.FileContents{NodeContents: models.NodeContents{Name: "a"}, Filename: "b"}})
	b := NewBranchView(cb.Ctx(), m)

	cb.ExpectDispatched(
		&actions.LoadFileSent{Branch: b.model},
		&actions.LoadFileSuccess{Branch: b.model},
		&actions.BranchOpening{Branch: b.model},
		&actions.BranchSelected{Branch: b.model, Loaded: true},
	)

	done := cb.GetApp().Notifier.NotifyWithData(
		b.model,
		stores.BranchSelecting,
		&stores.BranchSelectOperationData{Op: models.BranchOpClickToggle},
	)
	<-done

	cb.AssertAppSuccess()

}
Пример #2
0
func TestBranchControlView_Render(t *testing.T) {

	cb := ctests.New(t).SetApp(true, false, false)
	defer cb.Finish()

	b := NewBranchControlView(cb.Ctx(), models.NewBranchModel(cb.Ctx(), &models.RootContents{Name: "a"}))

	expected := elem.Div(
		elem.Anchor(
			vecty.ClassMap{
				"toggle": true,
				"empty":  true,
			},
			event.Click(nil),
		),
		elem.Div(
			vecty.ClassMap{
				"node-content": true,
			},
			elem.Span(
				prop.Class("node-label"),
				event.Click(nil),
				vecty.Text("a"),
			),
			elem.Span(
				prop.Class("badge"),
				vecty.Style("display", "none"),
			),
		),
	)
	equal(t, expected, b.Render())

	cb.AssertAppSuccess()

}
Пример #3
0
func TestBranchRender1(t *testing.T) {

	cb := ctests.New(t).SetApp(true, true, false)
	defer cb.Finish()

	b := NewBranchView(cb.Ctx(), nil)
	expected := elem.Div()
	equal(t, expected, b.Render())

	cb.AssertAppSuccess()

}
Пример #4
0
func TestBranchView_Unmount(t *testing.T) {
	cb := ctests.New(t).SetApp(true, true, false)
	defer cb.Finish()

	b := NewBranchView(cb.Ctx(), models.NewBranchModel(cb.Ctx(), &models.RootContents{Name: "a"}))

	c := mock_vecty.NewMockComponent(cb.GetMock())
	c.EXPECT().Unmount()
	b.Body = c
	b.Unmount()
	assert.Nil(t, b.Notifs)
}
Пример #5
0
func TestBranchNotifyOpen(t *testing.T) {
	cb := ctests.New(t).SetApp(true, false, false)
	defer cb.Finish()

	b := NewBranchView(cb.Ctx(), models.NewBranchModel(cb.Ctx(), &models.RootContents{Name: "a"}))

	cb.GetConnection().EXPECT().Go(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(0)

	cb.ExpectDispatched(&actions.BranchOpened{Branch: b.model, Loaded: false})

	done := cb.GetApp().Notifier.Notify(b.model, stores.BranchOpening)
	<-done

	cb.AssertAppSuccess()
}
Пример #6
0
func testBranchReconcile(t *testing.T, notif flux.Notif) {
	cb := ctests.New(t).SetApp(true, false, false)
	defer cb.Finish()

	b := NewBranchView(cb.Ctx(), models.NewBranchModel(cb.Ctx(), &models.RootContents{Name: "a"}))

	cb.ExpectReconcile(&b.Composite)
	cb.ExpectNoneDispatched()

	done := cb.GetApp().Notifier.Notify(b.model, notif)
	<-done

	cb.AssertAppSuccess()

}
Пример #7
0
func TestBranchRender2(t *testing.T) {

	cb := ctests.New(t).SetApp(true, true, false)
	defer cb.Finish()

	b := NewBranchView(cb.Ctx(), models.NewBranchModel(cb.Ctx(), &models.RootContents{Name: "a"}))
	expected := elem.Div(
		prop.Class("node"),
		NewBranchControlView(cb.Ctx(), models.NewBranchModel(cb.Ctx(), nil)),
		elem.Div(
			prop.Class("children"),
		),
	)
	equal(t, expected, b.Render())

}
Пример #8
0
func TestBranchNotifyOpenFile(t *testing.T) {
	cb := ctests.New(t).SetApp(true, false, false)
	defer cb.Finish()

	setupForSuccessfulFileLoad(t, cb)

	b := NewBranchView(cb.Ctx(), models.NewBranchModel(cb.Ctx(), &models.AsyncContents{FileContents: models.FileContents{NodeContents: models.NodeContents{Name: "a"}, Filename: "b"}}))

	cb.ExpectDispatched(
		&actions.LoadFileSent{Branch: b.model},
		&actions.LoadFileSuccess{Branch: b.model},
		&actions.BranchOpened{Branch: b.model, Loaded: true},
	)

	done := cb.GetApp().Notifier.Notify(b.model, stores.BranchOpening)
	<-done

	cb.AssertAppSuccess()

}
Пример #9
0
func TestBranchNotifySelect(t *testing.T) {
	cb := ctests.New(t).SetApp(true, false, false)
	defer cb.Finish()

	b := NewBranchView(cb.Ctx(), models.NewBranchModel(cb.Ctx(), &models.RootContents{Name: "a"}))

	cb.ExpectDispatched(
		&actions.BranchSelected{Branch: b.model, Loaded: false},
	)

	done := cb.GetApp().Notifier.NotifyWithData(
		b.model,
		stores.BranchSelecting,
		&stores.BranchSelectOperationData{Op: models.BranchOpClickLabel},
	)
	<-done

	cb.AssertAppSuccess()

}