From 78a1a724db7ae770a29bf93465069f582869fe46 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Sat, 28 Feb 2015 09:55:49 +0100 Subject: [PATCH] :art: More expressive specs --- spec/text-editor-presenter-spec.coffee | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/spec/text-editor-presenter-spec.coffee b/spec/text-editor-presenter-spec.coffee index 53dc41814..4ad319cc1 100644 --- a/spec/text-editor-presenter-spec.coffee +++ b/spec/text-editor-presenter-spec.coffee @@ -8,7 +8,7 @@ TextEditorPresenter = require '../src/text-editor-presenter' describe "TextEditorPresenter", -> # These `describe` and `it` blocks mirror the structure of the ::state object. # Please maintain this structure when adding specs for new state fields. - describe "::state", -> + describe "::getState()", -> [buffer, editor] = [] beforeEach -> @@ -43,13 +43,22 @@ describe "TextEditorPresenter", -> for key, value of expected expect(actual[key]).toEqual value - expectStateUpdate = (presenter, fn) -> + expectStateUpdatedToBe = (value, presenter, fn) -> updatedState = false disposable = presenter.onDidUpdateState -> updatedState = true disposable.dispose() fn() - expect(updatedState).toBe true + expect(updatedState).toBe(value) + + expectStateUpdate = (presenter, fn) -> expectStateUpdatedToBe(true, presenter, fn) + + expectNoStateUpdate = (presenter, fn) -> expectStateUpdatedToBe(false, presenter, fn) + + describe "during state retrieval", -> + it "does not trigger onDidUpdateState events", -> + presenter = buildPresenter() + expectNoStateUpdate presenter, -> presenter.getState() describe ".horizontalScrollbar", -> describe ".visible", ->