Initial commit

This commit is contained in:
Patrick Marsceill
2017-03-09 13:16:08 -05:00
commit b7b0d0d7bf
4147 changed files with 401224 additions and 0 deletions

21
node_modules/pipetteur/test/errors.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
var expect = require('unexpected');
var pipetteur = require('../pipetteur');
describe('Error handling', function () {
it('should throw on invalid input', function (done) {
var types = [
undefined,
null,
true,
0,
[],
{},
function () { return; }
];
expect(types, 'to be an array whose items satisfy', function (type) {
expect(pipetteur.bind(null, type), 'to throw');
});
done();
});
});

232
node_modules/pipetteur/test/hex.js generated vendored Normal file
View File

@@ -0,0 +1,232 @@
var expect = require('unexpected');
var pipetteur = require('../pipetteur');
describe('Hex match', function () {
it('should match a set of valid 6-char hex strings', function (done) {
var hexes = [
'#000000',
'#FFFFFF',
'#ffffff',
'#123456',
'#abcdef',
'#ABCDEF',
'#fedcba',
'#FEDCBA'
];
expect(hexes, 'to be an array whose items satisfy', function (hex) {
var matches = pipetteur(hex);
return expect(matches, 'to satisfy', [
{
line: 1,
column: 1,
index: 0,
match: hex,
color: function (color) {
expect(color, 'to satisfy', {
isColor: true,
});
expect(color.hex(), 'to be', hex.toLowerCase());
}
}
]);
});
done();
});
it('should match a set of valid 3-char hex strings', function (done) {
var hexes = [
'#000',
'#FFF',
'#fff',
'#123',
'#abc',
'#ABC',
'#cba',
'#CBA'
];
expect(hexes, 'to be an array whose items satisfy', function (hex) {
var matches = pipetteur(hex);
return expect(matches, 'to satisfy', [
{
line: 1,
column: 1,
index: 0,
match: hex,
color: {
isColor: true
}
}
]);
});
done();
});
it('should match a set of valid 6-char hex substrings', function (done) {
var hexes = [
{
string: 'foo #000000 bar',
hex: '#000000',
index: 4
},
{
string: 'one, two, #FFFFFF, three',
hex: '#FFFFFF',
index: 10
},
{
string: 'hvid (#ffffff) er pænt',
hex: '#ffffff',
index: 6
},
{
string: '#123456 are numbers',
hex: '#123456',
index: 0
},
{
string: 'alphabet song: #abcdef',
hex: '#abcdef',
index: 15
},
{
string: '#alphab et #ABCDEF gehijkl',
hex: '#ABCDEF',
index: 11
},
{
string: 'background:#fedcba',
hex: '#fedcba',
index: 11
},
{
string: '$color=#FEDCBA',
hex: '#FEDCBA',
index: 7
}
];
expect(hexes, 'to be an array whose items satisfy', function (obj) {
var matches = pipetteur(obj.string);
return expect(matches, 'to satisfy', [
{
line: 1,
column: obj.index + 1,
index: obj.index,
match: obj.hex,
color: {
isColor: true
}
}
]);
});
done();
});
it('should match a set of valid 3-char hex substrings', function (done) {
var hexes = [
{
string: 'foo #000 bar',
hex: '#000',
index: 4
},
{
string: 'one, two, #FFF, three',
hex: '#FFF',
index: 10
},
{
string: 'hvid (#fff) er pænt',
hex: '#fff',
index: 6
},
{
string: '#123 are numbers',
hex: '#123',
index: 0
},
{
string: 'alphabet song: #abc',
hex: '#abc',
index: 15
},
{
string: '#alphab et #ABC gehijkl',
hex: '#ABC',
index: 11
},
{
string: 'background:#fed',
hex: '#fed',
index: 11
},
{
string: '$color=#FED',
hex: '#FED',
index: 7
}
];
expect(hexes, 'to be an array whose items satisfy', function (obj) {
var matches = pipetteur(obj.string);
return expect(matches, 'to satisfy', [
{
line: 1,
column: obj.index + 1,
index: obj.index,
match: obj.hex,
color: {
isColor: true
}
}
]);
});
done();
});
it('should not match non-hex strings', function (done) {
var hexes = [
'#',
'#0',
'#00',
'#0000',
'#00000',
'#0000000'
];
expect(hexes, 'to be an array whose items satisfy', function (hex) {
var matches = pipetteur(hex);
expect(matches, 'to be an empty array');
});
done();
});
it('should match multiple colors in the same string', function (done) {
var strings = [
'#000000 #ffffff',
'#123456 and #234567',
'First: #123, Second: #fff000',
'Unlikely combination: #123#321'
];
expect(strings, 'to be an array whose items satisfy', function (str) {
var matches = pipetteur(str);
expect(matches, 'to have length', 2);
});
done();
});
});

