js-build-tools 2.3.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +334 -205
- package/dist/build.js +16 -5
- package/dist/build.min.js +1 -1
- package/dist/bundle.js +12 -13
- package/dist/bundle.min.js +1 -1
- package/dist/bundleLint.js +17 -18
- package/dist/bundleLint.min.js +1 -1
- package/dist/bundleMinify.js +8 -9
- package/dist/bundleMinify.min.js +1 -1
- package/dist/copyFonts.js +12 -0
- package/dist/copyFonts.min.js +1 -0
- package/dist/default.js +15 -15
- package/dist/default.min.js +1 -1
- package/dist/dist.js +0 -1
- package/dist/distLint.js +17 -18
- package/dist/distLint.min.js +1 -1
- package/dist/distMinify.js +8 -9
- package/dist/distMinify.min.js +1 -1
- package/dist/images.js +11 -0
- package/dist/images.min.js +1 -0
- package/dist/partials/addToReadme.js +13 -14
- package/dist/partials/beginWatcher.js +9 -10
- package/dist/partials/clean.js +0 -1
- package/dist/partials/copyFor.js +16 -0
- package/dist/partials/distFor.js +16 -17
- package/dist/partials/distForSrc.js +9 -10
- package/dist/partials/distSeries.js +19 -20
- package/dist/partials/imagesFor.js +34 -0
- package/dist/partials/minifyFor.js +0 -1
- package/dist/partials/readmeTemplate.js +11 -12
- package/dist/partials/removeDirectory.js +5 -6
- package/dist/partials/runOnChange.js +27 -27
- package/dist/partials/sassFor.js +2 -3
- package/dist/partials/tsFor.js +20 -21
- package/dist/partials.js +5 -1
- package/dist/partials.min.js +1 -1
- package/dist/sass.js +7 -7
- package/dist/test-helpers/setUp.js +31 -39
- package/dist/testFull.js +17 -18
- package/dist/testFull.min.js +1 -1
- package/dist/testHelpers.js +10 -28
- package/dist/testHelpers.min.js +1 -1
- package/dist/testQuick.js +19 -20
- package/dist/testQuick.min.js +1 -1
- package/dist/typeScript.js +0 -1
- package/dist/utilities/dotGet.js +50 -0
- package/dist/utilities/dotNotate.js +77 -0
- package/dist/utilities/dotSet.js +44 -0
- package/dist/utilities/isObject.js +10 -0
- package/dist/watchFull.js +0 -1
- package/dist/watchTest.js +13 -14
- package/dist/watchTest.min.js +1 -1
- package/functions/build.js +15 -5
- package/functions/build.test.js +278 -42
- package/functions/bundle.js +3 -4
- package/functions/bundle.test.js +6 -6
- package/functions/bundleLint.js +2 -3
- package/functions/bundleLint.test.js +5 -5
- package/functions/bundleMinify.js +1 -2
- package/functions/bundleMinify.test.js +1 -1
- package/functions/copyFonts.js +11 -0
- package/functions/copyFonts.test.js +31 -0
- package/functions/default.js +1 -1
- package/functions/default.test.js +2 -2
- package/functions/dist.js +0 -1
- package/functions/dist.test.js +1 -1
- package/functions/distLint.js +2 -3
- package/functions/distLint.test.js +3 -3
- package/functions/distMinify.js +1 -2
- package/functions/distMinify.test.js +1 -1
- package/functions/images.js +10 -0
- package/functions/images.test.js +138 -0
- package/functions/partials/addToReadme.js +2 -3
- package/functions/partials/addToReadme.test.js +2 -2
- package/functions/partials/beginWatcher.js +1 -2
- package/functions/partials/beginWatcher.test.js +1 -1
- package/functions/partials/clean.js +0 -1
- package/functions/partials/copyFor.js +13 -0
- package/functions/partials/copyFor.test.js +34 -0
- package/functions/partials/distFor.js +1 -2
- package/functions/partials/distFor.test.js +4 -4
- package/functions/partials/distForSrc.js +3 -4
- package/functions/partials/distForSrc.test.js +6 -6
- package/functions/partials/distSeries.js +2 -3
- package/functions/partials/distSeries.test.js +5 -5
- package/functions/partials/imagesFor.js +33 -0
- package/functions/partials/imagesFor.test.js +143 -0
- package/functions/partials/minifyFor.js +0 -1
- package/functions/partials/minifyFor.test.js +1 -1
- package/functions/partials/readmeTemplate.js +3 -4
- package/functions/partials/readmeTemplate.test.js +2 -2
- package/functions/partials/removeDirectory.js +22 -23
- package/functions/partials/runOnChange.js +5 -6
- package/functions/partials/runOnChange.test.js +9 -9
- package/functions/partials/sassFor.js +1 -2
- package/functions/partials/sassFor.test.js +3 -3
- package/functions/partials/tsFor.js +3 -4
- package/functions/partials/tsFor.test.js +2 -2
- package/functions/partials.js +5 -1
- package/functions/partials.test.js +1 -1
- package/functions/sass.test.js +2 -2
- package/functions/test-helpers/setUp.js +24 -32
- package/functions/testFull.js +2 -3
- package/functions/testFull.test.js +1 -1
- package/functions/testHelpers.js +3 -20
- package/functions/testHelpers.test.js +1 -1
- package/functions/testQuick.js +1 -2
- package/functions/testQuick.test.js +1 -1
- package/functions/typeScript.js +0 -1
- package/functions/typeScript.test.js +0 -2
- package/functions/utilities/dotGet.js +47 -0
- package/functions/utilities/dotNotate.js +68 -0
- package/functions/utilities/dotSet.js +41 -0
- package/functions/utilities/isObject.js +9 -0
- package/functions/watchFull.js +0 -1
- package/functions/watchFull.test.js +1 -1
- package/functions/watchTest.js +1 -2
- package/functions/watchTest.test.js +1 -1
- package/gulp.config.js +153 -79
- package/gulpfile.base.js +5 -1
- package/jsdoc.base.js +1 -1
- package/package.json +13 -9
- package/vendor/array-union/index.js +31 -0
- package/vendor/easy-transform-stream/index.js +58 -0
- package/vendor/globby/gitignore.js +100 -0
- package/vendor/globby/index.js +195 -0
- package/vendor/globby/node_modules/slash/index.js +16 -0
- package/vendor/globby/stream-utils.js +58 -0
- package/vendor/globby/to-path.js +20 -0
- package/vendor/gulp-imagemin/index.js +128 -0
- package/vendor/gulp-imagemin/node_modules/chalk/source/index.js +265 -0
- package/vendor/gulp-imagemin/node_modules/chalk/source/utilities.js +36 -0
- package/vendor/gulp-imagemin/node_modules/chalk/source/vendor/ansi-styles/index.js +217 -0
- package/vendor/gulp-imagemin/node_modules/chalk/source/vendor/supports-color/index.js +154 -0
- package/vendor/gulp-plugin-extras/index.js +46 -0
- package/vendor/gulp-plugin-extras/node_modules/chalk/source/index.js +265 -0
- package/vendor/gulp-plugin-extras/node_modules/chalk/source/utilities.js +36 -0
- package/vendor/gulp-plugin-extras/node_modules/chalk/source/vendor/ansi-styles/index.js +217 -0
- package/vendor/gulp-plugin-extras/node_modules/chalk/source/vendor/supports-color/index.js +154 -0
- package/vendor/gulp-plugin-extras/plugin-error.js +145 -0
- package/vendor/ignore/index.js +468 -0
- package/vendor/imagemin/index.js +94 -0
- package/vendor/imagemin-gifsicle/index.js +37 -0
- package/vendor/imagemin-mozjpeg/index.js +104 -0
- package/vendor/imagemin-mozjpeg/node_modules/execa/index.js +264 -0
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/command.js +47 -0
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/error.js +102 -0
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/kill.js +123 -0
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/promise.js +47 -0
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/stdio.js +50 -0
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/stream.js +128 -0
- package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/core.js +238 -0
- package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/main.js +89 -0
- package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/realtime.js +24 -0
- package/vendor/imagemin-mozjpeg/node_modules/human-signals/build/src/signals.js +44 -0
- package/vendor/imagemin-mozjpeg/node_modules/is-stream/index.js +25 -0
- package/vendor/imagemin-mozjpeg/node_modules/mimic-fn/index.js +70 -0
- package/vendor/imagemin-mozjpeg/node_modules/npm-run-path/index.js +52 -0
- package/vendor/imagemin-mozjpeg/node_modules/onetime/index.js +43 -0
- package/vendor/imagemin-mozjpeg/node_modules/path-key/index.js +20 -0
- package/vendor/imagemin-mozjpeg/node_modules/strip-final-newline/index.js +17 -0
- package/vendor/imagemin-optipng/index.js +44 -0
- package/vendor/imagemin-svgo/index.js +27 -0
- package/vendor/is-jpg/index.js +12 -0
- package/vendor/junk/index.js +49 -0
- package/vendor/mozjpeg/index.js +9 -0
- package/vendor/mozjpeg/lib/index.js +18 -0
- package/vendor/mozjpeg/package.json +50 -0
- package/vendor/p-pipe/index.js +26 -0
- package/vendor/plur/index.js +32 -0
- package/vendor/pretty-bytes/index.js +71 -0
- package/vendor/slash/index.js +12 -0
- package/dist/test-helpers/circularObject.js +0 -50
- package/dist/test-helpers/countMatches.js +0 -12
- package/dist/test-helpers/deepReferenceObject.js +0 -20
- package/dist/test-helpers/domItem.js +0 -33
- package/dist/test-helpers/jsonDom.js +0 -20
- package/dist/test-helpers/linkedList.js +0 -23
- package/dist/test-helpers/logObject.js +0 -21
- package/dist/test-helpers/multiReferenceObject.js +0 -20
- package/dist/test-helpers/nodeTree.js +0 -28
- package/functions/test-helpers/circularObject.js +0 -28
- package/functions/test-helpers/circularObject.test.js +0 -14
- package/functions/test-helpers/countMatches.js +0 -11
- package/functions/test-helpers/countMatches.test.js +0 -9
- package/functions/test-helpers/deepReferenceObject.js +0 -25
- package/functions/test-helpers/deepReferenceObject.test.js +0 -7
- package/functions/test-helpers/domItem.js +0 -31
- package/functions/test-helpers/domItem.test.js +0 -12
- package/functions/test-helpers/jsonDom.js +0 -16
- package/functions/test-helpers/jsonDom.test.js +0 -12
- package/functions/test-helpers/linkedList.js +0 -10
- package/functions/test-helpers/linkedList.test.js +0 -22
- package/functions/test-helpers/logObject.js +0 -18
- package/functions/test-helpers/logObject.test.js +0 -20
- package/functions/test-helpers/multiReferenceObject.js +0 -25
- package/functions/test-helpers/multiReferenceObject.test.js +0 -14
- package/functions/test-helpers/nodeTree.js +0 -11
- package/functions/test-helpers/nodeTree.test.js +0 -18
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Log out an object in a nicely formatted way.
|
|
5
|
-
* @function
|
|
6
|
-
* @memberOf module:testHelpers
|
|
7
|
-
* @param {Object} object
|
|
8
|
-
* @param {string} [label=logging]
|
|
9
|
-
* @param {string} [outputType=log]
|
|
10
|
-
* @returns {string|undefined}
|
|
11
|
-
*/
|
|
12
|
-
const logObject = function (object) {
|
|
13
|
-
let label = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'logging';
|
|
14
|
-
let outputType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'log';
|
|
15
|
-
const logger = outputType === 'string' ? (label, object) => `'${label}' | ` + JSON.stringify(object) : console[outputType];
|
|
16
|
-
if (typeof require === 'undefined' || outputType === 'string') {
|
|
17
|
-
return logger(label, object);
|
|
18
|
-
}
|
|
19
|
-
return logger(label, require('util').inspect(object, false, null, true));
|
|
20
|
-
};
|
|
21
|
-
module.exports = logObject;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Sample of object containing multiple references.
|
|
5
|
-
* @memberOf module:testHelpers
|
|
6
|
-
* @type {Object.<string, string|number|Object>}
|
|
7
|
-
*/
|
|
8
|
-
const multiReferenceObject = {
|
|
9
|
-
object1: {
|
|
10
|
-
name: 'someName'
|
|
11
|
-
},
|
|
12
|
-
object2: {
|
|
13
|
-
age: 12
|
|
14
|
-
},
|
|
15
|
-
array1: ['someString', 'anotherString'],
|
|
16
|
-
array2: [89, 32],
|
|
17
|
-
title: 'Some Title',
|
|
18
|
-
item: 45
|
|
19
|
-
};
|
|
20
|
-
module.exports = multiReferenceObject;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Sample NodeTree for testing circular references and arrays.
|
|
5
|
-
* @memberOf module:testHelpers
|
|
6
|
-
* @type {Object.<string, string|Object|Array>}
|
|
7
|
-
*/
|
|
8
|
-
const nodeTree = {
|
|
9
|
-
name: 'one',
|
|
10
|
-
parent: null,
|
|
11
|
-
children: []
|
|
12
|
-
};
|
|
13
|
-
nodeTree.children[0] = {
|
|
14
|
-
name: 'child one',
|
|
15
|
-
parent: nodeTree,
|
|
16
|
-
children: []
|
|
17
|
-
};
|
|
18
|
-
nodeTree.children[1] = {
|
|
19
|
-
name: 'child two',
|
|
20
|
-
parent: nodeTree,
|
|
21
|
-
children: []
|
|
22
|
-
};
|
|
23
|
-
nodeTree.children[0].children[0] = {
|
|
24
|
-
name: 'grandchild one',
|
|
25
|
-
parent: nodeTree.children[0],
|
|
26
|
-
children: []
|
|
27
|
-
};
|
|
28
|
-
module.exports = nodeTree;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Multilayered node tree-like structure with parent references
|
|
3
|
-
* @memberOf module:testHelpers
|
|
4
|
-
* @type {Object.<string, string|Object|Array>}
|
|
5
|
-
*/
|
|
6
|
-
const circularObject = { name: 'root', parent: {}, body: {}, head: {}, children: [] }
|
|
7
|
-
circularObject.children = [
|
|
8
|
-
{ name: 'body', parent: {}, children: [] },
|
|
9
|
-
{ name: 'head', parent: {}, children: [] }
|
|
10
|
-
]
|
|
11
|
-
circularObject.body = circularObject.children[0]
|
|
12
|
-
circularObject.head = circularObject.children[1]
|
|
13
|
-
circularObject.body.parent = circularObject
|
|
14
|
-
circularObject.head.parent = circularObject
|
|
15
|
-
circularObject.body.children = [
|
|
16
|
-
{ name: 'body child one', parent: {}, children: [] },
|
|
17
|
-
{ name: 'body child two', parent: {}, children: [] }
|
|
18
|
-
]
|
|
19
|
-
circularObject.body.children[0].parent = circularObject.body
|
|
20
|
-
circularObject.body.children[1].parent = circularObject.body
|
|
21
|
-
circularObject.head.children = [
|
|
22
|
-
{ name: 'head child one', parent: {}, children: [] },
|
|
23
|
-
{ name: 'head child two', parent: {}, children: [] }
|
|
24
|
-
]
|
|
25
|
-
circularObject.head.children[0].parent = circularObject.head
|
|
26
|
-
circularObject.head.children[1].parent = circularObject.head
|
|
27
|
-
|
|
28
|
-
module.exports = circularObject
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import circularObject from './circularObject'
|
|
2
|
-
|
|
3
|
-
describe('circularObject', () => {
|
|
4
|
-
test('has sample circular object', () => {
|
|
5
|
-
expect(circularObject.body.parent).toBe(circularObject)
|
|
6
|
-
expect(circularObject.body.children[0].parent).toBe(circularObject.body)
|
|
7
|
-
expect(circularObject.body.children[1].parent).toBe(circularObject.body)
|
|
8
|
-
expect(circularObject.children[0]).toBe(circularObject.body)
|
|
9
|
-
expect(circularObject.head.parent).toBe(circularObject)
|
|
10
|
-
expect(circularObject.head.children[0].parent).toBe(circularObject.head)
|
|
11
|
-
expect(circularObject.head.children[1].parent).toBe(circularObject.head)
|
|
12
|
-
expect(circularObject.children[1]).toBe(circularObject.head)
|
|
13
|
-
})
|
|
14
|
-
})
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Simple way to count string occurrences for testing.
|
|
3
|
-
* @function
|
|
4
|
-
* @memberOf module:testHelpers
|
|
5
|
-
* @param {string} content
|
|
6
|
-
* @param {string} search
|
|
7
|
-
* @returns {number}
|
|
8
|
-
*/
|
|
9
|
-
const countMatches = (content, search) => content.split(search).length - 1
|
|
10
|
-
|
|
11
|
-
module.exports = countMatches
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const countMatches = require('./countMatches')
|
|
2
|
-
|
|
3
|
-
describe('countMatches', () => {
|
|
4
|
-
test('can get count of string occurrences', () => {
|
|
5
|
-
const find = 'find me'
|
|
6
|
-
const sampleString = `${find} in some string that could change the times ${find} will occur here, ${find} should be found three times`
|
|
7
|
-
expect(countMatches(sampleString, find)).toBe(3)
|
|
8
|
-
})
|
|
9
|
-
})
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sample object with deep references.
|
|
3
|
-
* @memberOf module:testHelpers
|
|
4
|
-
* @type {Object.<string, string|number|Object>}
|
|
5
|
-
*/
|
|
6
|
-
const deepReferenceObject = {
|
|
7
|
-
object1: {
|
|
8
|
-
name: 'someName',
|
|
9
|
-
object2: {
|
|
10
|
-
age: 12,
|
|
11
|
-
array1: [
|
|
12
|
-
'someString',
|
|
13
|
-
'anotherString'
|
|
14
|
-
]
|
|
15
|
-
},
|
|
16
|
-
array2: [
|
|
17
|
-
89,
|
|
18
|
-
32
|
|
19
|
-
]
|
|
20
|
-
},
|
|
21
|
-
title: 'Some Title',
|
|
22
|
-
item: 45
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = deepReferenceObject
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sample of domItem child with nested child and optional details
|
|
3
|
-
* @memberOf module:testHelpers
|
|
4
|
-
* @type {Object.<string, string|number|Array|Object>}
|
|
5
|
-
*/
|
|
6
|
-
const domItem = [
|
|
7
|
-
{
|
|
8
|
-
attributes: { className: 'row', style: {} },
|
|
9
|
-
axis: 'y',
|
|
10
|
-
children: [
|
|
11
|
-
{
|
|
12
|
-
attributes: { style: {} },
|
|
13
|
-
axis: 'x',
|
|
14
|
-
children: [],
|
|
15
|
-
element: {},
|
|
16
|
-
eventListeners: {},
|
|
17
|
-
hasShip: false,
|
|
18
|
-
isHit: false,
|
|
19
|
-
parentItem: {},
|
|
20
|
-
point: {},
|
|
21
|
-
tagName: 'div'
|
|
22
|
-
}
|
|
23
|
-
],
|
|
24
|
-
element: null,
|
|
25
|
-
eventListeners: {},
|
|
26
|
-
parentItem: {},
|
|
27
|
-
tagName: 'div'
|
|
28
|
-
}
|
|
29
|
-
]
|
|
30
|
-
|
|
31
|
-
module.exports = domItem
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const domItem = require('./domItem')
|
|
2
|
-
|
|
3
|
-
describe('domItem', () => {
|
|
4
|
-
test('has sample domItem object', () => {
|
|
5
|
-
expect(domItem[0]).toHaveProperty('attributes')
|
|
6
|
-
expect(domItem[0]).toHaveProperty('children')
|
|
7
|
-
expect(domItem[0]).toHaveProperty('element')
|
|
8
|
-
expect(domItem[0]).toHaveProperty('eventListeners')
|
|
9
|
-
expect(domItem[0]).toHaveProperty('parentItem')
|
|
10
|
-
expect(domItem[0]).toHaveProperty('tagName')
|
|
11
|
-
})
|
|
12
|
-
})
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sample of jsonDom object containing empty nested array and objects
|
|
3
|
-
* @memberOf module:testHelpers
|
|
4
|
-
* @type {Object.<string, string|number|Array|Object>}
|
|
5
|
-
*/
|
|
6
|
-
const jsonDom = {
|
|
7
|
-
tagName: 'div',
|
|
8
|
-
attributes: { style: {}, className: 'column' },
|
|
9
|
-
element: null,
|
|
10
|
-
eventListeners: {},
|
|
11
|
-
parentItem: {},
|
|
12
|
-
children: [],
|
|
13
|
-
axis: 'x'
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
module.exports = jsonDom
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const jsonDom = require('./jsonDom')
|
|
2
|
-
|
|
3
|
-
describe('jsonDom', () => {
|
|
4
|
-
test('has sample jsonDom object', () => {
|
|
5
|
-
expect(jsonDom).toHaveProperty('attributes')
|
|
6
|
-
expect(jsonDom).toHaveProperty('children')
|
|
7
|
-
expect(jsonDom).toHaveProperty('element')
|
|
8
|
-
expect(jsonDom).toHaveProperty('eventListeners')
|
|
9
|
-
expect(jsonDom).toHaveProperty('parentItem')
|
|
10
|
-
expect(jsonDom).toHaveProperty('tagName')
|
|
11
|
-
})
|
|
12
|
-
})
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sample LinkedList for testing circular references.
|
|
3
|
-
* @memberOf module:testHelpers
|
|
4
|
-
* @type {Object.<string, string|Object>}
|
|
5
|
-
*/
|
|
6
|
-
const linkedList = { name: 'one', prev: null, next: null }
|
|
7
|
-
linkedList.next = { name: 'two', prev: linkedList, next: null }
|
|
8
|
-
linkedList.next.next = { name: 'three', prev: linkedList.next, next: null }
|
|
9
|
-
|
|
10
|
-
module.exports = linkedList
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const linkedList = require('./linkedList')
|
|
2
|
-
|
|
3
|
-
describe('linkedList', () => {
|
|
4
|
-
test('has sample linkedList object', () => {
|
|
5
|
-
expect(linkedList.name).toBe('one')
|
|
6
|
-
expect(linkedList).toHaveProperty('prev')
|
|
7
|
-
expect(linkedList.prev).toBeNull()
|
|
8
|
-
|
|
9
|
-
expect(linkedList).toHaveProperty('next')
|
|
10
|
-
expect(linkedList.next.name).toBe('two')
|
|
11
|
-
expect(linkedList).toHaveProperty('next.prev')
|
|
12
|
-
expect(linkedList.next.prev).toBe(linkedList)
|
|
13
|
-
|
|
14
|
-
expect(linkedList).toHaveProperty('next.next')
|
|
15
|
-
expect(linkedList.next.next.name).toBe('three')
|
|
16
|
-
expect(linkedList).toHaveProperty('next.prev')
|
|
17
|
-
expect(linkedList.next.next.prev).toBe(linkedList.next)
|
|
18
|
-
|
|
19
|
-
expect(linkedList).toHaveProperty('next.next.next')
|
|
20
|
-
expect(linkedList.next.next.next).toBeNull()
|
|
21
|
-
})
|
|
22
|
-
})
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Log out an object in a nicely formatted way.
|
|
3
|
-
* @function
|
|
4
|
-
* @memberOf module:testHelpers
|
|
5
|
-
* @param {Object} object
|
|
6
|
-
* @param {string} [label=logging]
|
|
7
|
-
* @param {string} [outputType=log]
|
|
8
|
-
* @returns {string|undefined}
|
|
9
|
-
*/
|
|
10
|
-
const logObject = (object, label = 'logging', outputType = 'log') => {
|
|
11
|
-
const logger = outputType === 'string' ? (label, object) => `'${label}' | ` + JSON.stringify(object) : console[outputType]
|
|
12
|
-
if (typeof require === 'undefined' || outputType === 'string') {
|
|
13
|
-
return logger(label, object)
|
|
14
|
-
}
|
|
15
|
-
return logger(label, require('util').inspect(object, false, null, true))
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
module.exports = logObject
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const logObject = require('./logObject')
|
|
2
|
-
const util = require('util')
|
|
3
|
-
|
|
4
|
-
describe('logObject', () => {
|
|
5
|
-
test('can nicely output objects', () => {
|
|
6
|
-
const logSpy = jest.spyOn(console, 'log').mockImplementation(jest.fn())
|
|
7
|
-
const inspectSpy = jest.spyOn(util, 'inspect')
|
|
8
|
-
const someObject = { one: 1, two: 2, three: 3 }
|
|
9
|
-
logObject(someObject, 'someObject')
|
|
10
|
-
expect(inspectSpy).toHaveBeenCalledWith(someObject, false, null, true)
|
|
11
|
-
expect(logSpy).toHaveBeenCalledWith('someObject', util.inspect(someObject, false, null, true))
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
test('output to string when that argument is provided', () => {
|
|
15
|
-
const someObject = { one: 1, two: 2, three: 3 }
|
|
16
|
-
const label = 'someObject'
|
|
17
|
-
const result = logObject(someObject, label, 'string')
|
|
18
|
-
expect(result).toEqual(`'${label}' | ` + JSON.stringify(someObject))
|
|
19
|
-
})
|
|
20
|
-
})
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sample of object containing multiple references.
|
|
3
|
-
* @memberOf module:testHelpers
|
|
4
|
-
* @type {Object.<string, string|number|Object>}
|
|
5
|
-
*/
|
|
6
|
-
const multiReferenceObject = {
|
|
7
|
-
object1: {
|
|
8
|
-
name: 'someName'
|
|
9
|
-
},
|
|
10
|
-
object2: {
|
|
11
|
-
age: 12
|
|
12
|
-
},
|
|
13
|
-
array1: [
|
|
14
|
-
'someString',
|
|
15
|
-
'anotherString'
|
|
16
|
-
],
|
|
17
|
-
array2: [
|
|
18
|
-
89,
|
|
19
|
-
32
|
|
20
|
-
],
|
|
21
|
-
title: 'Some Title',
|
|
22
|
-
item: 45
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = multiReferenceObject
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const multiReferenceObject = require('./multiReferenceObject')
|
|
2
|
-
|
|
3
|
-
describe('multiReferenceObject', () => {
|
|
4
|
-
test('has sample multiReferenceObject object', () => {
|
|
5
|
-
expect(multiReferenceObject).toHaveProperty('object1.name')
|
|
6
|
-
expect(multiReferenceObject).toHaveProperty('object2.age')
|
|
7
|
-
expect(multiReferenceObject).toHaveProperty('array1.0')
|
|
8
|
-
expect(multiReferenceObject).toHaveProperty('array1.1')
|
|
9
|
-
expect(multiReferenceObject).toHaveProperty('array2.0')
|
|
10
|
-
expect(multiReferenceObject).toHaveProperty('array2.1')
|
|
11
|
-
expect(multiReferenceObject).toHaveProperty('title')
|
|
12
|
-
expect(multiReferenceObject).toHaveProperty('item')
|
|
13
|
-
})
|
|
14
|
-
})
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sample NodeTree for testing circular references and arrays.
|
|
3
|
-
* @memberOf module:testHelpers
|
|
4
|
-
* @type {Object.<string, string|Object|Array>}
|
|
5
|
-
*/
|
|
6
|
-
const nodeTree = { name: 'one', parent: null, children: [] }
|
|
7
|
-
nodeTree.children[0] = { name: 'child one', parent: nodeTree, children: [] }
|
|
8
|
-
nodeTree.children[1] = { name: 'child two', parent: nodeTree, children: [] }
|
|
9
|
-
nodeTree.children[0].children[0] = { name: 'grandchild one', parent: nodeTree.children[0], children: [] }
|
|
10
|
-
|
|
11
|
-
module.exports = nodeTree
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import nodeTree from './nodeTree'
|
|
2
|
-
|
|
3
|
-
describe('nodeTree', () => {
|
|
4
|
-
test('has sample nodeTree object', () => {
|
|
5
|
-
expect(nodeTree.name).toBe('one')
|
|
6
|
-
expect(nodeTree.parent).toBeNull()
|
|
7
|
-
expect(nodeTree.children.length).toBe(2)
|
|
8
|
-
expect(nodeTree.children[0].name).toBe('child one')
|
|
9
|
-
expect(nodeTree.children[0].parent).toBe(nodeTree)
|
|
10
|
-
expect(nodeTree.children[0].children.length).toBe(1)
|
|
11
|
-
expect(nodeTree.children[0].children[0].name).toBe('grandchild one')
|
|
12
|
-
expect(nodeTree.children[0].children[0].parent).toBe(nodeTree.children[0])
|
|
13
|
-
expect(nodeTree.children[0].children[0].children.length).toBe(0)
|
|
14
|
-
expect(nodeTree.children[1].name).toBe('child two')
|
|
15
|
-
expect(nodeTree.children[1].parent).toBe(nodeTree)
|
|
16
|
-
expect(nodeTree.children[1].children.length).toBe(0)
|
|
17
|
-
})
|
|
18
|
-
})
|