diff --git a/spec/api/app.coffee b/spec/api-app-spec.coffee similarity index 100% rename from spec/api/app.coffee rename to spec/api-app-spec.coffee diff --git a/spec/api/window.coffee b/spec/api-browser-window-spec.coffee similarity index 96% rename from spec/api/window.coffee rename to spec/api-browser-window-spec.coffee index 66de175da971..bcf308a2803c 100644 --- a/spec/api/window.coffee +++ b/spec/api-browser-window-spec.coffee @@ -1,12 +1,13 @@ assert = require 'assert' -fs = require 'fs' -path = require 'path' +fs = require 'fs' +path = require 'path' remote = require 'remote' + BrowserWindow = remote.require 'browser-window' -fixtures = path.resolve __dirname, '..', 'fixtures' +describe 'browser-window module', -> + fixtures = path.resolve __dirname, 'fixtures' -describe 'window module', -> describe 'BrowserWindow.close()', -> it 'should emit unload handler', (done) -> w = new BrowserWindow(show: false) diff --git a/spec/api/crash-reporter.coffee b/spec/api-crash-reporter-spec.coffee similarity index 87% rename from spec/api/crash-reporter.coffee rename to spec/api-crash-reporter-spec.coffee index fc4e91d2d882..0555d804c64f 100644 --- a/spec/api/crash-reporter.coffee +++ b/spec/api-crash-reporter-spec.coffee @@ -1,13 +1,14 @@ -assert = require 'assert' -path = require 'path' -http = require 'http' -remote = require 'remote' +assert = require 'assert' +path = require 'path' +http = require 'http' +remote = require 'remote' formidable = require 'formidable' + BrowserWindow = remote.require 'browser-window' -fixtures = path.resolve __dirname, '..', 'fixtures' - describe 'crash-reporter module', -> + fixtures = path.resolve __dirname, 'fixtures' + it 'should send minidump when renderer crashes', (done) -> w = new BrowserWindow(show: false) server = http.createServer (req, res) -> diff --git a/spec/api/ipc.coffee b/spec/api-ipc-spec.coffee similarity index 93% rename from spec/api/ipc.coffee rename to spec/api-ipc-spec.coffee index b182da212081..890b7ab6fcf4 100644 --- a/spec/api/ipc.coffee +++ b/spec/api-ipc-spec.coffee @@ -1,13 +1,12 @@ assert = require 'assert' -ipc = require 'ipc' -path = require 'path' +ipc = require 'ipc' +path = require 'path' remote = require 'remote' + BrowserWindow = remote.require 'browser-window' -fixtures = path.resolve __dirname, '..', 'fixtures' - -describe 'ipc', -> - fixtures = path.join __dirname, '..', 'fixtures' +describe 'ipc module', -> + fixtures = path.join __dirname, 'fixtures' describe 'remote.require', -> it 'should returns same object for the same module', -> diff --git a/spec/api/menu.coffee b/spec/api-menu-spec.coffee similarity index 92% rename from spec/api/menu.coffee rename to spec/api-menu-spec.coffee index a2b8f28292d5..7f2b62b43ea2 100644 --- a/spec/api/menu.coffee +++ b/spec/api-menu-spec.coffee @@ -1,9 +1,10 @@ -assert= require 'assert' +assert = require 'assert' remote = require 'remote' -Menu = remote.require 'menu' + +Menu = remote.require 'menu' MenuItem = remote.require 'menu-item' -describe 'Menu API', -> +describe 'menu module', -> describe 'Menu.buildFromTemplate', -> it 'should be able to attach extra fields', -> menu = Menu.buildFromTemplate [label: 'text', extra: 'field'] diff --git a/spec/api/protocol.coffee b/spec/api-protocol-spec.coffee similarity index 97% rename from spec/api/protocol.coffee rename to spec/api-protocol-spec.coffee index 9459d333efa3..d017b85e5fea 100644 --- a/spec/api/protocol.coffee +++ b/spec/api-protocol-spec.coffee @@ -1,10 +1,10 @@ -assert = require 'assert' -ipc = require 'ipc' -path = require 'path' -remote = require 'remote' +assert = require 'assert' +ipc = require 'ipc' +path = require 'path' +remote = require 'remote' protocol = remote.require 'protocol' -describe 'protocol API', -> +describe 'protocol module', -> describe 'protocol.registerProtocol', -> it 'throws error when scheme is already registered', (done) -> register = -> protocol.registerProtocol('test1', ->) diff --git a/spec/chromium-spec.coffee b/spec/chromium-spec.coffee new file mode 100644 index 000000000000..f0403df3778f --- /dev/null +++ b/spec/chromium-spec.coffee @@ -0,0 +1,15 @@ +describe 'chromium features', -> + describe 'heap snapshot', -> + it 'does not crash', -> + process.atomBinding('v8_util').takeHeapSnapshot() + + describe 'sending request of http protocol urls', -> + it 'does not crash', -> + $.get 'https://api.github.com/zen' + + describe 'navigator.webkitGetUserMedia', -> + it 'calls its callbacks', (done) -> + @timeout 5000 + navigator.webkitGetUserMedia audio: true, video: false, + -> done() + -> done() diff --git a/spec/modules-spec.coffee b/spec/modules-spec.coffee new file mode 100644 index 000000000000..da9f4c6d2097 --- /dev/null +++ b/spec/modules-spec.coffee @@ -0,0 +1,38 @@ +assert = require 'assert' +fs = require 'fs' +path = require 'path' + +describe 'third-party modules', -> + fixtures = path.join __dirname, 'fixtures' + + describe 'd3', -> + it 'can be required', (done) -> + require 'd3' + done() + + describe 'unzip', -> + unzip = require 'unzip' + + it 'fires close event', (done) -> + fs.createReadStream(path.join(fixtures, 'zip', 'a.zip')) + .pipe(unzip.Parse()) + .on('close', done) + + describe 'int64-native', -> + it 'can be required in renderer', -> + Int64 = require 'int64-native' + x = new Int64() + y = new Int64(42) + z = new Int64(0xfedcba98, 0x76543210) + w = new Int64('fedcba9876543210') + assert.equal x.toString(), '0000000000000000' + assert.equal y.toString(), '000000000000002a' + assert.equal z.toString(), 'fedcba9876543210' + assert.equal w.toString(), 'fedcba9876543210' + + it 'can be required in node binary', (done) -> + int64_native = path.join fixtures, 'module', 'int64_native.js' + child = require('child_process').fork int64_native + child.on 'message', (msg) -> + assert.equal msg, 'ok' + done() diff --git a/spec/modules/d3.coffee b/spec/modules/d3.coffee deleted file mode 100644 index 871f60426797..000000000000 --- a/spec/modules/d3.coffee +++ /dev/null @@ -1,4 +0,0 @@ -describe 'd3 module', -> - it 'can be required', (done) -> - require 'd3' - done() diff --git a/spec/modules/native.coffee b/spec/modules/native.coffee deleted file mode 100644 index 229b065c8adf..000000000000 --- a/spec/modules/native.coffee +++ /dev/null @@ -1,23 +0,0 @@ -assert = require 'assert' -path = require 'path' - -fixtures = path.resolve __dirname, '..', 'fixtures' - -describe 'native module', -> - it 'can be required in renderer', -> - Int64 = require 'int64-native' - x = new Int64() - y = new Int64(42) - z = new Int64(0xfedcba98, 0x76543210) - w = new Int64('fedcba9876543210') - assert.equal x.toString(), '0000000000000000' - assert.equal y.toString(), '000000000000002a' - assert.equal z.toString(), 'fedcba9876543210' - assert.equal w.toString(), 'fedcba9876543210' - - it 'can be required in node binary', (done) -> - int64_native = path.join fixtures, 'module', 'int64_native.js' - child = require('child_process').fork int64_native - child.on 'message', (msg) -> - assert.equal msg, 'ok' - done() diff --git a/spec/modules/unzip.coffee b/spec/modules/unzip.coffee deleted file mode 100644 index b9c158014c55..000000000000 --- a/spec/modules/unzip.coffee +++ /dev/null @@ -1,12 +0,0 @@ -assert = require 'assert' -fs = require 'fs' -path = require 'path' -unzip = require 'unzip' - -fixtures = path.resolve __dirname, '..', 'fixtures' - -describe 'unzip module', -> - it 'fires close event', (done) -> - fs.createReadStream(path.join(fixtures, 'zip', 'a.zip')) - .pipe(unzip.Parse()) - .on('close', done) diff --git a/spec/node-spec.coffee b/spec/node-spec.coffee new file mode 100644 index 000000000000..9ba33ee34bd9 --- /dev/null +++ b/spec/node-spec.coffee @@ -0,0 +1,70 @@ +assert = require 'assert' +child_process = require 'child_process' +fs = require 'fs' +path = require 'path' + +describe 'node features', -> + describe 'child_process', -> + fixtures = path.join __dirname, 'fixtures' + + describe 'child_process.fork', -> + it 'works in current process', (done) -> + child = child_process.fork path.join(fixtures, 'module', 'ping.js') + child.on 'message', (msg) -> + assert.equal msg, 'message' + done() + child.send 'message' + + it 'works in forked process', (done) -> + child = child_process.fork path.join(fixtures, 'module', 'fork_ping.js') + child.on 'message', (msg) -> + assert.equal msg, 'message' + done() + child.send 'message' + + it 'works in forked process when options.env is specifed', (done) -> + child = child_process.fork path.join(fixtures, 'module', 'fork_ping.js'), + [], + path: process.env['PATH'] + child.on 'message', (msg) -> + assert.equal msg, 'message' + done() + child.send 'message' + + describe 'contexts', -> + describe 'setTimeout in fs callback', -> + it 'does not crash', (done) -> + fs.readFile __filename, -> + setTimeout done, 0 + + describe 'throw error in node context', -> + it 'gets caught', (done) -> + error = new Error('boo!') + lsts = process.listeners 'uncaughtException' + process.removeAllListeners 'uncaughtException' + process.on 'uncaughtException', (err) -> + process.removeAllListeners 'uncaughtException' + for lst in lsts + process.on 'uncaughtException', lst + done() + fs.readFile __filename, -> + throw error + + describe 'message loop', -> + describe 'process.nextTick', -> + it 'emits the callback', (done) -> + process.nextTick done + + it 'works in nested calls', (done) -> + process.nextTick -> + process.nextTick -> + process.nextTick done + + describe 'setImmediate', -> + it 'emits the callback', (done) -> + setImmediate done + + it 'works in nested calls', (done) -> + setImmediate -> + setImmediate -> + setImmediate done diff --git a/spec/node/child_process.coffee b/spec/node/child_process.coffee deleted file mode 100644 index 40bbd9730364..000000000000 --- a/spec/node/child_process.coffee +++ /dev/null @@ -1,30 +0,0 @@ -assert = require 'assert' -child_process = require 'child_process' -path = require 'path' - -describe 'child_process', -> - fixtures = path.join __dirname, '..', 'fixtures' - - describe 'child_process.fork', -> - it 'should work', (done) -> - child = child_process.fork path.join(fixtures, 'module', 'ping.js') - child.on 'message', (msg) -> - assert.equal msg, 'message' - done() - child.send 'message' - - it 'should work in forked process', (done) -> - child = child_process.fork path.join(fixtures, 'module', 'fork_ping.js') - child.on 'message', (msg) -> - assert.equal msg, 'message' - done() - child.send 'message' - - it 'should work in forked process when options.env is specifed', (done) -> - child = child_process.fork path.join(fixtures, 'module', 'fork_ping.js'), - [], - path: process.env['PATH'] - child.on 'message', (msg) -> - assert.equal msg, 'message' - done() - child.send 'message' diff --git a/spec/node/contexts.coffee b/spec/node/contexts.coffee deleted file mode 100644 index 589b74a64b27..000000000000 --- a/spec/node/contexts.coffee +++ /dev/null @@ -1,21 +0,0 @@ -assert = require 'assert' -fs = require 'fs' - -describe 'contexts', -> - describe 'setTimeout in fs callback', -> - it 'does not crash', (done) -> - fs.readFile __filename, -> - setTimeout done, 0 - - describe 'throw error in node context', -> - it 'get caught', (done) -> - error = new Error('boo!') - lsts = process.listeners 'uncaughtException' - process.removeAllListeners 'uncaughtException' - process.on 'uncaughtException', (err) -> - process.removeAllListeners 'uncaughtException' - for lst in lsts - process.on 'uncaughtException', lst - done() - fs.readFile __filename, -> - throw error diff --git a/spec/node/message_loop.coffee b/spec/node/message_loop.coffee deleted file mode 100644 index da47385f5b17..000000000000 --- a/spec/node/message_loop.coffee +++ /dev/null @@ -1,18 +0,0 @@ -describe 'message loop', -> - describe 'process.nextTick', -> - it 'should emit the callback', (done) -> - process.nextTick done - - it 'should work in nested calls', (done) -> - process.nextTick -> - process.nextTick -> - process.nextTick done - - describe 'setImmediate', -> - it 'should emit the callback', (done) -> - setImmediate done - - it 'should work in nested calls', (done) -> - setImmediate -> - setImmediate -> - setImmediate done diff --git a/spec/package.json b/spec/package.json index ae97d1ae0373..843e6752336e 100644 --- a/spec/package.json +++ b/spec/package.json @@ -1,5 +1,5 @@ { "name": "atom-shell-specs", - "main": "main.js", + "main": "static/main.js", "version": "0.1.0" } diff --git a/spec/index.html b/spec/static/index.html similarity index 88% rename from spec/index.html rename to spec/static/index.html index fd49cdfbe509..351af228a5b9 100644 --- a/spec/index.html +++ b/spec/static/index.html @@ -1,7 +1,7 @@ - + @@ -54,10 +54,12 @@ if (query.invert) mocha.invert(); // Read all test files. - var walker = require('walkdir').walk(__dirname); + var walker = require('walkdir').walk(require('path').dirname(__dirname), { + no_recurse: true + }); walker.on('file', function(file) { - if (/.coffee$/.test(file)) + if (/-spec.coffee$/.test(file)) mocha.addFile(file); }); diff --git a/spec/jquery-2.0.3.min.js b/spec/static/jquery-2.0.3.min.js similarity index 100% rename from spec/jquery-2.0.3.min.js rename to spec/static/jquery-2.0.3.min.js diff --git a/spec/main.js b/spec/static/main.js similarity index 100% rename from spec/main.js rename to spec/static/main.js diff --git a/spec/web/debugger.coffee b/spec/web/debugger.coffee deleted file mode 100644 index 86b7ee345f2e..000000000000 --- a/spec/web/debugger.coffee +++ /dev/null @@ -1,4 +0,0 @@ -describe 'debugger', -> - describe 'heap snapshot', -> - it 'should not crash', -> - process.atomBinding('v8_util').takeHeapSnapshot() diff --git a/spec/web/http.coffee b/spec/web/http.coffee deleted file mode 100644 index c7db44700651..000000000000 --- a/spec/web/http.coffee +++ /dev/null @@ -1,4 +0,0 @@ -describe 'http', -> - describe 'sending request of http protocol urls', -> - it 'should not crash', -> - $.get 'https://api.github.com/zen' diff --git a/spec/web/webrtc.coffee b/spec/web/webrtc.coffee deleted file mode 100644 index c2e2c3419fd7..000000000000 --- a/spec/web/webrtc.coffee +++ /dev/null @@ -1,7 +0,0 @@ -describe 'webrtc', -> - describe 'navigator.webkitGetUserMedia', -> - it 'should call its callbacks', (done) -> - @timeout 5000 - navigator.webkitGetUserMedia audio: true, video: false, - -> done() - -> done()