From f22e4225c3d1cd6d4840e8e353ec8a68fc2f1b91 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 19 Jun 2014 03:35:35 -0600 Subject: [PATCH] Break into separate specs for lineHeight, fontSize, and fontFamily --- spec/editor-component-spec.coffee | 33 +++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/spec/editor-component-spec.coffee b/spec/editor-component-spec.coffee index 7153f18b5..8b44153ab 100644 --- a/spec/editor-component-spec.coffee +++ b/spec/editor-component-spec.coffee @@ -1350,26 +1350,43 @@ describe "EditorComponent", -> expect(event.abortKeyBinding).toHaveBeenCalled() describe "hiding and showing the editor", -> - describe "when fontSize, fontFamily, or lineHeight changes while the editor is hidden", -> - it "does not attempt to measure the lineHeight and defaultCharWidth until the editor becomes visible again", -> + describe "when the lineHeight changes while the editor is hidden", -> + it "does not attempt to measure the lineHeightInPixels until the editor becomes visible again", -> + wrapperView.hide() + initialLineHeightInPixels = editor.getLineHeightInPixels() + + component.setLineHeight(2) + expect(editor.getLineHeightInPixels()).toBe initialLineHeightInPixels + + wrapperView.show() + expect(editor.getLineHeightInPixels()).not.toBe initialLineHeightInPixels + + describe "when the fontSize changes while the editor is hidden", -> + it "does not attempt to measure the lineHeightInPixels or defaultCharWidth until the editor becomes visible again", -> wrapperView.hide() initialLineHeightInPixels = editor.getLineHeightInPixels() initialCharWidth = editor.getDefaultCharWidth() - component.setLineHeight(2) - expect(editor.getLineHeightInPixels()).toBe initialLineHeightInPixels - expect(editor.getDefaultCharWidth()).toBe initialCharWidth component.setFontSize(22) expect(editor.getLineHeightInPixels()).toBe initialLineHeightInPixels expect(editor.getDefaultCharWidth()).toBe initialCharWidth - component.setFontFamily('monospace') - expect(editor.getLineHeightInPixels()).toBe initialLineHeightInPixels - expect(editor.getDefaultCharWidth()).toBe initialCharWidth wrapperView.show() expect(editor.getLineHeightInPixels()).not.toBe initialLineHeightInPixels expect(editor.getDefaultCharWidth()).not.toBe initialCharWidth + describe "when the fontFamily changes while the editor is hidden", -> + it "does not attempt to measure the defaultCharWidth until the editor becomes visible again", -> + wrapperView.hide() + initialLineHeightInPixels = editor.getLineHeightInPixels() + initialCharWidth = editor.getDefaultCharWidth() + + component.setFontFamily('sans-serif') + expect(editor.getDefaultCharWidth()).toBe initialCharWidth + + wrapperView.show() + expect(editor.getDefaultCharWidth()).not.toBe initialCharWidth + describe "when lines are changed while the editor is hidden", -> it "does not measure new characters until the editor is shown again", -> editor.setText('')