It("should retrieve the first child element of the parent selector", func() { repository.Get(target.Selectors{parentSelector, childSelector}) Expect(firstParentBus.SendCall.BodyJSON).To(MatchJSON(childSelectorJSON)) }) It("should return only the selected child element", func() { Expect(repository.Get(target.Selectors{parentSelector, childSelector})).To(Equal([]Element{children[0]})) }) }) Context("when single-element-only elements are successfully retrieved", func() { BeforeEach(func() { firstParentBus.SendCall.Result = `[{"ELEMENT": "first child"}]` client.GetElementsCall.ReturnElements = []*api.Element{firstParent} parentSelector.Single = true childSelector.Single = true }) It("should retrieve the parent element using the client", func() { repository.Get(target.Selectors{parentSelector, childSelector}) Expect(client.GetElementsCall.Selector).To(Equal(parentSelector.API())) }) It("should retrieve the child element of the parent selector", func() { repository.Get(target.Selectors{parentSelector, childSelector}) Expect(firstParentBus.SendCall.BodyJSON).To(MatchJSON(childSelectorJSON)) }) It("should return only the selected child element", func() { Expect(repository.Get(target.Selectors{parentSelector, childSelector})).To(Equal([]Element{children[0]}))