Пример #1
0
func New(subject leafnodes.SubjectNode, containers []*containernode.ContainerNode, announceProgress bool) *Spec {
	spec := &Spec{
		subject:          subject,
		containers:       containers,
		focused:          subject.Flag() == types.FlagTypeFocused,
		announceProgress: announceProgress,
	}

	spec.processFlag(subject.Flag())
	for i := len(containers) - 1; i >= 0; i-- {
		spec.processFlag(containers[i].Flag())
	}

	return spec
}
Пример #2
0
				BeforeEach(func() {
					container = New("description text", types.FlagTypeFocused, codeLocation)
					itA = leafnodes.NewItNode("A", func() {}, types.FlagTypeNone, codelocation.New(0), 0, nil, 0)
					container.PushSubjectNode(itA)

					innerContainer = New("Orange", types.FlagTypeNone, codelocation.New(0))
					container.PushContainerNode(innerContainer)
					innerItA = leafnodes.NewItNode("inner A", func() {}, types.FlagTypeFocused, codelocation.New(0), 0, nil, 0)
					innerContainer.PushSubjectNode(innerItA)
				})

				It("should unfocus the parent", func() {
					container.BackPropagateProgrammaticFocus()

					Ω(container.Flag()).Should(Equal(types.FlagTypeNone))
					Ω(itA.Flag()).Should(Equal(types.FlagTypeNone))
					Ω(innerContainer.Flag()).Should(Equal(types.FlagTypeNone))
					Ω(innerItA.Flag()).Should(Equal(types.FlagTypeFocused))
				})
			})

			Context("when a parent is focused *and* an inner container is focused", func() {
				BeforeEach(func() {
					container = New("description text", types.FlagTypeFocused, codeLocation)
					itA = leafnodes.NewItNode("A", func() {}, types.FlagTypeNone, codelocation.New(0), 0, nil, 0)
					container.PushSubjectNode(itA)

					innerContainer = New("Orange", types.FlagTypeFocused, codelocation.New(0))
					container.PushContainerNode(innerContainer)
					innerItA = leafnodes.NewItNode("inner A", func() {}, types.FlagTypeNone, codelocation.New(0), 0, nil, 0)
					innerContainer.PushSubjectNode(innerItA)