Skip to content

Commit

Permalink
add(specs): +101 specs and 403 assertions from Atom
Browse files Browse the repository at this point in the history
  • Loading branch information
bengotow committed Jun 3, 2015
1 parent 2b324c4 commit f0f4df6
Show file tree
Hide file tree
Showing 116 changed files with 307 additions and 208 deletions.
4 changes: 2 additions & 2 deletions build/tasks/prebuild-less-task.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LessCache = require 'less-cache'
module.exports = (grunt) ->
grunt.registerMultiTask 'prebuild-less', 'Prebuild cached of compiled LESS files', ->
prebuiltConfigurations = [
['light-ui']
['ui-light', 'ui-dark']
]

directory = path.join(grunt.config.get('atom.appDir'), 'less-compile-cache')
Expand All @@ -19,7 +19,7 @@ module.exports = (grunt) ->
themePath = path.resolve('node_modules', theme)
if fs.existsSync(themePath) is false
themePath = path.resolve('internal_packages', theme)

if fs.existsSync(path.join(themePath, 'stylesheets'))
stylesheetsDir = path.join(themePath, 'stylesheets')
else
Expand Down
2 changes: 1 addition & 1 deletion dot-nylas/config.cson
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'global':
'core':
'themes': [
'light-ui'
'ui-light'
]
'disabledPackages': [
"calendar-bar",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions internal_packages/ui-dark/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "ui-dark",
"theme": "ui",
"version": "0.1.0",
"description": "The Dark Nylas Mail Client Theme",
"license": "Proprietary",
"engines": {
"atom": "*"
},
"private": true
}
1 change: 1 addition & 0 deletions internal_packages/ui-light/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See the [Atom contributing guide](https://github.com/atom/atom/blob/master/CONTRIBUTING.md)
20 changes: 20 additions & 0 deletions internal_packages/ui-light/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2014 GitHub Inc.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9 changes: 9 additions & 0 deletions internal_packages/ui-light/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Atom Light UI theme

Default light UI theme for Atom.

This theme is installed by default with Atom and can be activated by going to
the _Themes_ section in the Settings view (`cmd-,`) and selecting it from the
_UI Themes_ drop-down menu.

![](https://f.cloud.github.com/assets/671378/2265022/bb148a20-9e7a-11e3-81c8-bf5965d48183.png)
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "light-ui",
"name": "ui-light",
"theme": "ui",
"version": "0.1.0",
"description": "The Nylas Mail Client Theme",
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions spec-nylas/fixtures/css.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
body {
font-size: 1234px;
width: 110%;
font-weight: bold !important;
}
3 changes: 3 additions & 0 deletions spec-nylas/fixtures/module-cache/file.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"foo": "bar"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"theme": "ui",
"styleSheets": ["editor.less"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@import "ui-variables";

atom-text-editor {
padding-top: @component-padding;
padding-right: @component-padding;
padding-bottom: @component-padding;

color: @input-background-color;
background-color: @spec-test-variable; // From the fallback variables, not overridden
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// This does not contain all of the ui-variables available.
@background-primary: #00f; // Changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "theme-with-invalid-styles",
"theme": "ui"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"theme": "ui",
"styleSheets": ["editor.less"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@import "ui-variables";

atom-text-editor {
padding-top: @component-padding;
padding-right: @component-padding;
padding-bottom: @component-padding;

color: @input-background-color;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Variables different from the original are marked 'Changed'

@text-color: #333;
@text-color-subtle: #777;
@text-color-highlight: #111;
@text-color-selected: @text-color-highlight;

@text-color-info: #5293d8;
@text-color-success: #1fe977;
@text-color-warning: #f78a46;
@text-color-error: #c00;

@background-color-info: #0098ff;
@background-color-success: #17ca65;
@background-color-warning: #ff4800;
@background-color-error: #c00;
@background-color-highlight: rgba(255, 255, 255, 0.10);
@background-color-selected: @background-color-highlight;

@background-primary: #00f; // Changed

@base-background-color: #fff;
@base-border-color: #eee;

@pane-item-background-color: @base-background-color;
@pane-item-border-color: @base-border-color;

@input-background-color: #f00; // Changed
@input-border-color: @base-border-color;

@tool-panel-background-color: #f4f4f4;
@tool-panel-border-color: @base-border-color;

@inset-panel-background-color: #eee;
@inset-panel-border-color: @base-border-color;

@panel-heading-background-color: #ddd;
@panel-heading-border-color: transparent;

@overlay-background-color: #f4f4f4;
@overlay-border-color: @base-border-color;

@button-background-color: #ccc;
@button-background-color-hover: lighten(@button-background-color, 5%);
@button-background-color-selected: @button-background-color-hover;
@button-border-color: #aaa;

@tab-bar-background-color: #fff;
@tab-bar-border-color: darken(@tab-background-color-active, 10%);
@tab-background-color: #f4f4f4;
@tab-background-color-active: #fff;
@tab-border-color: @base-border-color;

@tree-view-background-color: @tool-panel-background-color;
@tree-view-border-color: @tool-panel-border-color;

@ui-site-color-1: @background-color-success; // green
@ui-site-color-2: @background-color-info; // blue
@ui-site-color-3: @background-color-warning; // orange
@ui-site-color-4: #db2ff4; // purple
@ui-site-color-5: #f5e11d; // yellow

@font-size: 12px;

@disclosure-arrow-size: 12px;

@component-padding: 150px;
@component-icon-padding: 5px;
@component-icon-size: 16px;
@component-line-height: 25px;
@component-border-radius: 2px;

@tab-height: 30px;

@font-family: Arial;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions spec-nylas/fixtures/sample.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@color: #4D926F;

#header {
color: @color;
}
h2 {
color: @color;
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe 'ModuleCache', ->
_atomModuleCache:
extensions:
'.json': [
path.join('spec', 'fixtures', 'module-cache', 'file.json')
path.join('spec-nylas', 'fixtures', 'module-cache', 'file.json')
]
}
expect(require('./fixtures/module-cache/file.json').foo).toBe 'bar'
Expand All @@ -46,7 +46,7 @@ describe 'ModuleCache', ->
dependencies: [{
name: 'underscore'
version: require('underscore/package.json').version
path: path.join('node_modules', 'underscore', 'lib', 'underscore.js')
path: path.join('node_modules', 'underscore', 'underscore.js')
}]
}

Expand Down Expand Up @@ -77,7 +77,7 @@ describe 'ModuleCache', ->
dependencies: [{
name: 'underscore'
version: require('underscore/package.json').version
path: path.join('node_modules', 'underscore', 'lib', 'underscore.js')
path: path.join('node_modules', 'underscore', 'underscore.js')
}]
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{$} = require '../src/space-pen-extensions'

describe '"atom" protocol URL', ->
describe '"nylas" protocol URL', ->
it 'sends the file relative in the package as response', ->
called = false
callback = -> called = true
$.ajax
url: 'atom://async/package.json'
url: 'nylas://async/package.json'
success: callback
# In old versions of jQuery, ajax calls to custom protocol would always
# be treated as error eventhough the browser thinks it's a success
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ describe "PackageManager", ->
workspaceElement = null

beforeEach ->
workspaceElement = atom.views.getView(atom.workspace)
workspaceElement = document.createElement('atom-workspace')
jasmine.attachToDOM(workspaceElement)

describe "::loadPackage(name)", ->
beforeEach ->
Expand All @@ -32,7 +33,7 @@ describe "PackageManager", ->
it "returns null if the package has an invalid package.json", ->
spyOn(console, 'warn')
expect(atom.packages.loadPackage("package-with-broken-package-json")).toBeNull()
expect(console.warn.callCount).toBe(1)
expect(console.warn.callCount).toBe(2)
expect(console.warn.argsForCall[0][0]).toContain("Failed to load package.json")

it "returns null if the package is not found in any package directory", ->
Expand Down Expand Up @@ -154,64 +155,6 @@ describe "PackageManager", ->
expect(atom.config.get('package-with-config-defaults.numbers.one')).toBe 1
expect(atom.config.get('package-with-config-defaults.numbers.two')).toBe 2

describe "when the package metadata includes `activationCommands`", ->
[mainModule, promise, workspaceCommandListener] = []

beforeEach ->
jasmine.attachToDOM(workspaceElement)
mainModule = require './fixtures/packages/package-with-activation-commands/index'
mainModule.legacyActivationCommandCallCount = 0
mainModule.activationCommandCallCount = 0
spyOn(mainModule, 'activate').andCallThrough()
spyOn(Package.prototype, 'requireMainModule').andCallThrough()

workspaceCommandListener = jasmine.createSpy('workspaceCommandListener')
atom.commands.add '.workspace', 'activation-command', workspaceCommandListener

promise = atom.packages.activatePackage('package-with-activation-commands')

it "defers requiring/activating the main module until an activation event bubbles to the root view", ->
expect(promise.isFulfilled()).not.toBeTruthy()
workspaceElement.dispatchEvent(new CustomEvent('activation-command', bubbles: true))

waitsForPromise ->
promise

it "triggers the activation event on all handlers registered during activation", ->
waitsForPromise ->
atom.workspace.open()

runs ->
editorView = atom.views.getView(atom.workspace.getActiveTextEditor()).__spacePenView
legacyCommandListener = jasmine.createSpy("legacyCommandListener")
editorView.command 'activation-command', legacyCommandListener
editorCommandListener = jasmine.createSpy("editorCommandListener")
atom.commands.add 'atom-text-editor', 'activation-command', editorCommandListener
atom.commands.dispatch(editorView[0], 'activation-command')
expect(mainModule.activate.callCount).toBe 1
expect(mainModule.legacyActivationCommandCallCount).toBe 1
expect(mainModule.activationCommandCallCount).toBe 1
expect(legacyCommandListener.callCount).toBe 1
expect(editorCommandListener.callCount).toBe 1
expect(workspaceCommandListener.callCount).toBe 1
atom.commands.dispatch(editorView[0], 'activation-command')
expect(mainModule.legacyActivationCommandCallCount).toBe 2
expect(mainModule.activationCommandCallCount).toBe 2
expect(legacyCommandListener.callCount).toBe 2
expect(editorCommandListener.callCount).toBe 2
expect(workspaceCommandListener.callCount).toBe 2
expect(mainModule.activate.callCount).toBe 1

it "activates the package immediately when the events are empty", ->
mainModule = require './fixtures/packages/package-with-empty-activation-commands/index'
spyOn(mainModule, 'activate').andCallThrough()

waitsForPromise ->
atom.packages.activatePackage('package-with-empty-activation-commands')

runs ->
expect(mainModule.activate.callCount).toBe 1

describe "when the package has no main module", ->
it "does not throw an exception", ->
spyOn(console, "error")
Expand All @@ -233,7 +176,7 @@ describe "PackageManager", ->
waitsForPromise ->
atom.packages.activatePackage("package-with-serialization")
runs ->
expect(pack.mainModule.activate).toHaveBeenCalledWith({someNumber: 77})
expect(pack.mainModule.activate.calls[0].args[0]).toEqual({someNumber: 77})

it "invokes ::onDidActivatePackage listeners with the activated package", ->
activatedPackage = null
Expand Down Expand Up @@ -424,15 +367,6 @@ describe "PackageManager", ->

expect(count).toBe 4

describe "grammar loading", ->
it "loads the package's grammars", ->
waitsForPromise ->
atom.packages.activatePackage('package-with-grammars')

runs ->
expect(atom.grammars.selectGrammar('a.alot').name).toBe 'Alot'
expect(atom.grammars.selectGrammar('a.alittle').name).toBe 'Alittle'

describe "scoped-property loading", ->
it "loads the scoped properties", ->
waitsForPromise ->
Expand Down Expand Up @@ -550,15 +484,6 @@ describe "PackageManager", ->
expect(-> atom.packages.deactivatePackage("package-that-throws-on-deactivate")).not.toThrow()
expect(console.error).toHaveBeenCalled()

it "removes the package's grammars", ->
waitsForPromise ->
atom.packages.activatePackage('package-with-grammars')

runs ->
atom.packages.deactivatePackage('package-with-grammars')
expect(atom.grammars.selectGrammar('a.alot').name).toBe 'Null Grammar'
expect(atom.grammars.selectGrammar('a.alittle').name).toBe 'Null Grammar'

it "removes the package's keymaps", ->
waitsForPromise ->
atom.packages.activatePackage('package-with-keymaps')
Expand Down
Loading

0 comments on commit f0f4df6

Please sign in to comment.