-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Jason Poon
committed
Feb 6, 2019
1 parent
adff634
commit 0fbe990
Showing
9 changed files
with
201 additions
and
42 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
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
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,36 @@ | ||
import * as assert from 'assert'; | ||
import { Configuration } from '../../testConfiguration'; | ||
import { NeovimValidator } from '../../../src/configuration/validators/neovimValidator'; | ||
|
||
suite('Neovim Validator', () => { | ||
test('neovim enabled without path', async () => { | ||
// setup | ||
let configuration = new Configuration(); | ||
configuration.enableNeovim = true; | ||
configuration.neovimPath = ''; | ||
|
||
// test | ||
const validator = new NeovimValidator(); | ||
let actual = await validator.validate(configuration); | ||
validator.disable(configuration); | ||
|
||
// assert | ||
assert.equal(actual.numErrors, 1); | ||
assert.equal(actual.hasError, true); | ||
assert.equal(configuration.enableNeovim, false); | ||
}); | ||
|
||
test('neovim disabled', async () => { | ||
// setup | ||
let configuration = new Configuration(); | ||
configuration.enableNeovim = false; | ||
configuration.neovimPath = ''; | ||
|
||
// test | ||
const validator = new NeovimValidator(); | ||
let actual = await validator.validate(configuration); | ||
|
||
// assert | ||
assert.equal(actual.numErrors, 0); | ||
}); | ||
}); |
135 changes: 135 additions & 0 deletions
135
test/configuration/validators/remappingValidator.test.ts
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,135 @@ | ||
import * as assert from 'assert'; | ||
import { Configuration } from '../../testConfiguration'; | ||
import { RemappingValidator } from '../../../src/configuration/validators/remappingValidator'; | ||
|
||
suite('Remapping Validator', () => { | ||
test('no remappings', async () => { | ||
// setup | ||
const configuration = new Configuration(); | ||
configuration.insertModeKeyBindings = []; | ||
configuration.insertModeKeyBindingsNonRecursive = []; | ||
configuration.normalModeKeyBindings = []; | ||
configuration.normalModeKeyBindingsNonRecursive = []; | ||
configuration.visualModeKeyBindings = []; | ||
configuration.visualModeKeyBindingsNonRecursive = []; | ||
|
||
// test | ||
const validator = new RemappingValidator(); | ||
let actual = await validator.validate(configuration); | ||
|
||
// assert | ||
assert.equal(actual.numErrors, 0); | ||
assert.equal(actual.hasError, false); | ||
assert.equal(actual.numWarnings, 0); | ||
assert.equal(actual.hasWarning, false); | ||
|
||
assert.equal(configuration.insertModeKeyBindingsMap.size, 0); | ||
assert.equal(configuration.insertModeKeyBindingsNonRecursiveMap.size, 0); | ||
assert.equal(configuration.normalModeKeyBindingsMap.size, 0); | ||
assert.equal(configuration.normalModeKeyBindingsNonRecursiveMap.size, 0); | ||
assert.equal(configuration.visualModeKeyBindingsMap.size, 0); | ||
assert.equal(configuration.visualModeKeyBindingsNonRecursiveMap.size, 0); | ||
}); | ||
|
||
test('jj->esc', async () => { | ||
// setup | ||
let configuration = new Configuration(); | ||
configuration.insertModeKeyBindings = [ | ||
{ | ||
before: ['j', 'j'], | ||
after: ['<Esc>'], | ||
}]; | ||
configuration.insertModeKeyBindingsNonRecursive = []; | ||
configuration.normalModeKeyBindings = []; | ||
configuration.normalModeKeyBindingsNonRecursive = []; | ||
configuration.visualModeKeyBindings = []; | ||
configuration.visualModeKeyBindingsNonRecursive = []; | ||
|
||
// test | ||
const validator = new RemappingValidator(); | ||
let actual = await validator.validate(configuration); | ||
|
||
// assert | ||
assert.equal(actual.numErrors, 0); | ||
assert.equal(actual.hasError, false); | ||
assert.equal(actual.numWarnings, 0); | ||
assert.equal(actual.hasWarning, false); | ||
|
||
assert.equal(configuration.insertModeKeyBindingsMap.size, 1); | ||
assert.equal(configuration.insertModeKeyBindingsNonRecursiveMap.size, 0); | ||
assert.equal(configuration.normalModeKeyBindingsMap.size, 0); | ||
assert.equal(configuration.normalModeKeyBindingsNonRecursiveMap.size, 0); | ||
assert.equal(configuration.visualModeKeyBindingsMap.size, 0); | ||
assert.equal(configuration.visualModeKeyBindingsNonRecursiveMap.size, 0); | ||
|
||
assert.equal(configuration.insertModeKeyBindingsMap.get("jj"), configuration.insertModeKeyBindings[0]); | ||
}); | ||
|
||
test('remapping missing after and command', async () => { | ||
// setup | ||
let configuration = new Configuration(); | ||
configuration.insertModeKeyBindings = [ | ||
{ | ||
before: ['j', 'j'] | ||
}]; | ||
configuration.insertModeKeyBindingsNonRecursive = []; | ||
configuration.normalModeKeyBindings = []; | ||
configuration.normalModeKeyBindingsNonRecursive = []; | ||
configuration.visualModeKeyBindings = []; | ||
configuration.visualModeKeyBindingsNonRecursive = []; | ||
|
||
// test | ||
const validator = new RemappingValidator(); | ||
let actual = await validator.validate(configuration); | ||
|
||
// assert | ||
assert.equal(actual.numErrors, 1); | ||
assert.equal(actual.hasError, true); | ||
assert.equal(actual.numWarnings, 0); | ||
assert.equal(actual.hasWarning, false); | ||
|
||
assert.equal(configuration.insertModeKeyBindingsMap.size, 0); | ||
assert.equal(configuration.insertModeKeyBindingsNonRecursiveMap.size, 0); | ||
assert.equal(configuration.normalModeKeyBindingsMap.size, 0); | ||
assert.equal(configuration.normalModeKeyBindingsNonRecursiveMap.size, 0); | ||
assert.equal(configuration.visualModeKeyBindingsMap.size, 0); | ||
assert.equal(configuration.visualModeKeyBindingsNonRecursiveMap.size, 0); | ||
}); | ||
|
||
test('remappings are de-duped', async () => { | ||
// setup | ||
let configuration = new Configuration(); | ||
configuration.insertModeKeyBindings = []; | ||
configuration.insertModeKeyBindingsNonRecursive = []; | ||
configuration.normalModeKeyBindings = [ | ||
{ | ||
before: ['c', 'o', 'p', 'y'], | ||
after: ['c', 'o', 'p', 'y'], | ||
}, | ||
{ | ||
before: ['c', 'o', 'p', 'y'], | ||
after: ['c', 'o', 'p', 'y'], | ||
} | ||
] | ||
configuration.normalModeKeyBindingsNonRecursive = []; | ||
configuration.visualModeKeyBindings = []; | ||
configuration.visualModeKeyBindingsNonRecursive = []; | ||
|
||
// test | ||
const validator = new RemappingValidator(); | ||
let actual = await validator.validate(configuration); | ||
|
||
// assert | ||
assert.equal(actual.numErrors, 0); | ||
assert.equal(actual.hasError, false); | ||
assert.equal(actual.numWarnings, 1); | ||
assert.equal(actual.hasWarning, true); | ||
|
||
assert.equal(configuration.insertModeKeyBindingsMap.size, 0); | ||
assert.equal(configuration.insertModeKeyBindingsNonRecursiveMap.size, 0); | ||
assert.equal(configuration.normalModeKeyBindingsMap.size, 1); | ||
assert.equal(configuration.normalModeKeyBindingsNonRecursiveMap.size, 0); | ||
assert.equal(configuration.visualModeKeyBindingsMap.size, 0); | ||
assert.equal(configuration.visualModeKeyBindingsNonRecursiveMap.size, 0); | ||
}); | ||
}); |
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