Flatten spec files, make them seem cleaner.

This commit is contained in:
Cheng Zhao 2013-12-06 22:23:02 +08:00
Родитель b431e96f9d
Коммит 2c672052e6
22 изменённых файлов: 155 добавлений и 151 удалений

Просмотреть файл

Просмотреть файл

@ -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)

Просмотреть файл

@ -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) ->

Просмотреть файл

@ -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', ->

Просмотреть файл

@ -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']

Просмотреть файл

@ -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', ->)

15
spec/chromium-spec.coffee Normal file
Просмотреть файл

@ -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()

38
spec/modules-spec.coffee Normal file
Просмотреть файл

@ -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()

Просмотреть файл

@ -1,4 +0,0 @@
describe 'd3 module', ->
it 'can be required', (done) ->
require 'd3'
done()

Просмотреть файл

@ -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()

Просмотреть файл

@ -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)

70
spec/node-spec.coffee Normal file
Просмотреть файл

@ -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

Просмотреть файл

@ -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'

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -1,5 +1,5 @@
{
"name": "atom-shell-specs",
"main": "main.js",
"main": "static/main.js",
"version": "0.1.0"
}

Просмотреть файл

@ -1,7 +1,7 @@
<html>
<head>
<meta name="referrer" content="always">
<link href="../node_modules/mocha/mocha.css" rel="stylesheet">
<link href="../../node_modules/mocha/mocha.css" rel="stylesheet">
<script src="jquery-2.0.3.min.js"></script>
</head>
<body>
@ -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);
});

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -1,4 +0,0 @@
describe 'debugger', ->
describe 'heap snapshot', ->
it 'should not crash', ->
process.atomBinding('v8_util').takeHeapSnapshot()

Просмотреть файл

@ -1,4 +0,0 @@
describe 'http', ->
describe 'sending request of http protocol urls', ->
it 'should not crash', ->
$.get 'https://api.github.com/zen'

Просмотреть файл

@ -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()