diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cf6d36a6b..86d60dc0f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,7 +38,7 @@ For more information on how to work with Atom's official packages, see [JavaScript](https://github.com/styleguide/javascript), and [CSS](https://github.com/styleguide/css) styleguides. * Include thoughtfully-worded, well-structured - [Jasmine](http://pivotal.github.com/jasmine) specs. + [Jasmine](http://jasmine.github.io/) specs. * Document new code based on the [Documentation Styleguide](#documentation-styleguide) * End files with a newline. diff --git a/docs/build-instructions/windows.md b/docs/build-instructions/windows.md index 8652a291e..44ff5a6d5 100644 --- a/docs/build-instructions/windows.md +++ b/docs/build-instructions/windows.md @@ -3,7 +3,7 @@ ## Requirements * Windows 7 or later - * [Visual C++ 2010 SP1 Express](http://www.visualstudio.com/en-us/downloads/download-visual-studio-vs#DownloadFamilies_4) + * [Visual C++ 2010 Express](http://www.visualstudio.com/en-us/downloads/download-visual-studio-vs#DownloadFamilies_4) with [SP1](http://www.microsoft.com/en-us/download/details.aspx?id=23691) * [node.js](http://nodejs.org/download/) v0.10.x * [Python](http://www.python.org/download/) v2.7.x * [GitHub for Windows](http://windows.github.com/) diff --git a/docs/index.md b/docs/index.md index 246675cd7..c513f1c20 100644 --- a/docs/index.md +++ b/docs/index.md @@ -5,6 +5,7 @@ * [Creating a Package](creating-a-package.md) * [Creating a Theme](creating-a-theme.md) * [Publishing a Package](publishing-a-package.md) +* [Writing Specs](writing-specs.md) * [Converting a TextMate Bundle](converting-a-text-mate-bundle.md) * [Converting a TextMate Theme](converting-a-text-mate-theme.md) * [Contributing](contributing.md) diff --git a/docs/writing-specs.md b/docs/writing-specs.md new file mode 100644 index 000000000..61899d599 --- /dev/null +++ b/docs/writing-specs.md @@ -0,0 +1,61 @@ +# Writting specs + +Atom uses [Jasmine](http://jasmine.github.io/2.0/introduction.html) as its spec framework. Any new functionality should have specs to guard against regressions. + +## Create a new spec + +[Atom specs](https://github.com/atom/atom/tree/master/spec) and [package specs](https://github.com/atom/markdown-preview/tree/master/spec) are added to their respective `spec` directory. The example below creates a spec for Atom core. + +0. Create a spec file + + Spec files **must** end with `-spec` so add `sample-spec.coffee` to `atom/spec`. + +0. Add one or more `describe` method + + The `describe` method takes two arguments, a description and a function. If the description explains a behavior it typically begins with `when` if it is more like a unit test it begins with the method name. + + ```coffee + describe "when a test is written", -> + # contents + ``` + + or + + ```coffee + describe "Editor::moveUp", -> + # contents + ``` + +0. Add one or more `it` method + + The `it` method also takes two arugments, a description and a function. Try and make the description flow with the `it` method. For example, a description of `this should work` doesn't read well as `it this should work`. But a description of `should work` sounds great as `it should work`. + + ```coffee + describe "when a test is written", -> + it "has some expectations that should pass", -> + # Expectations + ``` + +0. Add one or more expectations + + The best way to learn about expectations is to read the [jamsine documentation](http://jasmine.github.io/2.0/introduction.html#section-Expectations) about them. Below is a simple example. + + ```coffee + describe "when a test is written", -> + it "has some expectations that should pass", -> + expect("apples").toEqual("apples") + expect("oranges").not.toEqual("apples") + ``` + +## Runnings specs + +Most of the time you'll want to run specs by triggering the `window:run-package-specs` command. This command is not only to run package specs, it is also for Atom core specs. This will run all the specs in the current project's spec directory. If you want to run the Atom core specs and **all** the default package specs trigger the `window:run-all-specs` command. + +To run a limited subset of specs use the `fdescribe` or `fit` methods. You can use those to focus a single spec or several specs. In the example above, focusing an individual spec looks like this: + +```coffee +describe "when a test is written", -> + fit "has some expectations that should pass", -> + expect("apples").toEqual("apples") + expect("oranges").not.toEqual("apples") +``` diff --git a/docs/your-first-package.md b/docs/your-first-package.md index 931380f51..4fc41d044 100644 --- a/docs/your-first-package.md +++ b/docs/your-first-package.md @@ -149,6 +149,8 @@ ASCII art professional! * [Getting your project on GitHub guide](http://guides.github.com/overviews/desktop) +* [Writing specs](writing-specs.md) for your package + * [Creating a package guide](creating-a-package.html) for more information on the mechanics of packages diff --git a/package.json b/package.json index 18293453d..17b3a120b 100644 --- a/package.json +++ b/package.json @@ -45,8 +45,8 @@ "property-accessors": "^1", "q": "^1.0.1", "random-words": "0.0.1", - "react": "^0.10.0", - "reactionary": "^0.9.0", + "react-atom-fork": "^0.10.0", + "reactionary-atom-fork": "^0.9.0", "runas": "^0.5", "scandal": "0.15.2", "scoped-property-store": "^0.9.0", diff --git a/spec/editor-component-spec.coffee b/spec/editor-component-spec.coffee index 0bedfe911..f3fbde79a 100644 --- a/spec/editor-component-spec.coffee +++ b/spec/editor-component-spec.coffee @@ -119,6 +119,14 @@ describe "EditorComponent", -> expect(newLineHeightInPixels).not.toBe initialLineHeightInPixels expect(component.lineNodeForScreenRow(1).offsetTop).toBe 1 * newLineHeightInPixels + it "renders the .lines div at the full height of the editor if there aren't enough lines to scroll vertically", -> + editor.setText('') + node.style.height = '300px' + component.measureHeightAndWidth() + + linesNode = node.querySelector('.lines') + expect(linesNode.offsetHeight).toBe 300 + describe "when showInvisibles is enabled", -> invisibles = null diff --git a/src/cursor-component.coffee b/src/cursor-component.coffee index 36ba33a08..902be9d28 100644 --- a/src/cursor-component.coffee +++ b/src/cursor-component.coffee @@ -1,5 +1,5 @@ -React = require 'react' -{div} = require 'reactionary' +React = require 'react-atom-fork' +{div} = require 'reactionary-atom-fork' module.exports = CursorComponent = React.createClass diff --git a/src/cursors-component.coffee b/src/cursors-component.coffee index bb43287ba..4d3e14deb 100644 --- a/src/cursors-component.coffee +++ b/src/cursors-component.coffee @@ -1,5 +1,5 @@ -React = require 'react' -{div} = require 'reactionary' +React = require 'react-atom-fork' +{div} = require 'reactionary-atom-fork' {debounce, toArray} = require 'underscore-plus' SubscriberMixin = require './subscriber-mixin' CursorComponent = require './cursor-component' diff --git a/src/editor-component.coffee b/src/editor-component.coffee index fc68355a1..ef5630f6b 100644 --- a/src/editor-component.coffee +++ b/src/editor-component.coffee @@ -1,5 +1,5 @@ -React = require 'react' -{div, span} = require 'reactionary' +React = require 'react-atom-fork' +{div, span} = require 'reactionary-atom-fork' {debounce, defaults} = require 'underscore-plus' scrollbarStyle = require 'scrollbar-style' @@ -43,6 +43,7 @@ EditorComponent = React.createClass scrollTop = editor.getScrollTop() scrollLeft = editor.getScrollLeft() lineHeightInPixels = editor.getLineHeightInPixels() + scrollViewHeight = editor.getHeight() horizontalScrollbarHeight = editor.getHorizontalScrollbarHeight() verticalScrollbarWidth = editor.getVerticalScrollbarWidth() verticallyScrollable = editor.verticallyScrollable() @@ -64,7 +65,7 @@ EditorComponent = React.createClass scrollTop, scrollLeft, scrollHeight, scrollWidth, @scrollingVertically, @cursorsMoved, @selectionChanged, @selectionAdded, cursorBlinkPeriod, cursorBlinkResumeDelay, @onInputFocused, @onInputBlurred, @mouseWheelScreenRow, - invisibles, visible + invisibles, visible, scrollViewHeight } ScrollbarComponent diff --git a/src/editor-scroll-view-component.coffee b/src/editor-scroll-view-component.coffee index 73d156e3b..f87bc1ad7 100644 --- a/src/editor-scroll-view-component.coffee +++ b/src/editor-scroll-view-component.coffee @@ -1,5 +1,5 @@ -React = require 'react' -{div} = require 'reactionary' +React = require 'react-atom-fork' +{div} = require 'reactionary-atom-fork' {debounce} = require 'underscore-plus' InputComponent = require './input-component' @@ -17,7 +17,7 @@ EditorScrollViewComponent = React.createClass render: -> {editor, fontSize, fontFamily, lineHeight, lineHeightInPixels, showIndentGuide, invisibles, visible} = @props - {renderedRowRange, pendingChanges, scrollTop, scrollLeft, scrollHeight, scrollWidth, scrollingVertically, mouseWheelScreenRow} = @props + {renderedRowRange, pendingChanges, scrollTop, scrollLeft, scrollHeight, scrollWidth, scrollViewHeight, scrollingVertically, mouseWheelScreenRow} = @props {selectionChanged, selectionAdded, cursorBlinkPeriod, cursorBlinkResumeDelay, cursorsMoved, onInputFocused, onInputBlurred} = @props if @isMounted() @@ -38,7 +38,7 @@ EditorScrollViewComponent = React.createClass ref: 'lines', editor, fontSize, fontFamily, lineHeight, lineHeightInPixels, showIndentGuide, renderedRowRange, pendingChanges, scrollTop, scrollLeft, scrollingVertically, selectionChanged, scrollHeight, scrollWidth, mouseWheelScreenRow, invisibles, - visible + visible, scrollViewHeight } componentDidMount: -> diff --git a/src/gutter-component.coffee b/src/gutter-component.coffee index d9922590e..ec1c8e041 100644 --- a/src/gutter-component.coffee +++ b/src/gutter-component.coffee @@ -1,5 +1,5 @@ -React = require 'react' -{div} = require 'reactionary' +React = require 'react-atom-fork' +{div} = require 'reactionary-atom-fork' {isEqual, isEqualForProperties, multiplyString, toArray} = require 'underscore-plus' SubscriberMixin = require './subscriber-mixin' diff --git a/src/input-component.coffee b/src/input-component.coffee index ada93cf2a..372bccf9c 100644 --- a/src/input-component.coffee +++ b/src/input-component.coffee @@ -1,7 +1,7 @@ punycode = require 'punycode' {last, isEqual} = require 'underscore-plus' -React = require 'react' -{input} = require 'reactionary' +React = require 'react-atom-fork' +{input} = require 'reactionary-atom-fork' module.exports = InputComponent = React.createClass diff --git a/src/lines-component.coffee b/src/lines-component.coffee index 4ddf60b9e..136910422 100644 --- a/src/lines-component.coffee +++ b/src/lines-component.coffee @@ -1,5 +1,5 @@ -React = require 'react' -{div, span} = require 'reactionary' +React = require 'react-atom-fork' +{div, span} = require 'reactionary-atom-fork' {debounce, isEqual, isEqualForProperties, multiplyString, toArray} = require 'underscore-plus' {$$} = require 'space-pen' @@ -17,9 +17,9 @@ LinesComponent = React.createClass render: -> if @isMounted() - {editor, scrollTop, scrollLeft, scrollHeight, scrollWidth, lineHeightInPixels} = @props + {editor, scrollTop, scrollLeft, scrollHeight, scrollWidth, lineHeightInPixels, scrollViewHeight} = @props style = - height: scrollHeight + height: Math.max(scrollHeight, scrollViewHeight) width: scrollWidth WebkitTransform: "translate3d(#{-scrollLeft}px, #{-scrollTop}px, 0px)" @@ -40,7 +40,7 @@ LinesComponent = React.createClass return true unless isEqualForProperties(newProps, @props, 'renderedRowRange', 'fontSize', 'fontFamily', 'lineHeight', 'lineHeightInPixels', 'scrollTop', 'scrollLeft', 'showIndentGuide', 'scrollingVertically', 'invisibles', - 'visible' + 'visible', 'scrollViewHeight' ) {renderedRowRange, pendingChanges} = newProps diff --git a/src/react-editor-view.coffee b/src/react-editor-view.coffee index e125dabd5..65b22862a 100644 --- a/src/react-editor-view.coffee +++ b/src/react-editor-view.coffee @@ -1,5 +1,5 @@ {View, $} = require 'space-pen' -React = require 'react' +React = require 'react-atom-fork' EditorComponent = require './editor-component' {defaults} = require 'underscore-plus' diff --git a/src/scrollbar-component.coffee b/src/scrollbar-component.coffee index a4482f21d..19b477e3e 100644 --- a/src/scrollbar-component.coffee +++ b/src/scrollbar-component.coffee @@ -1,5 +1,5 @@ -React = require 'react' -{div} = require 'reactionary' +React = require 'react-atom-fork' +{div} = require 'reactionary-atom-fork' {extend, isEqualForProperties} = require 'underscore-plus' module.exports = diff --git a/src/scrollbar-corner-component.coffee b/src/scrollbar-corner-component.coffee index edcfc8389..d4650b453 100644 --- a/src/scrollbar-corner-component.coffee +++ b/src/scrollbar-corner-component.coffee @@ -1,5 +1,5 @@ -React = require 'react' -{div} = require 'reactionary' +React = require 'react-atom-fork' +{div} = require 'reactionary-atom-fork' module.exports = ScrollbarComponent = React.createClass diff --git a/src/selection-component.coffee b/src/selection-component.coffee index 5bdf65958..9db81ab1e 100644 --- a/src/selection-component.coffee +++ b/src/selection-component.coffee @@ -1,5 +1,5 @@ -React = require 'react' -{div} = require 'reactionary' +React = require 'react-atom-fork' +{div} = require 'reactionary-atom-fork' module.exports = SelectionComponent = React.createClass diff --git a/src/selections-component.coffee b/src/selections-component.coffee index 699967c88..a32f9bdc7 100644 --- a/src/selections-component.coffee +++ b/src/selections-component.coffee @@ -1,5 +1,5 @@ -React = require 'react' -{div} = require 'reactionary' +React = require 'react-atom-fork' +{div} = require 'reactionary-atom-fork' SelectionComponent = require './selection-component' module.exports =