it("validates data received and hides when valid", () => { const mockData = { textBox: "" }; const mockValidatedData = ""; const stubValidate = sandbox.stub(options.metricsProvider, "validateTimeLabel").returns(mockValidatedData); const gotoTimeView = new GotoTimeView(options); const spyValidate = sandbox.spy(gotoTimeView, "validate"); const spyHide = sandbox.spy(gotoTimeView, "hide"); gotoTimeView.form.emit("submit", mockData); expect(stubValidate) .to.have.been.calledOnce .and.to.have.been.calledWithExactly(mockData.textBox); expect(spyValidate) .to.have.been.calledOnce .and.to.have.been.calledWithExactly(mockData) .and.to.have.returned(mockValidatedData); expect(spyHide).to.have.been.calledOnce; });