107
node_modules/pipetteur/test/rgba.js generated vendored Normal file
View File

@@ -0,0 +1,107 @@
var expect = require('unexpected');
var pipetteur = require('../pipetteur');
describe('RGB match', function () {
it('should match a set of valid RGB strings', function (done) {
var colors = [
'rgb(0, 0, 0)',
'rgb(255, 0, 0)',
'rgb(0, 255, 0)',
'rgb(0, 0, 255)',
'rgb(255, 255, 255)',
'rgba(0, 0, 0, 0)',
'rgba(255, 0, 0, 0)',
'rgba(0, 255, 0, 0)',
'rgba(0, 0, 255, 0)',
'rgba(255, 255, 255, 0)',
];
expect(colors, 'to be an array whose items satisfy', function (rgba) {
var matches = pipetteur(rgba);
expect(matches, 'to be a non-empty array');
expect(matches, 'to have length', 1);
expect(matches[0], 'to have properties', ['index', 'match']);
expect(matches[0].line, 'to be', 1);
expect(matches[0].column, 'to be', 1);
expect(matches[0].index, 'to be', 0);
expect(matches[0].match, 'to be', rgba);
});
done();
});
it('should match a set of valid 6-char hex substrings', function (done) {
var hexes = [
{
string: 'foo rgb(0, 0, 0) bar',
hex: 'rgb(0, 0, 0)',
index: 4
},
{
string: 'one, two, rgb(255, 255, 255), three',
hex: 'rgb(255, 255, 255)',
index: 10
},
{
string: 'hvid (rgb(255, 255, 255)) er pænt',
hex: 'rgb(255, 255, 255)',
index: 6
},
{
string: 'rgb(18, 52, 86) are numbers',
hex: 'rgb(18, 52, 86)',
index: 0
},
{
string: 'alphabet song: rgb(171, 205, 239)',
hex: 'rgb(171, 205, 239)',
index: 15
},
{
string: '#alphab et rgb(171, 205, 239) gehijkl',
hex: 'rgb(171, 205, 239)',
index: 11
},
{
string: 'background:rgb(254, 220, 186)',
hex: 'rgb(254, 220, 186)',
index: 11
},
{
string: '$color=rgb(254, 220, 186)',
hex: 'rgb(254, 220, 186)',
index: 7
}
];
expect(hexes, 'to be an array whose items satisfy', function (obj) {
var matches = pipetteur(obj.string);
expect(matches, 'to be a non-empty array');
expect(matches, 'to have length', 1);
expect(matches[0], 'to have properties', ['index', 'match']);
expect(matches[0].index, 'to be', obj.index);
expect(matches[0].match, 'to be', obj.hex);
});
done();
});
it('should match multiple colors in the same string', function (done) {
var strings = [
'rgb(0,0,0) rgb(255,255,255)',
'rgb(100.1, 200.1, 123) and rgba(1, 100, 200, 0.5), not rgb(0,0) or rgba(0,0,0)',
'First: rgba(0, 0, 0, 0), Second: rgb(0, 255, 0)',
'Unlikely combination: rgb(0, 255, 0)rgb(0, 255, 0)'
];
expect(strings, 'to be an array whose items satisfy', function (str) {
var matches = pipetteur(str);
expect(matches, 'to have length', 2);
});
done();
});
});