This repository has been archived by the owner on Nov 12, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
127 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
node_modules/ | ||
coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
let g:node_host_dir = expand('<sfile>:p:h:h') | ||
call remote#host#Register('node', '*.js', function('js_host#RequireJSHost')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"asi": true, | ||
"bitwise": true, | ||
"curly": true, | ||
"eqeqeq": true, | ||
"eqnull": true, | ||
"expr": true, | ||
"freeze": true, | ||
"immed": true, | ||
"latedef": true, | ||
"noarg": true, | ||
"node": true, | ||
"nonew": true, | ||
"quotmark": "single", | ||
"undef": true, | ||
"unused": true, | ||
|
||
"globals": { | ||
"describe": true, | ||
"before": true, | ||
"beforeEach": true, | ||
"it": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
loaded = [] instanceof Array | ||
globals = global | ||
required = require('fixture') | ||
console.log('ahh, silence') | ||
|
||
plugin.commandSync('JSHostTestCmd', { | ||
range: '', | ||
nargs: '*', | ||
}, function( nvim, args, range ) { | ||
if ( args[0] === 'can haz response?') { | ||
throw new Error('no >:(') | ||
} | ||
return [args, range] | ||
}) | ||
|
||
plugin.autocmdSync('BufEnter', { | ||
pattern: '*.js', | ||
eval: 'expand("<afile>")' | ||
}, function( nvim, filename ) { | ||
debug('This is an annoying function') | ||
}) | ||
|
||
plugin.function('Func', function( nvim, args ) { | ||
return 'Funcy ' + args | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "test.js", | ||
"version": "1.0.0", | ||
"description": "A test fixture", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "gulp test" | ||
}, | ||
"author": "", | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var assert = require('chai').assert, | ||
DevNull = require('../lib/devnull') | ||
|
||
describe('DevNull', function() { | ||
it('should be webscale', function( done ) { | ||
var devnull = new DevNull() | ||
assert.isNull( devnull.read(), 'Read should return null' ) | ||
assert.isTrue( devnull.write( 'benchmarks', done ), 'Write should succeed' ) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
var assert = require('chai').assert, | ||
path = require('path'), | ||
Plugin = require('../lib/plugin'), | ||
PLUGIN_PATH = path.join( __dirname, 'rplugin', 'node', 'test.js' ) | ||
|
||
describe('Plugin', function() { | ||
var plugin | ||
|
||
beforeEach( function() { | ||
plugin = new Plugin( PLUGIN_PATH ).load() | ||
}) | ||
|
||
it('should collect the specs from a plugin file', function() { | ||
var exSPECted = [ | ||
{ type: 'command', name: 'JSHostTestCmd', sync: true, | ||
opts: { range: '', nargs: '*' } }, | ||
{ type: 'autocmd', name: 'BufEnter', sync: true, | ||
opts: { pattern: '*.js', eval: 'expand("<afile>")' } }, | ||
{ type: 'function', name: 'Func', sync: false, opts: {} } | ||
] | ||
assert.deepEqual( plugin.specs, exSPECted ) | ||
}) | ||
|
||
it('should collect the handlers from a plugin', function() { | ||
var handlerId = [ PLUGIN_PATH, 'function', 'Func' ].join(':') | ||
assert.strictEqual( plugin.handlers[ handlerId ]( null, 'town' ), 'Funcy town' ) | ||
}) | ||
|
||
it('should load the plugin a sandbox', function() { | ||
var sandbox = plugin.sandbox | ||
assert.isTrue( sandbox.loaded, 'Plugin was not loaded' ) | ||
assert.isUndefined( global.loaded, 'Plugin polluted host global scope' ) | ||
assert.notInclude( Object.keys( sandbox.process ), [ 'chdir', 'exit' ], | ||
'Plugin should not have dangerous `process` functions') | ||
}) | ||
|
||
it('should load files required by the plugin in a sandbox', function() { | ||
var required = plugin.sandbox.required | ||
assert.strictEqual( required.loaded, 'you bet!', | ||
'require() from within a plugin failed' ) | ||
assert.notInclude( Object.keys( required.globals.process ), [ 'chdir', 'exit' ], | ||
'Plugin should not have dangerous `process` functions') | ||
}) | ||
|
||
it('should cache loaded plugins', function() { | ||
var samePlugin = new Plugin( PLUGIN_PATH ).load() | ||
assert.strictEqual( plugin, samePlugin ) | ||
}) | ||
}) |