First release
This commit is contained in:
commit
fa6c85266e
2339 changed files with 761050 additions and 0 deletions
134
node_modules/keycode/test/keycode.js
generated
vendored
Normal file
134
node_modules/keycode/test/keycode.js
generated
vendored
Normal file
|
@ -0,0 +1,134 @@
|
|||
"use strict"
|
||||
|
||||
// check if is component
|
||||
if (require.modules) {
|
||||
var keycode = require('keycode')
|
||||
var assert = require('timoxley-assert')
|
||||
} else {
|
||||
var keycode = require('../')
|
||||
var assert = require('assert')
|
||||
}
|
||||
|
||||
it('can return a charcode from a letter', function() {
|
||||
assert.strictEqual(keycode('0'), 48);
|
||||
assert.strictEqual(keycode('B'), 66);
|
||||
assert.strictEqual(keycode('f1'), 112);
|
||||
assert.strictEqual(keycode('9'), 57);
|
||||
assert.strictEqual(keycode('numpad 0'), 96);
|
||||
})
|
||||
|
||||
|
||||
it('can use aliases from a letter', function() {
|
||||
assert.strictEqual(keycode('ctl'), keycode('ctrl'));
|
||||
})
|
||||
|
||||
it('does not use alias name when mapping back from a number', function() {
|
||||
for (var key in keycode.aliases) {
|
||||
assert.notStrictEqual(keycode(keycode(key)), key);
|
||||
}
|
||||
})
|
||||
|
||||
it('is case insensitive', function() {
|
||||
assert.strictEqual(keycode('a'), 65);
|
||||
assert.strictEqual(keycode('A'), 65);
|
||||
assert.strictEqual(keycode('enter'), 13);
|
||||
assert.strictEqual(keycode('ENTER'), 13);
|
||||
assert.strictEqual(keycode('enTeR'), 13);
|
||||
assert.strictEqual(keycode('Spacebar'), 32);
|
||||
})
|
||||
|
||||
it('returns char code for strange chars', function() {
|
||||
// TODO: not sure if this is sensible behaviour
|
||||
assert.strictEqual(keycode('∆'), 8710);
|
||||
assert.strictEqual(keycode('漢'), 28450);
|
||||
})
|
||||
|
||||
it('returns undefined for unknown strings', function() {
|
||||
assert.strictEqual(keycode('ants'), undefined);
|
||||
assert.strictEqual(keycode('Bagels'), undefined);
|
||||
assert.strictEqual(keycode(''), undefined);
|
||||
assert.strictEqual(keycode('JKHG KJG LSDF'), undefined);
|
||||
})
|
||||
|
||||
it('returns undefined for unknown numbers', function() {
|
||||
assert.strictEqual(keycode(-1), undefined);
|
||||
assert.strictEqual(keycode(Infinity), undefined);
|
||||
assert.strictEqual(keycode(0.3), undefined);
|
||||
assert.strictEqual(keycode(9999999), undefined);
|
||||
})
|
||||
|
||||
it('returns code for objects implementing toString function', function() {
|
||||
var obj = {}
|
||||
obj.toString = function() {
|
||||
return 'a'
|
||||
}
|
||||
assert.strictEqual(keycode(obj), 65);
|
||||
})
|
||||
|
||||
it('returns char for objects with a keyCode property', function() {
|
||||
var obj = { keyCode: 65 }
|
||||
assert.strictEqual(keycode(obj), 'a');
|
||||
})
|
||||
|
||||
it('returns undefined for any other passed in type', function() {
|
||||
assert.strictEqual(keycode({}), undefined);
|
||||
assert.strictEqual(keycode([]), undefined);
|
||||
assert.strictEqual(keycode([1,2]), undefined);
|
||||
assert.strictEqual(keycode(null), undefined);
|
||||
assert.strictEqual(keycode(undefined), undefined);
|
||||
assert.strictEqual(keycode(/.*/), undefined);
|
||||
assert.strictEqual(keycode(), undefined);
|
||||
})
|
||||
|
||||
it('is commutative', function() {
|
||||
for (var key in keycode.code) {
|
||||
assert.strictEqual(keycode(key), keycode(keycode(keycode(key))))
|
||||
}
|
||||
})
|
||||
|
||||
it('exposes keycode/name maps', function() {
|
||||
for (var code in keycode.codes) {
|
||||
assert.strictEqual(keycode(code), keycode(keycode.names[keycode.codes[code]]))
|
||||
}
|
||||
})
|
||||
|
||||
it('should return shift, ctrl, and alt for 16, 17, and 18', function() {
|
||||
assert.strictEqual(keycode(16), 'shift')
|
||||
assert.strictEqual(keycode(17), 'ctrl')
|
||||
assert.strictEqual(keycode(18), 'alt')
|
||||
})
|
||||
|
||||
describe('isEventKey', function() {
|
||||
|
||||
it('should allow to compare events to their names', function() {
|
||||
var event = { which: 13, keyCode: 13, charCode: 13 };
|
||||
assert.strictEqual(keycode.isEventKey(event, 'enter'), true);
|
||||
assert.strictEqual(keycode.isEventKey(event, 'down'), false);
|
||||
});
|
||||
|
||||
it('should allow to compare events to their names (case insensitive)', function() {
|
||||
var event = { which: 13, keyCode: 13, charCode: 13 };
|
||||
assert.strictEqual(keycode.isEventKey(event, 'eNtER'), true);
|
||||
assert.strictEqual(keycode.isEventKey(event, 'dOWN'), false);
|
||||
});
|
||||
|
||||
it('should return false if a ', function() {
|
||||
var event = { which: 13, keyCode: 13, charCode: 13 };
|
||||
assert.strictEqual(keycode.isEventKey(event, 'eNtER'), true);
|
||||
assert.strictEqual(keycode.isEventKey(event, 'dOWN'), false);
|
||||
});
|
||||
|
||||
it('should allow to compare events to their keyCodes)', function() {
|
||||
var event = { which: 13, keyCode: 13, charCode: 13 };
|
||||
assert.strictEqual(keycode.isEventKey(event, 13), true);
|
||||
assert.strictEqual(keycode.isEventKey(event, 14), false);
|
||||
});
|
||||
|
||||
it('should not break when invalid key codes are entered, instead false should be returned', function() {
|
||||
var event = { which: -1, keyCode: -1, charCode: -1 };
|
||||
assert.strictEqual(keycode.isEventKey(event, 'enter'), false);
|
||||
assert.strictEqual(keycode.isEventKey(event, 'down'), false);
|
||||
});
|
||||
|
||||
});
|
||||
|
203
node_modules/keycode/test/mocha.css
generated
vendored
Normal file
203
node_modules/keycode/test/mocha.css
generated
vendored
Normal file
|
@ -0,0 +1,203 @@
|
|||
@charset "UTF-8";
|
||||
body {
|
||||
font: 20px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
padding: 60px 50px;
|
||||
}
|
||||
|
||||
#mocha ul, #mocha li {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#mocha ul {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
#mocha h1, #mocha h2 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#mocha h1 {
|
||||
margin-top: 15px;
|
||||
font-size: 1em;
|
||||
font-weight: 200;
|
||||
}
|
||||
|
||||
#mocha h1 a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
#mocha h1 a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#mocha .suite .suite h1 {
|
||||
margin-top: 0;
|
||||
font-size: .8em;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#mocha h2 {
|
||||
font-size: 12px;
|
||||
font-weight: normal;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#mocha .suite {
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
#mocha .test {
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
#mocha .test:hover h2::after {
|
||||
position: relative;
|
||||
top: 0;
|
||||
right: -10px;
|
||||
content: '(view source)';
|
||||
font-size: 12px;
|
||||
font-family: arial;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
#mocha .test.pending:hover h2::after {
|
||||
content: '(pending)';
|
||||
font-family: arial;
|
||||
}
|
||||
|
||||
#mocha .test.pass.medium .duration {
|
||||
background: #C09853;
|
||||
}
|
||||
|
||||
#mocha .test.pass.slow .duration {
|
||||
background: #B94A48;
|
||||
}
|
||||
|
||||
#mocha .test.pass::before {
|
||||
content: '✓';
|
||||
font-size: 12px;
|
||||
display: block;
|
||||
float: left;
|
||||
margin-right: 5px;
|
||||
color: #00d6b2;
|
||||
}
|
||||
|
||||
#mocha .test.pass .duration {
|
||||
font-size: 9px;
|
||||
margin-left: 5px;
|
||||
padding: 2px 5px;
|
||||
color: white;
|
||||
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.2);
|
||||
-moz-box-shadow: inset 0 1px 1px rgba(0,0,0,.2);
|
||||
box-shadow: inset 0 1px 1px rgba(0,0,0,.2);
|
||||
-webkit-border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
-ms-border-radius: 5px;
|
||||
-o-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
#mocha .test.pass.fast .duration {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#mocha .test.pending {
|
||||
color: #0b97c4;
|
||||
}
|
||||
|
||||
#mocha .test.pending::before {
|
||||
content: '◦';
|
||||
color: #0b97c4;
|
||||
}
|
||||
|
||||
#mocha .test.fail {
|
||||
color: #c00;
|
||||
}
|
||||
|
||||
#mocha .test.fail pre {
|
||||
color: black;
|
||||
}
|
||||
|
||||
#mocha .test.fail::before {
|
||||
content: '✖';
|
||||
font-size: 12px;
|
||||
display: block;
|
||||
float: left;
|
||||
margin-right: 5px;
|
||||
color: #c00;
|
||||
}
|
||||
|
||||
#mocha .test pre.error {
|
||||
color: #c00;
|
||||
}
|
||||
|
||||
#mocha .test pre {
|
||||
display: inline-block;
|
||||
font: 12px/1.5 monaco, monospace;
|
||||
margin: 5px;
|
||||
padding: 15px;
|
||||
border: 1px solid #eee;
|
||||
border-bottom-color: #ddd;
|
||||
-webkit-border-radius: 3px;
|
||||
-webkit-box-shadow: 0 1px 3px #eee;
|
||||
}
|
||||
|
||||
#report.pass .test.fail {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#report.fail .test.pass {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#error {
|
||||
color: #c00;
|
||||
font-size: 1.5 em;
|
||||
font-weight: 100;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
#stats {
|
||||
position: fixed;
|
||||
top: 15px;
|
||||
right: 10px;
|
||||
font-size: 12px;
|
||||
margin: 0;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
#stats .progress {
|
||||
float: right;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
#stats em {
|
||||
color: black;
|
||||
}
|
||||
|
||||
#stats a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
#stats a:hover {
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
#stats li {
|
||||
display: inline-block;
|
||||
margin: 0 5px;
|
||||
list-style: none;
|
||||
padding-top: 11px;
|
||||
}
|
||||
|
||||
code .comment { color: #ddd }
|
||||
code .init { color: #2F6FAD }
|
||||
code .string { color: #5890AD }
|
||||
code .keyword { color: #8A6343 }
|
||||
code .number { color: #2F6FAD }
|
4906
node_modules/keycode/test/mocha.js
generated
vendored
Normal file
4906
node_modules/keycode/test/mocha.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
17
node_modules/keycode/test/tests.html
generated
vendored
Normal file
17
node_modules/keycode/test/tests.html
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Mocha</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<link rel="stylesheet" href="mocha.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<script src="mocha.js"></script>
|
||||
<script src="../build/build.js"></script>
|
||||
<script>mocha.setup('bdd')</script>
|
||||
<script src="keycode.js"></script>
|
||||
<script>
|
||||
mocha.run();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue