-
Notifications
You must be signed in to change notification settings - Fork 0
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
14 changed files
with
196 additions
and
32 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,14 +1,13 @@ | ||
module.exports = { | ||
extends: [ | ||
'semistandard' | ||
], | ||
extends: ['semistandard'], | ||
rules: { | ||
quotes: [ | ||
'error', | ||
'single', | ||
{ | ||
allowTemplateLiterals: true | ||
} | ||
] | ||
], | ||
'operator-linebreak': ['error', 'after'] | ||
} | ||
}; |
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,6 @@ | ||
{ | ||
"useTabs": false, | ||
"singleQuote": true, | ||
"trailingComma": "none", | ||
"printWidth": 100 | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,5 @@ | ||
export default function isObject (val) { | ||
return Array.isArray(val) === false && | ||
typeof val === 'object' && | ||
val !== null; | ||
} |
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,52 @@ | ||
/* globals describe it */ | ||
import assert from 'assert'; | ||
|
||
import fn from '../src/utils/formatTime.js'; | ||
|
||
const name = 'formatTime'; | ||
|
||
const rows = [ | ||
{ args: [0], expected: '0ms' }, | ||
{ args: [0.1 * 0.2], expected: '0ms' }, | ||
{ args: [2], expected: '2ms' }, | ||
{ args: [20], expected: '20ms' }, | ||
{ args: [6814], expected: '6.81s' }, | ||
{ args: [7565], expected: '7.56s' }, | ||
{ args: [7686], expected: '7.69s' }, | ||
{ args: [7692], expected: '7.69s' }, | ||
{ args: [7805], expected: '7.81s' }, | ||
{ args: [7944], expected: '7.94s' }, | ||
{ args: [20.4], expected: '20.4ms' }, | ||
{ args: [20.5], expected: '20.5ms' }, | ||
{ args: [20.6], expected: '20.6ms' }, | ||
{ args: [60.02000000000004], expected: '60ms' }, | ||
{ args: [60.1], expected: '60.1ms' }, | ||
{ args: [1500], expected: '1.5s' }, | ||
{ args: [1750], expected: '1.75s' }, | ||
{ args: [40000], expected: '40s' }, | ||
{ args: [40500], expected: '40.5s' }, | ||
{ args: [40750], expected: '40.75s' }, | ||
{ args: [60000], expected: '1m' }, | ||
{ args: [61000], expected: '1m 1s' }, | ||
{ args: [61750], expected: '1m 1s' }, | ||
{ args: [10 * 60 * 1000], expected: '10m' }, | ||
{ args: [60 * 1000 * 10 + 500], expected: '10m' }, | ||
{ args: [60 * 1000 * 10 + 1600], expected: '10m 1s' }, | ||
{ args: [51 * 60 * 1000 + 40 * 1000], expected: '51m 40s' }, | ||
{ args: [59 * 60 * 1000 + 59 * 1000], expected: '59m 59s' }, | ||
{ args: [60 * 60 * 1000 + 59 * 1000], expected: '1h 59s' }, | ||
{ args: [2 * 60 * 60 * 1000 + 30 * 1000 + 59 * 1000], expected: '2h 1m 29s' }, | ||
{ args: [2 * 60 * 60 * 1000 + 30 * 1000], expected: '2h 30s' }, | ||
{ args: [2 * 60 * 60 * 1000 + 300], expected: '2h 1s' }, | ||
{ args: [2 * 60 * 60 * 1000 + 1200], expected: '2h 1s' }, | ||
{ args: [2 * 60 * 60 * 1000 + 300], expected: '2h 1s' } | ||
]; | ||
|
||
describe(name, () => { | ||
rows.forEach(t => { | ||
it(`should match expected ${t.args[0]}`, () => { | ||
const actual = fn(t.args[0]); | ||
assert.equal(actual, t.expected); | ||
}); | ||
}); | ||
}); |
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,19 @@ | ||
/* globals describe it */ | ||
import assert from 'assert'; | ||
|
||
import fn from '../src/lib/getProjectName.js'; | ||
|
||
const name = 'getProjectName'; | ||
|
||
const rows = [ | ||
{ args: [], expected: 'notify' } | ||
]; | ||
|
||
describe(name, () => { | ||
rows.forEach((t) => { | ||
it(`should match expected`, () => { | ||
const actual = fn(t.args[0]); | ||
assert.equal(actual, t.expected); | ||
}); | ||
}); | ||
}); |
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,28 @@ | ||
/* globals describe it */ | ||
import assert from 'assert'; | ||
|
||
import fn from '../src/utils/isObject.js'; | ||
|
||
const name = 'isObject'; | ||
|
||
const rows = [ | ||
{ args: [{}], expected: true }, | ||
{ args: [0], expected: false }, | ||
{ args: [1], expected: false }, | ||
{ args: [NaN], expected: false }, | ||
{ args: [undefined], expected: false }, | ||
{ args: [null], expected: false }, | ||
{ args: [false], expected: false }, | ||
{ args: [true], expected: false }, | ||
{ args: [Infinity], expected: false }, | ||
{ args: [-Infinity], expected: false } | ||
]; | ||
|
||
describe(name, () => { | ||
rows.forEach((t) => { | ||
it(`should match expected`, () => { | ||
const actual = fn(t.args[0]); | ||
assert.equal(actual, t.expected); | ||
}); | ||
}); | ||
}); |
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,43 @@ | ||
/* globals describe it */ | ||
import assert from 'assert'; | ||
|
||
import fn from '../src/lib/getDisplay.js'; | ||
import defaults from '../src/defaults.js'; | ||
|
||
const name = 'getDisplay'; | ||
|
||
const rows = [ | ||
// Empty | ||
{ args: [defaults, undefined, undefined], expected: defaults.baseDisplay }, | ||
|
||
// Setting desktop | ||
{ args: [defaults, {}, true], expected: { ...defaults.baseDisplay, desktop: true } }, | ||
{ args: [defaults, {}, false], expected: { ...defaults.baseDisplay, desktop: false } }, | ||
{ args: [defaults, {}, {}], expected: { ...defaults.baseDisplay, desktop: false } }, | ||
{ args: [defaults, {}, []], expected: { ...defaults.baseDisplay, desktop: false } }, | ||
{ args: [defaults, {}, 1], expected: { ...defaults.baseDisplay, desktop: false } }, | ||
{ args: [defaults, {}, ''], expected: { ...defaults.baseDisplay, desktop: false } }, | ||
|
||
// Setting colors | ||
{ args: [defaults, 'red', ''], expected: { ...defaults.baseDisplay, messageStyle: 'red' } }, | ||
{ args: [defaults, 'bold', ''], expected: { ...defaults.baseDisplay, messageStyle: 'bold' } }, | ||
{ args: [defaults, ['red'], ''], expected: { ...defaults.baseDisplay, messageStyle: ['red'] } }, | ||
{ args: [defaults, ['bold'], ''], expected: { ...defaults.baseDisplay, messageStyle: ['bold'] } }, | ||
{ args: [defaults, ['bold', 'blue'], ''], expected: { ...defaults.baseDisplay, messageStyle: ['bold', 'blue'] } }, | ||
|
||
// Setting colors and desktop | ||
{ args: [defaults, 'red', true], expected: { ...defaults.baseDisplay, messageStyle: 'red', desktop: true } }, | ||
{ args: [defaults, 'bold', false], expected: { ...defaults.baseDisplay, messageStyle: 'bold', desktop: false } }, | ||
{ args: [defaults, ['red'], {}], expected: { ...defaults.baseDisplay, messageStyle: ['red'], desktop: false } }, | ||
{ args: [defaults, ['bold'], []], expected: { ...defaults.baseDisplay, messageStyle: ['bold'], desktop: false } }, | ||
{ args: [defaults, ['bold', 'blue'], ''], expected: { ...defaults.baseDisplay, messageStyle: ['bold', 'blue'], desktop: false } }, | ||
]; | ||
|
||
describe(name, () => { | ||
rows.forEach((t) => { | ||
it(`should match expected ${t.args[1]}`, () => { | ||
const actual = fn(...t.args); | ||
assert.deepEqual(actual, t.expected); | ||
}); | ||
}); | ||
}); |
Empty file.