hashBrowser(JSON.stringify({ a: 'a', b: [1, 2, 3, 4], foo: { c: 'bar' } })).then(console.log); // '04aa106279f5977f59f9067fa9712afc4aedc6f5862a8defc34552d8c7206393' -
Hides all the elements specified.
Use NodeList.prototype.forEach() to apply display: none to each element specified.
const hide = els => els.forEach(e => (e.style.display = 'none')); +
Hides all the elements specified.
Use NodeList.prototype.forEach() to apply display: none to each element specified.
const hide = (...el) => [...el].forEach(e => (e.style.display = 'none'));
hide(document.querySelectorAll('img')); // Hides all <img> elements on the page
Redirects the page to HTTPS if its currently in HTTP. Also, pressing the back button doesn't take it back to the HTTP page as its replaced in the history.
Use location.protocol to get the protocol currently being used. If it's not HTTPS, use location.replace() to replace the existing page with the HTTPS version of the page. Use location.href to get the full address, split it with String.prototype.split() and remove the protocol part of the URL.
const httpsRedirect = () => { if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]); diff --git a/docs/index.html b/docs/index.html index 3c08101c6..8e7f052d7 100644 --- a/docs/index.html +++ b/docs/index.html @@ -526,7 +526,7 @@ console.log< (acc, data, index) => ((acc[!key ? index : data[key]] = data), acc), {} ); -
toHash([4, 3, 2, 1]); // { 0: 4, 1: 3, 2: 2, 1: 1 } +
toHash([4, 3, 2, 1]); // { 0: 4, 1: 3, 2: 2, 3: 1 } toHash([{ a: 'label' }], 'a'); // { label: { a: 'label' } } // A more in depth example: let users = [{ id: 1, first: 'Jon' }, { id: 2, first: 'Joe' }, { id: 3, first: 'Moe' }]; diff --git a/package-lock.json b/package-lock.json index f4507ba4b..70d83e454 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "30-seconds-of-code", - "version": "1.1.0", + "version": "1.2.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 4371ce207..74331954e 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ "fs-extra": "^6.0.0", "html-minifier": "^3.5.20", "jest": "^23.6.0", - "jest-tap-reporter": "^1.9.0", "markdown-builder": "^0.8.4", "markdown-it": "^8.4.2", "node-sass": "^4.9.3", @@ -21,9 +20,10 @@ }, "name": "30-seconds-of-code", "description": "A collection of useful JavaScript snippets.", - "version": "1.1.0", + "version": "1.2.2", "main": "dist/_30s.js", "module": "dist/_30s.esm.js", + "sideEffects": false, "scripts": { "glossary:librarian": "node ./scripts/glossary/library.js", "glossary:keymaker": "node ./scripts/glossary/keyword.js", @@ -36,7 +36,7 @@ "vscoder": "node ./scripts/vscodegen.js", "packager": "node ./scripts/module.js", "localizer": "node ./scripts/localize.js", - "test": "jest --verbose", + "test": "jest --verbose --coverage", "test-with-coverage": "jest --coverage && cat ./coverage/lcov.info | codacy-coverage" }, "repository": { @@ -53,18 +53,6 @@ "bugs": { "url": "https://github.com/30-seconds/30-seconds-of-code/issues" }, - "homepage": "https://github.com/30-seconds/30-seconds-of-code#readme", - "dependencies": {}, - "jest": { - "reporters": [ - [ - "jest-tap-reporter", - { - "logLevel": "INFO", - "showInternalStackTraces": false, - "filePath": "test/testlog" - } - ] - ] - } + "homepage": "https://30secondsofcode.org/", + "dependencies": {} } diff --git a/scripts/build.js b/scripts/build.js index 369336507..34b9b2958 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -47,8 +47,7 @@ if ( // Store the data read from each snippet in the appropriate object for (const name of snippetFilenames.filter(s => s !== 'README.md')) snippets[name] = fs.readFileSync(path.join(SNIPPETS_ARCHIVE_PATH, name), 'utf8'); - } - catch (err) { + } catch (err) { console.log(`${chalk.red('ERROR!')} During snippet loading: ${err}`); process.exit(1); } @@ -70,8 +69,7 @@ if ( // Write to the README file of the archive fs.writeFileSync(path.join(SNIPPETS_ARCHIVE_PATH, 'README.md'), output); - } - catch (err) { + } catch (err) { console.log(`${chalk.red('ERROR!')} During README generation for snippets archive: ${err}`); process.exit(1); } @@ -110,8 +108,7 @@ snippets = util.readSnippets(SNIPPETS_PATH); try { startPart = fs.readFileSync(path.join(STATIC_PARTS_PATH, 'README-start.md'), 'utf8'); endPart = fs.readFileSync(path.join(STATIC_PARTS_PATH, 'README-end.md'), 'utf8'); -} -catch (err) { +} catch (err) { console.log(`${chalk.red('ERROR!')} During static part loading: ${err}`); process.exit(1); } @@ -171,8 +168,7 @@ try { output += `\n${endPart}\n`; // Write to the README file fs.writeFileSync('README.md', output); -} -catch (err) { +} catch (err) { console.log(`${chalk.red('ERROR!')} During README generation: ${err}`); process.exit(1); } diff --git a/scripts/extract.js b/scripts/extract.js index 0f6514fc0..90b8fb745 100644 --- a/scripts/extract.js +++ b/scripts/extract.js @@ -1,94 +1,93 @@ -/* - This is the extractor script that generates the snippets.json and snippetsArchive.json files. - Run using `npm run extractor`. -*/ -// Load modules -const fs = require('fs-extra'); -const path = require('path'); -const chalk = require('chalk'); -const util = require('./util'); -// Paths -const SNIPPETS_PATH = './snippets'; -const SNIPPETS_ARCHIVE_PATH = './snippets_archive'; -const OUTPUT_PATH = './snippet_data'; -// Check if running on Travis - only build for cron jobs and custom builds -if ( - util.isTravisCI() && - process.env['TRAVIS_EVENT_TYPE'] !== 'cron' && - process.env['TRAVIS_EVENT_TYPE'] !== 'api' -) { - console.log(`${chalk.green('NOBUILD')} snippet extraction terminated, not a cron or api build!`); - process.exit(0); -} -// Read data -let snippets = {}, - archivedSnippets = {}, - tagDbData = {}; -console.time('Extractor'); -snippets = util.readSnippets(SNIPPETS_PATH); -archivedSnippets = util.readSnippets(SNIPPETS_ARCHIVE_PATH); -tagDbData = util.readTags(); -// Extract snippet data -let snippetData = Object.keys(snippets).map(key => { - return { - id: key.slice(0, -3), - type: 'snippet', - attributes: { - fileName: key, - text: util.getTextualContent(snippets[key]).trim(), - codeBlocks: util.getCodeBlocks(snippets[key]), - tags: tagDbData[key.slice(0, -3)] - }, - meta: { - archived: false, - hash: util.hashData(snippets[key]) - } - }; -}); -// Extract archived snippet data -let snippetArchiveData = Object.keys(archivedSnippets).map(key => { - return { - id: key.slice(0, -3), - type: 'snippet', - attributes: { - fileName: key, - text: util.getTextualContent(archivedSnippets[key]).trim(), - codeBlocks: util.getCodeBlocks(archivedSnippets[key]), - tags: [] - }, - meta: { - archived: true, - hash: util.hashData(archivedSnippets[key]) - } - }; -}); -const completeData = { - data: [...snippetData, ...snippetArchiveData], - meta: { - specification: 'http://jsonapi.org/format/' - } -}; -let listingData = { - data: - completeData.data.map(v => ({ - id: v.id, - type: 'snippetListing', - attributes: { - tags: v.attributes.tags, - archived: v.meta.archived - }, - meta: { - hash: v.meta.hash - } - })) - , - meta: { - specification: 'http://jsonapi.org/format/' - } -}; -// Write files -fs.writeFileSync(path.join(OUTPUT_PATH, 'snippets.json'), JSON.stringify(completeData, null, 2)); -fs.writeFileSync(path.join(OUTPUT_PATH, 'snippetList.json'), JSON.stringify(listingData, null, 2)); -// Display messages and time -console.log(`${chalk.green('SUCCESS!')} snippets.json and snippetList.json files generated!`); -console.timeEnd('Extractor'); +/* + This is the extractor script that generates the snippets.json and snippetsArchive.json files. + Run using `npm run extractor`. +*/ +// Load modules +const fs = require('fs-extra'); +const path = require('path'); +const chalk = require('chalk'); +const util = require('./util'); +// Paths +const SNIPPETS_PATH = './snippets'; +const SNIPPETS_ARCHIVE_PATH = './snippets_archive'; +const OUTPUT_PATH = './snippet_data'; +// Check if running on Travis - only build for cron jobs and custom builds +if ( + util.isTravisCI() && + process.env['TRAVIS_EVENT_TYPE'] !== 'cron' && + process.env['TRAVIS_EVENT_TYPE'] !== 'api' +) { + console.log(`${chalk.green('NOBUILD')} snippet extraction terminated, not a cron or api build!`); + process.exit(0); +} +// Read data +let snippets = {}, + archivedSnippets = {}, + tagDbData = {}; +console.time('Extractor'); +snippets = util.readSnippets(SNIPPETS_PATH); +archivedSnippets = util.readSnippets(SNIPPETS_ARCHIVE_PATH); +tagDbData = util.readTags(); +// Extract snippet data +let snippetData = Object.keys(snippets).map(key => { + return { + id: key.slice(0, -3), + type: 'snippet', + attributes: { + fileName: key, + text: util.getTextualContent(snippets[key]).trim(), + codeBlocks: util.getCodeBlocks(snippets[key]), + tags: tagDbData[key.slice(0, -3)] + }, + meta: { + archived: false, + hash: util.hashData(snippets[key]) + } + }; +}); +// Extract archived snippet data +let snippetArchiveData = Object.keys(archivedSnippets).map(key => { + return { + id: key.slice(0, -3), + type: 'snippet', + attributes: { + fileName: key, + text: util.getTextualContent(archivedSnippets[key]).trim(), + codeBlocks: util.getCodeBlocks(archivedSnippets[key]), + tags: [] + }, + meta: { + archived: true, + hash: util.hashData(archivedSnippets[key]) + } + }; +}); +const completeData = { + data: [...snippetData, ...snippetArchiveData], + meta: { + specification: 'http://jsonapi.org/format/' + } +}; +let listingData = { + data: + completeData.data.map(v => ({ + id: v.id, + type: 'snippetListing', + attributes: { + tags: v.attributes.tags, + archived: v.meta.archived + }, + meta: { + hash: v.meta.hash + } + })), + meta: { + specification: 'http://jsonapi.org/format/' + } +}; +// Write files +fs.writeFileSync(path.join(OUTPUT_PATH, 'snippets.json'), JSON.stringify(completeData, null, 2)); +fs.writeFileSync(path.join(OUTPUT_PATH, 'snippetList.json'), JSON.stringify(listingData, null, 2)); +// Display messages and time +console.log(`${chalk.green('SUCCESS!')} snippets.json and snippetList.json files generated!`); +console.timeEnd('Extractor'); diff --git a/scripts/glossary/library.js b/scripts/glossary/library.js index 76b5e65cd..e0951dc69 100644 --- a/scripts/glossary/library.js +++ b/scripts/glossary/library.js @@ -41,9 +41,9 @@ const getTermLinkMarkdownBlock = termTitle => { }; const glossaryTableOfContentsReducer = (accumulator, currentFile) => { - if (accumulator === fileTitles[0]) { + if (accumulator === fileTitles[0]) return getTermLinkMarkdownBlock(accumulator) + getTermLinkMarkdownBlock(currentFile); - } + return accumulator + getTermLinkMarkdownBlock(currentFile); }; diff --git a/scripts/lint.js b/scripts/lint.js index c3b1a11f7..05bdf36ea 100644 --- a/scripts/lint.js +++ b/scripts/lint.js @@ -77,8 +77,7 @@ try { console.log(`${chalk.green('SUCCESS!')} Snippet files linted!`); console.timeEnd('Linter'); }); -} -catch (err) { +} catch (err) { console.log(`${chalk.red('ERROR!')} During linting: ${err}`); process.exit(1); } diff --git a/scripts/module.js b/scripts/module.js index 901778a05..cc39fce2f 100644 --- a/scripts/module.js +++ b/scripts/module.js @@ -1,7 +1,7 @@ -/* - Builds the `_30s` module. -*/ -// Load modules +/** + * Builds the `_30s` module in UMD and ESM formats. + * Also builds the test module file for testing snippets. + */ const fs = require('fs-extra'); const path = require('path'); const chalk = require('chalk'); @@ -9,110 +9,159 @@ const util = require('./util'); const { rollup } = require('rollup'); const babel = require('rollup-plugin-babel'); const minify = require('rollup-plugin-babel-minify'); -// Set variables for paths + +const MODULE_NAME = '_30s'; const SNIPPETS_PATH = './snippets'; const SNIPPETS_ARCHIVE_PATH = './snippets_archive'; -const IMPORTS = './imports.js'; -const TEST_PACKAGE = './test/_30s.js'; -const MODULE_NAME = '_30s'; -const DIST = './dist'; -// Regex for selecting code blocks -const codeRE = /```\s*js([\s\S]*?)```/; -// Read snippets, build packages -(async () => { - // Start the timer of the script +const DIST_PATH = './dist'; +const ROLLUP_INPUT_FILE = './imports.temp.js'; +const TEST_MODULE_FILE = './test/_30s.js'; +const CODE_RE = /```\s*js([\s\S]*?)```/; + +/** + * Returns the raw markdown string. + */ +function getRawSnippetString(snippetPath, snippet) { + return fs.readFileSync(path.join(snippetPath, snippet), 'utf8'); +} + +/** + * Returns the JavaScript code from the raw markdown string. + */ +function getCode(rawSnippetString) { + return rawSnippetString.match(CODE_RE)[1].replace('\n', ''); +} + +/** + * Builds the UMD + ESM files to the ./dist directory. + */ +async function doRollup() { + // Plugins + const es5 = babel({ presets: ['@babel/preset-env'] }); + const min = minify({ comments: false }); + + const output = format => file => ({ + format, + file, + name: MODULE_NAME + }); + + const umd = output('umd'); + const esm = output('es'); + + const bundle = await rollup({ input: ROLLUP_INPUT_FILE }); + const bundleES5 = await rollup({ input: ROLLUP_INPUT_FILE, plugins: [es5] }); + const bundleES5Min = await rollup({ + input: ROLLUP_INPUT_FILE, + plugins: [es5, min] + }); + + const baseName = `${DIST_PATH}/${MODULE_NAME}`; + + // UMD ES2018 + await bundle.write(umd(`${baseName}.js`)); + // ESM ES2018 + await bundle.write(esm(`${baseName}.esm.js`)); + // UMD ES5 + await bundleES5.write(umd(`${baseName}.es5.js`)); + // UMD ES5 min + await bundleES5Min.write(umd(`${baseName}.es5.min.js`)); +} + +/** + * Starts the build process. + */ +async function build() { console.time('Packager'); + + let requires = []; + let esmExportString = ''; + let cjsExportString = ''; + try { - const tagDatabase = fs.readFileSync('tag_database', 'utf8'); - const nodeSnippets = tagDatabase.split('\n').filter(v => v.search(/:.*node/g) !== -1).map(v => v.slice(0,v.indexOf(':'))); + if (!fs.existsSync(DIST_PATH)) fs.mkdirSync(DIST_PATH); + fs.writeFileSync(ROLLUP_INPUT_FILE, ''); + fs.writeFileSync(TEST_MODULE_FILE, ''); + + // All the snippets that are Node.js-based and will break in a browser + // environment + const nodeSnippets = fs + .readFileSync('tag_database', 'utf8') + .split('\n') + .filter(v => v.search(/:.*node/g) !== -1) + .map(v => v.slice(0, v.indexOf(':'))); + const snippets = fs.readdirSync(SNIPPETS_PATH); - const snippetExports = `module.exports = {${snippets.map(v => v.replace('.md', '')).join(',')}}`; - let requires = []; - let importData = ''; - const archivedSnippets = fs.readdirSync(SNIPPETS_ARCHIVE_PATH).filter(v => v !== 'README.md'); - const testExports = `module.exports = {${[...snippets,...archivedSnippets].map(v => v.replace('.md', '')).join(',')}}`; - // Create `temp` and `dist` folders if they don't already exist. - if (!fs.existsSync(DIST)) fs.mkdirSync(DIST); - // Write `imports.js` - fs.writeFileSync(IMPORTS, ''); - fs.writeFileSync(TEST_PACKAGE, ''); + const archivedSnippets = fs + .readdirSync(SNIPPETS_ARCHIVE_PATH) + .filter(v => v !== 'README.md'); snippets.forEach(snippet => { - const snippetData = fs.readFileSync(path.join(SNIPPETS_PATH, snippet), 'utf8'); + const rawSnippetString = getRawSnippetString(SNIPPETS_PATH, snippet); const snippetName = snippet.replace('.md', ''); - let code = snippetData.match(codeRE)[1].replace('\n', ''); + let code = getCode(rawSnippetString); if (nodeSnippets.includes(snippetName)) { requires.push(code.match(/const.*=.*require\(([^\)]*)\);/g)); - code = code.replace(/const.*=.*require\(([^\)]*)\);/g,''); + code = code.replace(/const.*=.*require\(([^\)]*)\);/g, ''); } - importData += code; + esmExportString += `export ${code}`; + cjsExportString += code; }); - // Write the data to the imports file - requires = [...new Set(requires.filter(Boolean).map(v => v[0].replace('require(', 'typeof require !== "undefined" && require(')))].join('\n'); - fs.writeFileSync(IMPORTS, `${requires}\n\n${importData}\n\n${snippetExports}`); - archivedSnippets.forEach(snippet => { - const snippetData = fs.readFileSync(path.join(SNIPPETS_ARCHIVE_PATH, snippet), 'utf8'); - let code = snippetData.match(codeRE)[1].replace('\n', ''); - importData += code; + const rawSnippetString = getRawSnippetString( + SNIPPETS_ARCHIVE_PATH, + snippet + ); + cjsExportString += getCode(rawSnippetString); }); - fs.writeFileSync(TEST_PACKAGE, `${requires}\n\n${importData}\n\n${testExports}`); + + requires = [ + ...new Set( + requires + .filter(Boolean) + .map(v => + v[0].replace( + 'require(', + 'typeof require !== "undefined" && require(' + ) + ) + ) + ].join('\n'); + + fs.writeFileSync(ROLLUP_INPUT_FILE, `${requires}\n\n${esmExportString}`); + + const testExports = `module.exports = {${[...snippets, ...archivedSnippets] + .map(v => v.replace('.md', '')) + .join(',')}}`; + + fs.writeFileSync( + TEST_MODULE_FILE, + `${requires}\n\n${cjsExportString}\n\n${testExports}` + ); // Check Travis builds - Will skip builds on Travis if not CRON/API if (util.isTravisCI() && util.isNotTravisCronOrAPI()) { - fs.unlink(IMPORTS); + fs.unlink(ROLLUP_INPUT_FILE); console.log( - `${chalk.green('NOBUILD')} Module build terminated, not a cron job or a custom build!` + `${chalk.green( + 'NOBUILD' + )} Module build terminated, not a cron job or a custom build!` ); console.timeEnd('Packager'); process.exit(0); } - - // Write to the proper files and start the `rollup` script - const es5 = babel({ - presets: ['@babel/preset-env'] - }); - const min = minify({ comments: false }); - const bundle = await rollup({ input: IMPORTS }); - // UMD ES2018 - await bundle.write({ - file: `${DIST}/${MODULE_NAME}.js`, - name: MODULE_NAME, - format: 'umd' - }); - // ESM ES2018 - await bundle.write({ - file: `${DIST}/${MODULE_NAME}.esm.js`, - name: MODULE_NAME, - format: 'es' - }); - // UMD ES5 - const bundleES5 = await rollup({ input: IMPORTS, plugins: [es5] }); - await bundleES5.write({ - file: `${DIST}/${MODULE_NAME}.es5.js`, - name: MODULE_NAME, - format: 'umd' - }); - // UMD ES5 min - const bundleES5Min = await rollup({ - input: IMPORTS, - plugins: [es5, min] - }); - await bundleES5Min.write({ - file: `${DIST}/${MODULE_NAME}.es5.min.js`, - name: MODULE_NAME, - format: 'umd' - }); - // Clean up temporary data - fs.unlink(IMPORTS); - // Log a success message + await doRollup(); + + // Clean up the temporary input file Rollup used for building the module + fs.unlink(ROLLUP_INPUT_FILE); + console.log(`${chalk.green('SUCCESS!')} Snippet module built!`); - // Log the time taken console.timeEnd('Packager'); } catch (err) { - // Handle errors (hopefully not!) console.log(`${chalk.red('ERROR!')} During module creation: ${err}`); process.exit(1); } -})(); \ No newline at end of file +} + +build(); diff --git a/scripts/tag.js b/scripts/tag.js index 6953b4692..f29131533 100644 --- a/scripts/tag.js +++ b/scripts/tag.js @@ -38,8 +38,7 @@ try { output += `${snippet[0].slice(0, -3)}:${tagDbData[snippet[0].slice(0, -3)] .join(',') .trim()}\n`; - } - else { + } else { output += `${snippet[0].slice(0, -3)}:uncategorized\n`; missingTags++; console.log(`${chalk.yellow('Tagged uncategorized:')} ${snippet[0].slice(0, -3)}`); @@ -47,8 +46,7 @@ try { } // Write to tag_database fs.writeFileSync('tag_database', output); -} -catch (err) { +} catch (err) { // Handle errors (hopefully not!) console.log(`${chalk.red('ERROR!')} During tag_database generation: ${err}`); process.exit(1); diff --git a/scripts/tdd.js b/scripts/tdd.js index 46cf22799..e8145e7a5 100644 --- a/scripts/tdd.js +++ b/scripts/tdd.js @@ -9,10 +9,6 @@ const fs = require('fs-extra'), const childProcess = require('child_process'); const chalk = require('chalk'); const util = require('./util'); -if (util.isTravisCI() && util.isNotTravisCronOrAPI()) { - console.log(`${chalk.green('NOBUILD')} Testing terminated, not a cron job or a custom build!`); - process.exit(0); -} // Declare paths const SNIPPETS_PATH = './snippets'; const SNIPPETS_ARCHIVE_PATH = './snippets_archive'; @@ -28,7 +24,7 @@ try { const orphanedTests = [...definedTests.filter(v => ![...snippets, ...archivedSnippets].includes(v))]; orphanedTests.forEach(snippet => { console.log(`${chalk.yellow('WARNING!')} Orphaned test: ${snippet}`); - }) + }); // Create files for undefined tests undefinedTests.forEach(snippet => { const exportTest = [ @@ -41,11 +37,15 @@ try { fs.writeFileSync(path.join(TEST_PATH, `${snippet}.test.js`), exportTest); }); // Run tests - fs.writeFileSync(path.join(TEST_PATH, 'testlog'), `Test log for: ${new Date().toString()}\n`); - childProcess.execSync('npm test'); + if (util.isTravisCI()) { + process.exit(0); + } + else { + childProcess.execSync('npm test'); + } console.log(`${chalk.green('SUCCESS!')} All tests ran successfully!`); } catch (err) { console.log(`${chalk.red('ERROR!')} During test runs: ${err}`); process.exit(1); } -console.timeEnd('Tester'); \ No newline at end of file +console.timeEnd('Tester'); diff --git a/scripts/util.js b/scripts/util.js index f3808a8dc..c43cd00ed 100644 --- a/scripts/util.js +++ b/scripts/util.js @@ -32,8 +32,7 @@ const getFilesInDir = (directoryPath, withPath, exclude = null) => { }, []); } return directoryFilenames; - } - catch (err) { + } catch (err) { console.log(`${chalk.red('ERROR!')} During snippet loading: ${err}`); process.exit(1); } @@ -47,8 +46,7 @@ const readSnippets = snippetsPath => { try { for (let snippet of snippetFilenames) snippets[snippet] = fs.readFileSync(path.join(snippetsPath, snippet), 'utf8'); - } - catch (err) { + } catch (err) { console.log(`${chalk.red('ERROR!')} During snippet loading: ${err}`); process.exit(1); } @@ -71,8 +69,7 @@ const readTags = () => { return data; }) ); - } - catch (err) { + } catch (err) { // Handle errors (hopefully not!) console.log(`${chalk.red('ERROR!')} During tag database loading: ${err}`); process.exit(1); @@ -131,9 +128,9 @@ const getCodeBlocks = str => { results = results.map(v => v.replace(/```js([\s\S]*?)```/g, '$1').trim()); return { es6: results[0], - es5: babel.transformSync(results[0], { presets: ['@babel/preset-env'] }).code.replace('"use strict";\n\n',''), + es5: babel.transformSync(results[0], { presets: ['@babel/preset-env'] }).code.replace('"use strict";\n\n', ''), example: results[1] - } + }; }; // Gets the textual content for a snippet file. const getTextualContent = str => { diff --git a/scripts/vscodegen.js b/scripts/vscodegen.js index 3a89490cc..43db6c3c0 100644 --- a/scripts/vscodegen.js +++ b/scripts/vscodegen.js @@ -11,10 +11,10 @@ let snippetsData = require('../snippet_data/snippets.json'); const OUTPUT_PATH = './vscode_snippets'; console.time('VSCoder'); // Read and format data -let vscodeData = snippetsData.data.filter(v => !v.meta.archived ).reduce((acc,v) => { +let vscodeData = snippetsData.data.filter(v => !v.meta.archived ).reduce((acc, v) => { acc[v.id] = { prefix: `30s_${v.id}`, - body: v.attributes.codeBlocks.es6.replace(/\r/g,'').split('\n'), + body: v.attributes.codeBlocks.es6.replace(/\r/g, '').split('\n'), description: v.attributes.text.slice(0, v.attributes.text.indexOf('\r\n\r\n')) }; return acc; @@ -30,4 +30,4 @@ console.log( 'SUCCESS!' )} vscode_snippets/snippets.json file generated!` ); -console.timeEnd('VSCoder'); \ No newline at end of file +console.timeEnd('VSCoder'); diff --git a/scripts/web.js b/scripts/web.js index df924f021..5c439397c 100644 --- a/scripts/web.js +++ b/scripts/web.js @@ -109,8 +109,7 @@ sass.render( if (!err2) console.log(`${chalk.green('SUCCESS!')} style.css file generated!`); else console.log(`${chalk.red('ERROR!')} During style.css file generation: ${err}`); }); - } - else + } else console.log(`${chalk.red('ERROR!')} During style.css file generation: ${err}`); } @@ -148,8 +147,7 @@ try { 'static-page-start.html', 'static-page-end.html' ].map(filename => fs.readFileSync(path.join(staticPartsPath, filename), 'utf8')); -} -catch (err) { +} catch (err) { // Handle errors (hopefully not!) console.log(`${chalk.red('ERROR!')} During static part loading: ${err}`); process.exit(1); @@ -234,14 +232,13 @@ try { `${chalk.green('SUCCESS!')} ${page.tag === 'array' ? 'index' : page.tag}.html file generated!` ); }); -} -catch (err) { +} catch (err) { // Handle errors (hopefully not!) console.log(`${chalk.red('ERROR!')} During category page generation: ${err}`); process.exit(1); } -const generateMenuForStaticPage = (staticPart) => { +const generateMenuForStaticPage = staticPart => { let taggedData = util.prepTaggedData(tagDbData); // Add the start static part let htmlCode; @@ -258,7 +255,7 @@ const generateMenuForStaticPage = (staticPart) => { htmlCode += md .render( `[${taggedSnippet[0]}](./${ - tag === 'array' ? 'index' : tag + tag === 'array' ? 'index' : tag }#${taggedSnippet[0].toLowerCase()})\n` ) .replace(//g, '') @@ -268,7 +265,7 @@ const generateMenuForStaticPage = (staticPart) => { htmlCode += '\n'; } return staticPart.replace('$nav-menu-data', htmlCode); -} +}; const staticPageStartGenerator = (staticPart, heading, description) => { let taggedData = util.prepTaggedData(tagDbData); @@ -350,8 +347,7 @@ try { fs.writeFileSync(path.join(docsPath, 'archive.html'), minifiedArchivedOutput); console.log(`${chalk.green('SUCCESS!')} archive.html file generated!`); -} -catch (err) { +} catch (err) { console.log(`${chalk.red('ERROR!')} During archive.html generation: ${err}`); process.exit(1); } @@ -384,8 +380,7 @@ try { const minifiedGlossaryOutput = minifyHTML(glossaryOutput); fs.writeFileSync(path.join(docsPath, 'glossary.html'), minifiedGlossaryOutput); console.log(`${chalk.green('SUCCESS!')} glossary.html file generated!`); -} -catch (err) { +} catch (err) { console.log(`${chalk.red('ERROR!')} During glossary.html generation: ${err}`); process.exit(1); } @@ -396,12 +391,10 @@ staticFiles.forEach(f => { if(f !== 'array.html') { let fileData = fs.readFileSync(path.join(staticPartsPath, f), 'utf8'); fs.writeFileSync(path.join(docsPath, f), generateMenuForStaticPage(fileData)); - } - else + } else fs.copyFileSync(path.join(staticPartsPath, f), path.join(docsPath, f)); console.log(`${chalk.green('SUCCESS!')} ${f} file copied!`); - } - catch (err) { + } catch (err) { console.log(`${chalk.red('ERROR!')} During ${f} copying: ${err}`); process.exit(1); } diff --git a/snippet_data/snippetList.json b/snippet_data/snippetList.json index a4a4124cf..e46df3f51 100644 --- a/snippet_data/snippetList.json +++ b/snippet_data/snippetList.json @@ -1664,7 +1664,7 @@ "archived": false }, "meta": { - "hash": "8b7b70809f93fd9392315a5c63aa4cbbf9b45eb1165a7d44db314186d407816b" + "hash": "40558410bed6e9e2866362dc86898fd28a97073f798d8dd5c566eea2ccec2f8f" } }, { @@ -4414,7 +4414,7 @@ "archived": false }, "meta": { - "hash": "c7a62b55b5a90661bf3f9c956f075906439a50151a3aee4023ad8fe878cae2e6" + "hash": "2fd449a2a993bdbc2b93d185ef09aea72af7845152de46d6050db82efe912130" } }, { @@ -5205,7 +5205,7 @@ "archived": true }, "meta": { - "hash": "f5cb5c0acd7e7bca28ac3a7e2c0292db8f72b2e0598dd0b84270d3eb1cc72c8b" + "hash": "7af37e0984b5c8bd78d6b224cdc155f8c2bf687e38b5cfee27f32c7c29dcddf5" } }, { diff --git a/snippet_data/snippets.json b/snippet_data/snippets.json index 7b6bc4bdc..6cfb993e1 100644 --- a/snippet_data/snippets.json +++ b/snippet_data/snippets.json @@ -2443,8 +2443,8 @@ "fileName": "hide.md", "text": "Hides all the elements specified.\n\nUse `NodeList.prototype.forEach()` to apply `display: none` to each element specified.", "codeBlocks": { - "es6": "const hide = els => els.forEach(e => (e.style.display = 'none'));", - "es5": "var hide = function hide(els) {\n return els.forEach(function (e) {\n return e.style.display = 'none';\n });\n};", + "es6": "const hide = (...el) => [...el].forEach(e => (e.style.display = 'none'));", + "es5": "var hide = function hide() {\n for (var _len = arguments.length, el = new Array(_len), _key = 0; _key < _len; _key++) {\n el[_key] = arguments[_key];\n }\n\n return el.concat().forEach(function (e) {\n return e.style.display = 'none';\n });\n};", "example": "hide(document.querySelectorAll('img')); // Hides all
elements on the page" }, "tags": [ @@ -2455,7 +2455,7 @@ }, "meta": { "archived": false, - "hash": "8b7b70809f93fd9392315a5c63aa4cbbf9b45eb1165a7d44db314186d407816b" + "hash": "40558410bed6e9e2866362dc86898fd28a97073f798d8dd5c566eea2ccec2f8f" } }, { @@ -6491,7 +6491,7 @@ "codeBlocks": { "es6": "const toHash = (object, key) =>\n Array.prototype.reduce.call(\n object,\n (acc, data, index) => ((acc[!key ? index : data[key]] = data), acc),\n {}\n );", "es5": "var toHash = function toHash(object, key) {\n return Array.prototype.reduce.call(object, function (acc, data, index) {\n return acc[!key ? index : data[key]] = data, acc;\n }, {});\n};", - "example": "toHash([4, 3, 2, 1]); // { 0: 4, 1: 3, 2: 2, 1: 1 }\ntoHash([{ a: 'label' }], 'a'); // { label: { a: 'label' } }\n// A more in depth example:\nlet users = [{ id: 1, first: 'Jon' }, { id: 2, first: 'Joe' }, { id: 3, first: 'Moe' }];\nlet managers = [{ manager: 1, employees: [2, 3] }];\n// We use function here because we want a bindable reference, but a closure referencing the hash would work, too.\nmanagers.forEach(\n manager =>\n (manager.employees = manager.employees.map(function(id) {\n return this[id];\n }, toHash(users, 'id')))\n);\nmanagers; // [ { manager:1, employees: [ { id: 2, first: \"Joe\" }, { id: 3, first: \"Moe\" } ] } ]" + "example": "toHash([4, 3, 2, 1]); // { 0: 4, 1: 3, 2: 2, 3: 1 }\ntoHash([{ a: 'label' }], 'a'); // { label: { a: 'label' } }\n// A more in depth example:\nlet users = [{ id: 1, first: 'Jon' }, { id: 2, first: 'Joe' }, { id: 3, first: 'Moe' }];\nlet managers = [{ manager: 1, employees: [2, 3] }];\n// We use function here because we want a bindable reference, but a closure referencing the hash would work, too.\nmanagers.forEach(\n manager =>\n (manager.employees = manager.employees.map(function(id) {\n return this[id];\n }, toHash(users, 'id')))\n);\nmanagers; // [ { manager:1, employees: [ { id: 2, first: \"Joe\" }, { id: 3, first: \"Moe\" } ] } ]" }, "tags": [ "array", @@ -6500,7 +6500,7 @@ }, "meta": { "archived": false, - "hash": "c7a62b55b5a90661bf3f9c956f075906439a50151a3aee4023ad8fe878cae2e6" + "hash": "2fd449a2a993bdbc2b93d185ef09aea72af7845152de46d6050db82efe912130" } }, { @@ -7704,7 +7704,7 @@ }, "meta": { "archived": true, - "hash": "f5cb5c0acd7e7bca28ac3a7e2c0292db8f72b2e0598dd0b84270d3eb1cc72c8b" + "hash": "7af37e0984b5c8bd78d6b224cdc155f8c2bf687e38b5cfee27f32c7c29dcddf5" } }, { diff --git a/snippets/hide.md b/snippets/hide.md index 16d40cf0f..53e157adb 100644 --- a/snippets/hide.md +++ b/snippets/hide.md @@ -5,7 +5,7 @@ Hides all the elements specified. Use `NodeList.prototype.forEach()` to apply `display: none` to each element specified. ```js -const hide = els => els.forEach(e => (e.style.display = 'none')); +const hide = (...el) => [...el].forEach(e => (e.style.display = 'none')); ``` ```js diff --git a/snippets/toHash.md b/snippets/toHash.md index 002fe8e92..6ebc38907 100644 --- a/snippets/toHash.md +++ b/snippets/toHash.md @@ -14,7 +14,7 @@ const toHash = (object, key) => ``` ```js -toHash([4, 3, 2, 1]); // { 0: 4, 1: 3, 2: 2, 1: 1 } +toHash([4, 3, 2, 1]); // { 0: 4, 1: 3, 2: 2, 3: 1 } toHash([{ a: 'label' }], 'a'); // { label: { a: 'label' } } // A more in depth example: let users = [{ id: 1, first: 'Jon' }, { id: 2, first: 'Joe' }, { id: 3, first: 'Moe' }]; diff --git a/test/JSONToDate.test.js b/test/JSONToDate.test.js index fc089826e..a4e7febd4 100644 --- a/test/JSONToDate.test.js +++ b/test/JSONToDate.test.js @@ -5,5 +5,5 @@ test('JSONToDate is a Function', () => { expect(JSONToDate).toBeInstanceOf(Function); }); test('JSONToDate returns the correct date string', () => { - expect(JSONToDate(/Date(1489525200000)/)).toBe("14/3/2017"); + expect(JSONToDate(/Date(1489525200000)/)).toBe('14/3/2017'); }); diff --git a/test/_30s.js b/test/_30s.js index 867e9f1c9..cadfa3f13 100644 --- a/test/_30s.js +++ b/test/_30s.js @@ -482,7 +482,7 @@ const hexToRGB = hex => { ')' ); }; -const hide = els => els.forEach(e => (e.style.display = 'none')); +const hide = (...el) => [...el].forEach(e => (e.style.display = 'none')); const httpGet = (url, callback, err = console.error) => { const request = new XMLHttpRequest(); request.open('GET', url, true); diff --git a/test/bindAll.test.js b/test/bindAll.test.js index 193225167..c86c18539 100644 --- a/test/bindAll.test.js +++ b/test/bindAll.test.js @@ -6,7 +6,7 @@ test('bindAll is a Function', () => { }); var view = { label: 'docs', - click: function() { + click() { return 'clicked ' + this.label; } }; diff --git a/test/bindKey.test.js b/test/bindKey.test.js index cf1586955..0952caad7 100644 --- a/test/bindKey.test.js +++ b/test/bindKey.test.js @@ -6,7 +6,7 @@ test('bindKey is a Function', () => { }); const freddy = { user: 'fred', - greet: function(greeting, punctuation) { + greet(greeting, punctuation) { return greeting + ' ' + this.user + punctuation; } }; diff --git a/test/bottomVisible.test.js b/test/bottomVisible.test.js index 591d985b0..ea9170790 100644 --- a/test/bottomVisible.test.js +++ b/test/bottomVisible.test.js @@ -4,3 +4,6 @@ const {bottomVisible} = require('./_30s.js'); test('bottomVisible is a Function', () => { expect(bottomVisible).toBeInstanceOf(Function); }); +test('bottomVisible returns a boolean', () => { + expect(typeof bottomVisible()).toBe('boolean'); +}); diff --git a/test/byteSize.test.js b/test/byteSize.test.js index 1199b5a3b..963aada9f 100644 --- a/test/byteSize.test.js +++ b/test/byteSize.test.js @@ -1,4 +1,5 @@ const expect = require('expect'); +const { byteSize } = require('./_30s.js'); const Blob = class { constructor(s) { return { @@ -6,7 +7,6 @@ const Blob = class { }; } }; -const byteSize = str => new Blob([str]).size; test('byteSize is a Function', () => { expect(byteSize).toBeInstanceOf(Function); diff --git a/test/celsiusToFahrenheit.test.js b/test/celsiusToFahrenheit.test.js index 5735745c2..7b1f0d018 100644 --- a/test/celsiusToFahrenheit.test.js +++ b/test/celsiusToFahrenheit.test.js @@ -6,21 +6,21 @@ test('celsiusToFahrenheit is a Function', () => { }); test('0 Celsius is 32 Fahrenheit', () => { - expect(celsiusToFahrenheit(0)).toBe(32) -}) + expect(celsiusToFahrenheit(0)).toBe(32); +}); test('100 Celsius is 212 Fahrenheit', () => { - expect(celsiusToFahrenheit(100)).toBe(212) -}) + expect(celsiusToFahrenheit(100)).toBe(212); +}); test('-50 Celsius is -58 Fahrenheit', () => { - expect(celsiusToFahrenheit(-50)).toBe(-58) -}) + expect(celsiusToFahrenheit(-50)).toBe(-58); +}); test('1000 Celsius is 1832 Fahrenheit', () => { - expect(celsiusToFahrenheit(1000)).toBe(1832) -}) + expect(celsiusToFahrenheit(1000)).toBe(1832); +}); test('Not a number value is NaN', () => { - expect(celsiusToFahrenheit("Durr")).toBe(NaN) -}) \ No newline at end of file + expect(celsiusToFahrenheit('Durr')).toBe(NaN); +}); diff --git a/test/copyToClipboard.test.js b/test/copyToClipboard.test.js index 27bbd402e..7605b48c3 100644 --- a/test/copyToClipboard.test.js +++ b/test/copyToClipboard.test.js @@ -4,3 +4,28 @@ const {copyToClipboard} = require('./_30s.js'); test('copyToClipboard is a Function', () => { expect(copyToClipboard).toBeInstanceOf(Function); }); +test('copyToClipboard does not throw errors', () => { + document.getSelection = function() { + return { + rangeCount: 0, + removeAllRanges() { return; }, + addRange(x) { return x; } + }; + }; + document.execCommand = function(x) { return x; }; + + expect(copyToClipboard('hi')).toBe(undefined); +}); +test('copyToClipboard does not throw errors', () => { + document.getSelection = function() { + return { + rangeCount: 1, + getRangeAt(x) { return x + 1; }, + removeAllRanges() { return; }, + addRange(x) { return x; } + }; + }; + document.execCommand = function(x) { return x; }; + + expect(copyToClipboard('hi')).toBe(undefined); +}); diff --git a/test/counter.test.js b/test/counter.test.js index b6cc1648c..49a062263 100644 --- a/test/counter.test.js +++ b/test/counter.test.js @@ -4,3 +4,11 @@ const {counter} = require('./_30s.js'); test('counter is a Function', () => { expect(counter).toBeInstanceOf(Function); }); +test('counter does not throw errors', () => { + expect(() => { + document.body.appendChild(document.createElement('div')); + counter('div', 1, 1000, 5, 2000); + counter('div', 1000, 1, 5, 2000); + counter('div', 1, 1000); + }).not.toThrow(TypeError); +}); diff --git a/test/createEventHub.test.js b/test/createEventHub.test.js index ca6ed2088..2b5f1e76e 100644 --- a/test/createEventHub.test.js +++ b/test/createEventHub.test.js @@ -4,3 +4,14 @@ const {createEventHub} = require('./_30s.js'); test('createEventHub is a Function', () => { expect(createEventHub).toBeInstanceOf(Function); }); +test('createEventHub returns an object', () => { + let hub = createEventHub(); + expect(typeof hub).toBe('object'); + expect(typeof hub.hub).toBe('object'); + expect(hub.emit).toBeInstanceOf(Function); + expect(hub.on).toBeInstanceOf(Function); + expect(hub.off).toBeInstanceOf(Function); + expect(hub.emit()).toBe(undefined); + expect(hub.on()).toBe(undefined); + expect(hub.off()).toBe(undefined); +}); diff --git a/test/elementContains.test.js b/test/elementContains.test.js index 2a46c2d49..a1898278f 100644 --- a/test/elementContains.test.js +++ b/test/elementContains.test.js @@ -4,3 +4,13 @@ const {elementContains} = require('./_30s.js'); test('elementContains is a Function', () => { expect(elementContains).toBeInstanceOf(Function); }); +test('elementContains returns true', () => { + let p = document.createElement('div'); + let c = p.appendChild(document.createElement('div')); + expect(elementContains(p, c)).toBeTruthy(); +}); +test('elementContains returns false', () => { + let p = document.createElement('div'); + let c = document.createElement('div'); + expect(elementContains(p, c)).toBeFalsy(); +}); diff --git a/test/elementIsVisibleInViewport.test.js b/test/elementIsVisibleInViewport.test.js index 68f0fa1d2..274ec9c39 100644 --- a/test/elementIsVisibleInViewport.test.js +++ b/test/elementIsVisibleInViewport.test.js @@ -4,3 +4,11 @@ const {elementIsVisibleInViewport} = require('./_30s.js'); test('elementIsVisibleInViewport is a Function', () => { expect(elementIsVisibleInViewport).toBeInstanceOf(Function); }); +test('elementIsVisibleInViewport returns a boolean', () => { + let el = document.createElement('div'); + expect(typeof elementIsVisibleInViewport(el)).toBe('boolean'); +}); +test('elementIsVisibleInViewport returns a boolean', () => { + let el = document.createElement('div'); + expect(typeof elementIsVisibleInViewport(el, true)).toBe('boolean'); +}); diff --git a/test/fahrenheitToCelsius.test.js b/test/fahrenheitToCelsius.test.js index e22dda3c8..f91520f85 100644 --- a/test/fahrenheitToCelsius.test.js +++ b/test/fahrenheitToCelsius.test.js @@ -6,21 +6,21 @@ test('fahrenheitToCelsius is a Function', () => { }); test('32 Fahrenheit is 0 Celsius', () => { - expect(fahrenheitToCelsius(32)).toBe(0) -}) + expect(fahrenheitToCelsius(32)).toBe(0); +}); test('212 Fahrenheit is 100 Celsius', () => { - expect(fahrenheitToCelsius(212)).toBe(100) -}) + expect(fahrenheitToCelsius(212)).toBe(100); +}); test('150 Fahrenheit is 65.55555555555556 Celsius', () => { - expect(fahrenheitToCelsius(150)).toBe(65.55555555555556) -}) + expect(fahrenheitToCelsius(150)).toBe(65.55555555555556); +}); test('1000 Fahrenheit is 537.7777777777778', () => { - expect(fahrenheitToCelsius(1000)).toBe(537.7777777777778) -}) + expect(fahrenheitToCelsius(1000)).toBe(537.7777777777778); +}); test('Not a number value is NaN', () => { - expect(fahrenheitToCelsius("Durr")).toBe(NaN) -}) \ No newline at end of file + expect(fahrenheitToCelsius('Durr')).toBe(NaN); +}); diff --git a/test/getColonTimeFromDate.test.js b/test/getColonTimeFromDate.test.js index 8371c58b6..1e52acd80 100644 --- a/test/getColonTimeFromDate.test.js +++ b/test/getColonTimeFromDate.test.js @@ -7,4 +7,4 @@ test('getColonTimeFromDate is a Function', () => { test('Gets the time in the proper format.', () => { let date = new Date(); expect(getColonTimeFromDate(date)).toEqual(date.toTimeString().slice(0, 8)); -}); \ No newline at end of file +}); diff --git a/test/getImages.test.js b/test/getImages.test.js index dc259cdd6..348bdc36a 100644 --- a/test/getImages.test.js +++ b/test/getImages.test.js @@ -1,18 +1,18 @@ -const expect = require("expect"); -const {getImages} = require("./_30s.js"); -const jsdom = require("jsdom"); +const expect = require('expect'); +const {getImages} = require('./_30s.js'); +const jsdom = require('jsdom'); const { JSDOM } = jsdom; -const TEST_HTML = new JSDOM("
Hello world
").window.document; +const TEST_HTML = new JSDOM('
Hello world
').window.document; -test("getImages is a Function", () => { - expect(getImages).toBeInstanceOf(Function); +test('getImages is a Function', () => { + expect(getImages).toBeInstanceOf(Function); }); -test("getImages returns an Array", () => { - expect(getImages(TEST_HTML)).toBeInstanceOf(Array); +test('getImages returns an Array', () => { + expect(getImages(TEST_HTML)).toBeInstanceOf(Array); }); -test("getImages removes duplicates from images Array", () => { - expect(getImages(TEST_HTML, false).length).toBeLessThanOrEqual(getImages(TEST_HTML, true).length); - expect(getImages(TEST_HTML, true)).toEqual(expect.arrayContaining(getImages(TEST_HTML, false))); +test('getImages removes duplicates from images Array', () => { + expect(getImages(TEST_HTML, false).length).toBeLessThanOrEqual(getImages(TEST_HTML, true).length); + expect(getImages(TEST_HTML, true)).toEqual(expect.arrayContaining(getImages(TEST_HTML, false))); }); diff --git a/test/getScrollPosition.test.js b/test/getScrollPosition.test.js index c061d268b..1863fe74f 100644 --- a/test/getScrollPosition.test.js +++ b/test/getScrollPosition.test.js @@ -4,3 +4,14 @@ const {getScrollPosition} = require('./_30s.js'); test('getScrollPosition is a Function', () => { expect(getScrollPosition).toBeInstanceOf(Function); }); +test('getScrollPosition returns an object with x and y values', () => { + let scrollPos = getScrollPosition(); + expect(typeof scrollPos.x).toBe('number'); + expect(typeof scrollPos.y).toBe('number'); +}); +test('getScrollPosition returns an object with x and y values', () => { + let el = document.createElement('div'); + let scrollPos = getScrollPosition(el); + expect(typeof scrollPos.x).toBe('number'); + expect(typeof scrollPos.y).toBe('number'); +}); diff --git a/test/getStyle.test.js b/test/getStyle.test.js index c6d6e0a1a..84c75fb72 100644 --- a/test/getStyle.test.js +++ b/test/getStyle.test.js @@ -4,3 +4,8 @@ const {getStyle} = require('./_30s.js'); test('getStyle is a Function', () => { expect(getStyle).toBeInstanceOf(Function); }); +test('getStyle returns the proper value', () => { + let el = document.createElement('div'); + el.setAttribute('style', 'font-size: 20px;'); + expect(getStyle(el, 'font-size')).toBe('20px'); +}); diff --git a/test/hasClass.test.js b/test/hasClass.test.js index d7f796238..d8d3307a5 100644 --- a/test/hasClass.test.js +++ b/test/hasClass.test.js @@ -4,3 +4,8 @@ const {hasClass} = require('./_30s.js'); test('hasClass is a Function', () => { expect(hasClass).toBeInstanceOf(Function); }); +test('hasClass returns the proper value', () => { + let el = document.createElement('div'); + el.classList.add('myClass'); + expect(hasClass(el, 'myClass')).toBeTruthy(); +}); diff --git a/test/hide.test.js b/test/hide.test.js index ed5ad2ad1..85a0c390f 100644 --- a/test/hide.test.js +++ b/test/hide.test.js @@ -4,3 +4,9 @@ const {hide} = require('./_30s.js'); test('hide is a Function', () => { expect(hide).toBeInstanceOf(Function); }); +test('hide hides an element', () => { + let el = document.createElement('div'); + el.setAttribute('style', 'display: block;'); + hide(el); + expect(el.style.display).toBe('none'); +}); diff --git a/test/httpDelete.test.js b/test/httpDelete.test.js index b5ea1c17a..7ff85ad9d 100644 --- a/test/httpDelete.test.js +++ b/test/httpDelete.test.js @@ -4,3 +4,9 @@ const {httpDelete} = require('./_30s.js'); test('httpDelete is a Function', () => { expect(httpDelete).toBeInstanceOf(Function); }); +test('httpDelete does not throw errors', () => { + expect(() => { + httpDelete('http://localhost', x => x, console.log); + httpDelete('http://localhost', x => x); + }).not.toThrow(TypeError); +}); diff --git a/test/httpGet.test.js b/test/httpGet.test.js index 9a02c0728..7167a34ee 100644 --- a/test/httpGet.test.js +++ b/test/httpGet.test.js @@ -4,3 +4,9 @@ const {httpGet} = require('./_30s.js'); test('httpGet is a Function', () => { expect(httpGet).toBeInstanceOf(Function); }); +test('httpGet does not throw errors', () => { + expect(() => { + httpGet('http://localhost', x => x, console.log); + httpGet('http://localhost', x => x); + }).not.toThrow(TypeError); +}); diff --git a/test/httpPost.test.js b/test/httpPost.test.js index 85cd66d59..ef69d3c00 100644 --- a/test/httpPost.test.js +++ b/test/httpPost.test.js @@ -4,3 +4,9 @@ const {httpPost} = require('./_30s.js'); test('httpPost is a Function', () => { expect(httpPost).toBeInstanceOf(Function); }); +test('httpPost does not throw errors', () => { + expect(() => { + httpPost('http://localhost', x => x, console.log); + httpPost('http://localhost', x => x); + }).not.toThrow(TypeError); +}); diff --git a/test/httpPut.test.js b/test/httpPut.test.js index 8b472caa7..06e0bd22c 100644 --- a/test/httpPut.test.js +++ b/test/httpPut.test.js @@ -4,3 +4,9 @@ const {httpPut} = require('./_30s.js'); test('httpPut is a Function', () => { expect(httpPut).toBeInstanceOf(Function); }); +test('httpPut does not throw errors', () => { + expect(() => { + httpPut('http://localhost', x => x, console.log); + httpPut('http://localhost', x => x); + }).not.toThrow(TypeError); +}); diff --git a/test/initializeNDArray.test.js b/test/initializeNDArray.test.js index eaf298784..147a1f341 100644 --- a/test/initializeNDArray.test.js +++ b/test/initializeNDArray.test.js @@ -8,5 +8,5 @@ test('Initializes a n-D array with given data', () => { expect(initializeNDArray(1, 3)).toEqual([1, 1, 1]); }); test('Initializes a n-D array with given data', () => { - expect(initializeNDArray(5, 2, 2, 2)).toEqual([[[5, 5], [5, 5]],[[5, 5], [5, 5]]]); + expect(initializeNDArray(5, 2, 2, 2)).toEqual([[[5, 5], [5, 5]], [[5, 5], [5, 5]]]); }); diff --git a/test/insertAfter.test.js b/test/insertAfter.test.js index df05bb871..453f06735 100644 --- a/test/insertAfter.test.js +++ b/test/insertAfter.test.js @@ -5,7 +5,7 @@ test('insertAfter is a Function', () => { expect(insertAfter).toBeInstanceOf(Function); }); let e = document.createElement('div'); -e.setAttribute("id", "test"); +e.setAttribute('id', 'test'); test('Does not throw error if the element exists', () => { expect(() => { insertAfter(e, 'test'); diff --git a/test/insertBefore.test.js b/test/insertBefore.test.js index 332fe9cb2..7d6a3aca6 100644 --- a/test/insertBefore.test.js +++ b/test/insertBefore.test.js @@ -5,7 +5,7 @@ test('insertBefore is a Function', () => { expect(insertBefore).toBeInstanceOf(Function); }); let e = document.createElement('div'); -e.setAttribute("id", "test"); +e.setAttribute('id', 'test'); test('Does not throw error if the element exists', () => { expect(() => { insertBefore(e, 'test'); diff --git a/test/isPrime.test.js b/test/isPrime.test.js index 2e967fce3..e64fdde4e 100644 --- a/test/isPrime.test.js +++ b/test/isPrime.test.js @@ -7,3 +7,6 @@ test('isPrime is a Function', () => { test('passed number is a prime', () => { expect(isPrime(11)).toBeTruthy(); }); +test('passed number is not a prime', () => { + expect(isPrime(10)).toBeFalsy(); +}); diff --git a/test/isPromiseLike.test.js b/test/isPromiseLike.test.js index 7bf5b9af3..ba769c93c 100644 --- a/test/isPromiseLike.test.js +++ b/test/isPromiseLike.test.js @@ -7,7 +7,7 @@ test('isPromiseLike is a Function', () => { test('Returns true for a promise-like object', () => { expect( isPromiseLike({ - then: function() { + then() { return ''; } }) diff --git a/test/isTravisCI.test.js b/test/isTravisCI.test.js index 6489b57ea..b68fe43ba 100644 --- a/test/isTravisCI.test.js +++ b/test/isTravisCI.test.js @@ -4,11 +4,12 @@ const {isTravisCI} = require('./_30s.js'); test('isTravisCI is a Function', () => { expect(isTravisCI).toBeInstanceOf(Function); }); -if (isTravisCI()) +if (isTravisCI()) { test('Running on Travis, correctly evaluates', () => { expect(isTravisCI()).toBeTruthy(); }); -else +} else { test('Not running on Travis, correctly evaluates', () => { expect(isTravisCI()).toBeFalsy(); }); +} diff --git a/test/memoize.test.js b/test/memoize.test.js index fd906727b..886935616 100644 --- a/test/memoize.test.js +++ b/test/memoize.test.js @@ -12,6 +12,9 @@ test('Function works properly', () => { test('Function works properly', () => { expect(square(3)).toBe(9); }); +test('Function works properly, cache stores values (coverage)', () => { + expect(square(3)).toBe(9); +}); test('Cache stores values', () => { expect(Array.from(square.cache)).toEqual([[2, 4], [3, 9]]); }); diff --git a/test/nodeListToArray.test.js b/test/nodeListToArray.test.js index b775d168a..f8d9006af 100644 --- a/test/nodeListToArray.test.js +++ b/test/nodeListToArray.test.js @@ -4,3 +4,6 @@ const {nodeListToArray} = require('./_30s.js'); test('nodeListToArray is a Function', () => { expect(nodeListToArray).toBeInstanceOf(Function); }); +test('nodeListToArray returns an array of proper length', () => { + expect(nodeListToArray(document.childNodes).length).toBe(2); +}); diff --git a/test/off.test.js b/test/off.test.js index 0da5e9d94..a6fd08674 100644 --- a/test/off.test.js +++ b/test/off.test.js @@ -4,3 +4,31 @@ const {off} = require('./_30s.js'); test('off is a Function', () => { expect(off).toBeInstanceOf(Function); }); +test('off removes an event listener', () => { + let el = document.createElement('div'); + let val = false; + const fn = () => val = true; + el.addEventListener('click', fn); + off(el, 'click', fn); + var clickEvent = new MouseEvent('click', { + 'view': window, + 'bubbles': true, + 'cancelable': false + }); + el.dispatchEvent(clickEvent); + expect(val).toBeFalsy(); +}); +test('off removes an event listener', () => { + let el = document.createElement('div'); + let val = false; + const fn = () => val = true; + el.addEventListener('click', fn); + off(el, 'click', fn, {}); + var clickEvent = new MouseEvent('click', { + 'view': window, + 'bubbles': true, + 'cancelable': false + }); + el.dispatchEvent(clickEvent); + expect(val).toBeFalsy(); +}); diff --git a/test/on.test.js b/test/on.test.js index c757e9592..3acdff31f 100644 --- a/test/on.test.js +++ b/test/on.test.js @@ -4,3 +4,30 @@ const {on} = require('./_30s.js'); test('on is a Function', () => { expect(on).toBeInstanceOf(Function); }); +test('on creates an event listener', () => { + let el = document.createElement('div'); + let val = false; + const fn = () => val = true; + on(el, 'click', fn); + var clickEvent = new MouseEvent('click', { + 'view': window, + 'bubbles': true, + 'cancelable': false + }); + el.dispatchEvent(clickEvent); + expect(val).toBeTruthy(); +}); +test('on creates an event listener', () => { + let el = document.createElement('div'); + document.body.appendChild(el); + let val = false; + const fn = () => val = true; + on(document.body, 'click', fn, { target: 'div' }); + var clickEvent = new MouseEvent('click', { + 'view': window, + 'bubbles': true, + 'cancelable': false + }); + el.dispatchEvent(clickEvent); + expect(val).toBeTruthy(); +}); diff --git a/test/once.test.js b/test/once.test.js index 158d164f8..1dd65d3a6 100644 --- a/test/once.test.js +++ b/test/once.test.js @@ -4,6 +4,11 @@ const {once} = require('./_30s.js'); test('once is a Function', () => { expect(once).toBeInstanceOf(Function); }); -test('once is a Function', () => { +test('once returns Function', () => { expect(typeof once(x => 10)).toBe('function'); }); +test('once returns the result only once', () => { + let onced = once(x => x); + expect(onced(10)).toBe(10); + expect(onced(10)).toBe(undefined); +}); diff --git a/test/permutations.test.js b/test/permutations.test.js index f0d8764ab..dc92a0232 100644 --- a/test/permutations.test.js +++ b/test/permutations.test.js @@ -14,3 +14,6 @@ test('Generates all permutations of an array', () => { [5, 33, 1] ]); }); +test('Generates all permutations of an array', () => { + expect(permutations([1])).toEqual([1]); +}); diff --git a/test/pluralize.test.js b/test/pluralize.test.js index 0dbe882cd..e732b500e 100644 --- a/test/pluralize.test.js +++ b/test/pluralize.test.js @@ -13,9 +13,12 @@ test('Produces the singular of the word', () => { test('Produces the plural of the word', () => { expect(pluralize(2, 'apple')).toBe('apples'); }); -test('Prodices the defined plural of the word', () => { +test('Produces the defined plural of the word', () => { expect(pluralize(2, 'person', 'people')).toBe('people'); }); +test('Produces the defined plural of the word', () => { + expect(pluralize(1, 'person', 'people')).toBe('person'); +}); const PLURALS = { person: 'people', radius: 'radii' diff --git a/test/prettyBytes.test.js b/test/prettyBytes.test.js index 954713d42..76fde2e88 100644 --- a/test/prettyBytes.test.js +++ b/test/prettyBytes.test.js @@ -13,3 +13,9 @@ test('Converts a number in bytes to a human-readable string.', () => { test('Converts a number in bytes to a human-readable string.', () => { expect(prettyBytes(123456789, 3, false)).toBe('123MB'); }); +test('Converts a number in bytes to a human-readable string.', () => { + expect(prettyBytes(0, 3, false)).toBe('0B'); +}); +test('Converts a number in bytes to a human-readable string.', () => { + expect(prettyBytes(0, 3, true)).toBe('0 B'); +}); diff --git a/test/shank.test.js b/test/shank.test.js index c53b90656..9311a7899 100644 --- a/test/shank.test.js +++ b/test/shank.test.js @@ -1,21 +1,21 @@ -const expect = require("expect"); -const {shank} = require("./_30s.js"); +const expect = require('expect'); +const {shank} = require('./_30s.js'); -test("shank is a Function", () => { +test('shank is a Function', () => { expect(shank).toBeInstanceOf(Function); }); const names = ['alpha', 'bravo', 'charlie']; -test("Returns an array with the added elements.", () => { +test('Returns an array with the added elements.', () => { expect(shank(names, 1, 0, 'delta')).toEqual(['alpha', 'delta', 'bravo', 'charlie']); }); -test("Returns an array with the removed elements.", () => { +test('Returns an array with the removed elements.', () => { expect(shank(names, 1, 1)).toEqual(['alpha', 'charlie']); }); -test("Does not mutate the original array", () => { +test('Does not mutate the original array', () => { shank(names, 1, 0, 'delta'); expect(names).toEqual(['alpha', 'bravo', 'charlie']); }); diff --git a/test/show.test.js b/test/show.test.js index e1e535f43..fbccef807 100644 --- a/test/show.test.js +++ b/test/show.test.js @@ -4,3 +4,9 @@ const {show} = require('./_30s.js'); test('show is a Function', () => { expect(show).toBeInstanceOf(Function); }); +test('show shows an element', () => { + let el = document.createElement('div'); + el.setAttribute('style', 'display: none;'); + show(el); + expect(el.style.display).not.toBe('none'); +}); diff --git a/test/sortedIndex.test.js b/test/sortedIndex.test.js index bf1606098..9b4d1a83f 100644 --- a/test/sortedIndex.test.js +++ b/test/sortedIndex.test.js @@ -10,3 +10,6 @@ test('Returns the lowest index at which value should be inserted into array in o test('Returns the lowest index at which value should be inserted into array in order to maintain its sort order.', () => { expect(sortedIndex([30, 50], 40)).toBe(1); }); +test('Returns the lowest index at which value should be inserted into array in order to maintain its sort order.', () => { + expect(sortedIndex([30, 50], 60)).toBe(2); +}); diff --git a/test/sortedIndexBy.test.js b/test/sortedIndexBy.test.js index 65545dd7f..5ac4186ce 100644 --- a/test/sortedIndexBy.test.js +++ b/test/sortedIndexBy.test.js @@ -7,3 +7,9 @@ test('sortedIndexBy is a Function', () => { test('Returns the lowest index to insert the element without messing up the list order', () => { expect(sortedIndexBy([{ x: 4 }, { x: 5 }], { x: 4 }, o => o.x)).toBe(0); }); +test('Returns the lowest index to insert the element without messing up the list order', () => { + expect(sortedIndexBy([{ x: 5 }, { x: 4 }], { x: 4 }, o => o.x)).toBe(1); +}); +test('Returns the lowest index to insert the element without messing up the list order', () => { + expect(sortedIndexBy([{ x: 4 }, { x: 5 }], { x: 6 }, o => o.x)).toBe(2); +}); diff --git a/test/sortedLastIndex.test.js b/test/sortedLastIndex.test.js index 789fcc188..718a74c52 100644 --- a/test/sortedLastIndex.test.js +++ b/test/sortedLastIndex.test.js @@ -7,3 +7,9 @@ test('sortedLastIndex is a Function', () => { test('Returns the highest index to insert the element without messing up the list order', () => { expect(sortedLastIndex([10, 20, 30, 30, 40], 30)).toBe(4); }); +test('Returns the highest index to insert the element without messing up the list order', () => { + expect(sortedLastIndex([40, 30, 10], 20)).toBe(2); +}); +test('Returns the highest index to insert the element without messing up the list order', () => { + expect(sortedLastIndex([10, 20, 30, 30, 40], 5)).toBe(0); +}); diff --git a/test/sortedLastIndexBy.test.js b/test/sortedLastIndexBy.test.js index 8185bed93..6d3c203f3 100644 --- a/test/sortedLastIndexBy.test.js +++ b/test/sortedLastIndexBy.test.js @@ -7,3 +7,9 @@ test('sortedLastIndexBy is a Function', () => { test('Returns the highest index to insert the element without messing up the list order', () => { expect(sortedLastIndexBy([{ x: 4 }, { x: 5 }], { x: 4 }, o => o.x)).toBe(1); }); +test('Returns the highest index to insert the element without messing up the list order', () => { + expect(sortedLastIndexBy([{ x: 5 }, { x: 4 }], { x: 5 }, o => o.x)).toBe(1); +}); +test('Returns the highest index to insert the element without messing up the list order', () => { + expect(sortedLastIndexBy([{ x: 4 }, { x: 5 }], { x: 3 }, o => o.x)).toBe(0); +}); diff --git a/test/squareSum.test.js b/test/squareSum.test.js index 08b60a65c..13b31a2af 100644 --- a/test/squareSum.test.js +++ b/test/squareSum.test.js @@ -4,3 +4,6 @@ const {squareSum} = require('./_30s.js'); test('squareSum is a Function', () => { expect(squareSum).toBeInstanceOf(Function); }); +test('squareSum returns the proper result', () => { + expect(squareSum(2, 3, 4)).toBe(29); +}); diff --git a/test/sumBy.test.js b/test/sumBy.test.js index 90523040b..da63193b5 100644 --- a/test/sumBy.test.js +++ b/test/sumBy.test.js @@ -9,4 +9,4 @@ test('Works with a callback.', () => { }); test('Works with a property name.', () => { expect(sumBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n')).toBe(20); -}); \ No newline at end of file +}); diff --git a/test/testlog b/test/testlog deleted file mode 100644 index ea2188a5d..000000000 --- a/test/testlog +++ /dev/null @@ -1,2282 +0,0 @@ - - -# Starting... -# 360 test suites found. - -# PASS test/uniqueElements.test.js - -ok 1 — uniqueElements is a Function -ok 2 — uniqueElements([1, 2, 2, 3, 4, 4, 5]) returns [1,2,3,4,5] -ok 3 — uniqueElements([1, 23, 53]) returns [1, 23, 53] -ok 4 — uniqueElements([true, 0, 1, false, false, undefined, null, '']) returns [true, 0, 1, false, false, undefined, null, ''] -ok 5 — uniqueElements() returns [] -ok 6 — uniqueElements(null) returns [] -ok 7 — uniqueElements(undefined) returns [] -ok 8 — uniqueElements('strt') returns ['s', 't', 'r'] -ok 9 — uniqueElements(1, 1, 2543, 534, 5) throws an error -ok 10 — uniqueElements({}) throws an error -ok 11 — uniqueElements(true) throws an error -ok 12 — uniqueElements(false) throws an error -ok 13 — uniqueElements([true, 0, 1, false, false, undefined, null]) takes less than 2s to run - -# PASS test/toSnakeCase.test.js - -ok 14 — toSnakeCase is a Function -ok 15 — toSnakeCase('camelCase') returns camel_case -ok 16 — toSnakeCase('some text') returns some_text -ok 17 — toSnakeCase('some-mixed_string With spaces_underscores-and-hyphens') returns some_mixed_string_with_spaces_underscores_and_hyphens -ok 18 — toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i_am_listening_to_fm_while_loading_different_url_on_my_browser_and_also_editing_some_xml_and_html -ok 19 — toSnakeCase() returns undefined -ok 20 — toSnakeCase([]) throws an error -ok 21 — toSnakeCase({}) throws an error -ok 22 — toSnakeCase(123) throws an error -ok 23 — toSnakeCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run - -# PASS test/toKebabCase.test.js - -ok 24 — toKebabCase is a Function -ok 25 — toKebabCase('camelCase') returns camel-case -ok 26 — toKebabCase('some text') returns some-text -ok 27 — toKebabCase('some-mixed-string With spaces-underscores-and-hyphens') returns some-mixed-string-with-spaces-underscores-and-hyphens -ok 28 — toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html -ok 29 — toKebabCase() returns undefined -ok 30 — toKebabCase([]) throws an erro -ok 31 — toKebabCase({}) throws an erro -ok 32 — toKebabCase(123) throws an erro -ok 33 — toKebabCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run - -# PASS test/toTitleCase.test.js - -ok 34 — toTitleCase is a Function -ok 35 — toTitleCase('some_database_field_name') returns Some Database Field Name -ok 36 — toTitleCase('Some label that needs to be titled') returns Some Label That Needs To Be Titled -ok 37 — toTitleCase('some-javaScript-property') return Some Java Script Property -ok 38 — toTitleCase('some-mixed_string with spaces_underscores-and-hyphens') returns Some Mixed String With Spaces Underscores And Hyphens -ok 39 — toTitleCase() throws a error -ok 40 — toTitleCase([]) throws a error -ok 41 — toCamelCase({}) throws a error -ok 42 — toTitleCase(123) throws a error -ok 43 — toTitleCase(some-mixed_string with spaces_underscores-and-hyphens) takes less than 2s to run - -# PASS test/toCamelCase.test.js - -ok 44 — toCamelCase is a Function -ok 45 — toCamelCase('some_database_field_name') returns someDatabaseFieldName -ok 46 — toCamelCase('Some label that needs to be camelized') returns someLabelThatNeedsToBeCamelized -ok 47 — toCamelCase('some-javascript-property') return someJavascriptProperty -ok 48 — toCamelCase('some-mixed_string with spaces_underscores-and-hyphens') returns someMixedStringWithSpacesUnderscoresAndHyphens -ok 49 — toCamelCase() throws a error -ok 50 — toCamelCase([]) throws a error -ok 51 — toCamelCase({}) throws a error -ok 52 — toCamelCase(123) throws a error -ok 53 — toCamelCase(some-mixed_string with spaces_underscores-and-hyphens) takes less than 2s to run - -# PASS test/is.test.js - -ok 54 — is is a Function -ok 55 — Works for arrays with data -ok 56 — Works for empty arrays -ok 57 — Works for arrays, not objects -ok 58 — Works for objects -ok 59 — Works for maps -ok 60 — Works for regular expressions -ok 61 — Works for sets -ok 62 — Works for weak maps -ok 63 — Works for weak sets -ok 64 — Works for strings - returns true for primitive -ok 65 — Works for strings - returns true when using constructor -ok 66 — Works for numbers - returns true for primitive -ok 67 — Works for numbers - returns true when using constructor -ok 68 — Works for booleans - returns true for primitive -ok 69 — Works for booleans - returns true when using constructor -ok 70 — Works for functions - -# PASS test/average.test.js - -ok 71 — average is a Function -ok 72 — average(true) returns 0 -ok 73 — average(false) returns 1 -ok 74 — average(9, 1) returns 5 -ok 75 — average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631) returns 32163.909090909092 -ok 76 — average(1, 2, 3) returns 2 -ok 77 — average(null) returns 0 -ok 78 — average(1, 2, 3) returns NaN -ok 79 — average(String) returns NaN -ok 80 — average({ a: 123}) returns NaN -ok 81 — average([undefined, 0, string]) returns NaN -ok 82 — average([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run - -# PASS test/union.test.js - -ok 83 — union is a Function -ok 84 — union([1, 2, 3], [4, 3, 2]) returns [1, 2, 3, 4] -ok 85 — union('str', 'asd') returns [ 's', 't', 'r', 'a', 'd' ] -ok 86 — union([[], {}], [1, 2, 3]) returns [[], {}, 1, 2, 3] -ok 87 — union([], []) returns [] -ok 88 — union() throws an error -ok 89 — union(true, 'str') throws an error -ok 90 — union('false', true) throws an error -ok 91 — union((123, {}) throws an error -ok 92 — union([], {}) throws an error -ok 93 — union(undefined, null) throws an error -ok 94 — union([1, 2, 3], [4, 3, 2]) takes less than 2s to run - -# PASS test/validateNumber.test.js - -ok 95 — validateNumber is a Function -ok 96 — validateNumber(9) returns true -ok 97 — validateNumber(234asd.slice(0, 2)) returns true -ok 98 — validateNumber(1232) returns true -ok 99 — validateNumber(1232 + 13423) returns true -ok 100 — validateNumber(1232 * 2342 * 123) returns true -ok 101 — validateNumber(1232.23423536) returns true -ok 102 — validateNumber(234asd) returns false -ok 103 — validateNumber(e234d) returns false -ok 104 — validateNumber(false) returns false -ok 105 — validateNumber(true) returns false -ok 106 — validateNumber(null) returns false -ok 107 — validateNumber(123 * asd) returns false - -# PASS test/equals.test.js - -ok 108 — equals is a Function -ok 109 — { a: [2, {e: 3}], b: [4], c: 'foo' } is equal to { a: [2, {e: 3}], b: [4], c: 'foo' } -ok 110 — [1,2,3] is equal to [1,2,3] -ok 111 — { a: [2, 3], b: [4] } is not equal to { a: [2, 3], b: [6] } -ok 112 — [1,2,3] is not equal to [1,2,4] -ok 113 — [1, 2, 3] should be equal to { 0: 1, 1: 2, 2: 3 }) - type is different, but their enumerable properties match. -ok 114 — Two of the same date are equal -ok 115 — null should not be equal to anything -ok 116 — undefined should not be equal to anything -ok 117 — {a: ""} should not be equal to {a: "", b: ""} - -# PASS test/toSafeInteger.test.js - -ok 118 — toSafeInteger is a Function -ok 119 — Number(toSafeInteger(3.2)) is a number -ok 120 — Converts a value to a safe integer -ok 121 — toSafeInteger('4.2') returns 4 -ok 122 — toSafeInteger(4.6) returns 5 -ok 123 — toSafeInteger([]) returns 0 -ok 124 — isNaN(toSafeInteger([1.5, 3124])) is true -ok 125 — isNaN(toSafeInteger('string')) is true -ok 126 — isNaN(toSafeInteger({})) is true -ok 127 — isNaN(toSafeInteger()) is true -ok 128 — toSafeInteger(Infinity) returns 9007199254740991 -ok 129 — toSafeInteger(3.2) takes less than 2s to run - -# PASS test/isPrimitive.test.js - -ok 130 — isPrimitive is a Function -ok 131 — isPrimitive(null) is primitive -ok 132 — isPrimitive(undefined) is primitive -ok 133 — isPrimitive(string) is primitive -ok 134 — isPrimitive(true) is primitive -ok 135 — isPrimitive(50) is primitive -ok 136 — isPrimitive('Hello') is primitive -ok 137 — isPrimitive(false) is primitive -ok 138 — isPrimitive(Symbol()) is primitive -ok 139 — isPrimitive([1, 2, 3]) is not primitive -ok 140 — isPrimitive({ a: 123 }) is not primitive -ok 141 — isPrimitive({ a: 123 }) takes less than 2s to run - -# PASS test/zipObject.test.js - -ok 142 — zipObject is a Function -ok 143 — zipObject([a, b, c], [1, 2]) returns {a: 1, b: 2, c: undefined} -ok 144 — zipObject([a, b], [1, 2, 3]) returns {a: 1, b: 2} -ok 145 — zipObject([a, b, c], string) returns { a: s, b: t, c: r } -ok 146 — zipObject([a], string) returns { a: s } -ok 147 — zipObject() throws an error -ok 148 — zipObject((['string'], null) throws an error -ok 149 — zipObject(null, [1]) throws an error -ok 150 — zipObject('string') throws an error -ok 151 — zipObject('test', 'string') throws an error - -# PASS test/quickSort.test.js - -ok 152 — quickSort is a Function -ok 153 — quickSort([5, 6, 4, 3, 1, 2]) returns [1, 2, 3, 4, 5, 6] -ok 154 — quickSort([-1, 0, -2]) returns [-2, -1, 0] -ok 155 — quickSort() throws an error -ok 156 — quickSort(123) throws an error -ok 157 — quickSort({ 234: string}) throws an error -ok 158 — quickSort(null) throws an error -ok 159 — quickSort(undefined) throws an error -ok 160 — quickSort([11, 1, 324, 23232, -1, 53, 2, 524, 32, 13, 156, 133, 62, 12, 4]) takes less than 2s to run - -# PASS test/round.test.js - -ok 161 — round is a Function -ok 162 — round(1.005, 2) returns 1.01 -ok 163 — round(123.3423345345345345344, 11) returns 123.34233453453 -ok 164 — round(3.342, 11) returns 3.342 -ok 165 — round(1.005) returns 1 -ok 166 — round([1.005, 2]) returns NaN -ok 167 — round(string) returns NaN -ok 168 — round() returns NaN -ok 169 — round(132, 413, 4134) returns NaN -ok 170 — round({a: 132}, 413) returns NaN -ok 171 — round(123.3423345345345345344, 11) takes less than 2s to run - -# PASS test/yesNo.test.js - -ok 172 — yesNo is a Function -ok 173 — yesNo(Y) returns true -ok 174 — yesNo(yes) returns true -ok 175 — yesNo(foo, true) returns true -ok 176 — yesNo(No) returns false -ok 177 — yesNo() returns false -ok 178 — yesNo(null) returns false -ok 179 — yesNo(undefined) returns false -ok 180 — yesNo([123, null]) returns false -ok 181 — yesNo([Yes, No]) returns false -ok 182 — yesNo({ 2: Yes }) returns false -ok 183 — yesNo([Yes, No], true) returns true -ok 184 — yesNo({ 2: Yes }, true) returns true - -# PASS test/isSorted.test.js - -ok 185 — isSorted is a Function -ok 186 — Array is sorted in ascending order -ok 187 — Array is sorted in ascending order -ok 188 — Array is sorted in ascending order -ok 189 — Array is sorted in ascending order -ok 190 — Array is sorted in descending order -ok 191 — Array is sorted in descending order -ok 192 — Array is sorted in descending order -ok 193 — Array is sorted in descending order -ok 194 — Array is empty -ok 195 — Array is not sorted, direction changed in array -ok 196 — Array is not sorted, direction changed in array - -# PASS test/longestItem.test.js - -ok 197 — longestItem is a Function -ok 198 — Returns the longest object from plain values -ok 199 — Returns the longest object from a spread array -ok 200 — Returns the longest object from mixed input -ok 201 — Returns the longest array -ok 202 — Returns the longest object when comparing arrays and strings -ok 203 — Returns TypeError without any input -ok 204 — Returns first found of all similar -ok 205 — Throws TypeError if all inputs are undefined - -# PASS test/words.test.js - -ok 206 — words is a Function -ok 207 — words('I love javaScript!!') returns [I, love, javaScript] -ok 208 — words('python, javaScript & coffee') returns [python, javaScript, coffee] -ok 209 — words(I love javaScript!!) returns an array -ok 210 — words() throws an error -ok 211 — words(null) throws an error -ok 212 — words(undefined) throws an error -ok 213 — words({}) throws an error -ok 214 — words([]) throws an error -ok 215 — words(1234) throws an error - -# PASS test/without.test.js - -ok 216 — without is a Function -ok 217 — without([2, 1, 2, 3], 1, 2) returns [3] -ok 218 — without([]) returns [] -ok 219 — without([3, 1, true, '3', true], '3', true) returns [3, 1] -ok 220 — without('string'.split(''), 's', 't', 'g') returns ['r', 'i', 'n'] -ok 221 — without() throws an error -ok 222 — without(null) throws an error -ok 223 — without(undefined) throws an error -ok 224 — without(123) throws an error -ok 225 — without({}) throws an error - -# PASS test/chunk.test.js - -ok 226 — chunk is a Function -ok 227 — chunk([1, 2, 3, 4, 5], 2) returns [[1,2],[3,4],[5]] -ok 228 — chunk([]) returns [] -ok 229 — chunk(123) returns [] -ok 230 — chunk({ a: 123}) returns [] -ok 231 — chunk(string, 2) returns [ st, ri, ng ] -ok 232 — chunk() throws an error -ok 233 — chunk(undefined) throws an error -ok 234 — chunk(null) throws an error -ok 235 — chunk(This is a string, 2) takes less than 2s to run - -# PASS test/zip.test.js - -ok 236 — zip is a Function -ok 237 — zip([a, b], [1, 2], [true, false]) returns [[a, 1, true], [b, 2, false]] -ok 238 — zip([a], [1, 2], [true, false]) returns [[a, 1, true], [undefined, 2, false]] -ok 239 — zip([]) returns [] -ok 240 — zip(123) returns [] -ok 241 — zip([a, b], [1, 2], [true, false]) returns an Array -ok 242 — zip([a], [1, 2], [true, false]) returns an Array -ok 243 — zip(null) throws an error -ok 244 — zip(undefined) throws an error - -# PASS test/uniqueElementsByRight.test.js - -ok 245 — uniqueElementsByRight is a Function -ok 246 — uniqueElementsByRight works for properties -ok 247 — uniqueElementsByRight works for nested properties - -# PASS test/isEmpty.test.js - -ok 248 — isEmpty is a Function -ok 249 — Returns true for empty Map -ok 250 — Returns true for empty Set -ok 251 — Returns true for empty array -ok 252 — Returns true for empty object -ok 253 — Returns true for empty string -ok 254 — Returns false for non-empty array -ok 255 — Returns false for non-empty object -ok 256 — Returns false for non-empty string -ok 257 — Returns true - type is not considered a collection -ok 258 — Returns true - type is not considered a collection - -# PASS test/last.test.js - -ok 259 — last is a Function -ok 260 — last({ a: 1234}) returns undefined -ok 261 — last([1, 2, 3]) returns 3 -ok 262 — last({ 0: false}) returns undefined -ok 263 — last(String) returns g -ok 264 — last(null) throws an Error -ok 265 — last(undefined) throws an Error -ok 266 — last() throws an Error -ok 267 — last([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run - -# PASS test/head.test.js - -ok 268 — head is a Function -ok 269 — head({ a: 1234}) returns undefined -ok 270 — head([1, 2, 3]) returns 1 -ok 271 — head({ 0: false}) returns false -ok 272 — head(String) returns S -ok 273 — head(null) throws an Error -ok 274 — head(undefined) throws an Error -ok 275 — head() throws an Error -ok 276 — head([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run - -# PASS test/uniqueElementsBy.test.js - -ok 277 — uniqueElementsBy is a Function -ok 278 — uniqueElementsBy works for properties -ok 279 — uniqueElementsBy works for nested properties - -# PASS test/allEqual.test.js - -ok 280 — allEqual is a Function -ok 281 — Truthy numbers -ok 282 — Falsy numbers -ok 283 — Truthy strings -ok 284 — Falsy numbers -ok 285 — Truthy trues -ok 286 — Truthy falses -ok 287 — Falsy trues -ok 288 — Falsy falses -ok 289 — False when there are different types - -# PASS test/filterNonUniqueBy.test.js - -ok 290 — filterNonUniqueBy is a Function -ok 291 — filterNonUniqueBy works for properties -ok 292 — filterNonUniqueBy works for nested properties - -# PASS test/all.test.js - -ok 293 — all is a Function -ok 294 — Returns true for arrays with no falsey values -ok 295 — Returns false for arrays with 0 -ok 296 — Returns false for arrays with NaN -ok 297 — Returns false for arrays with undefined -ok 298 — Returns false for arrays with null -ok 299 — Returns false for arrays with empty strings -ok 300 — Returns true with predicate function -ok 301 — Returns false with a predicate function - -# PASS test/offset.test.js - -ok 302 — offset is a Function -ok 303 — Offset of 0 returns the same array. -ok 304 — Offset > 0 returns the offsetted array. -ok 305 — Offset < 0 returns the reverse offsetted array. -ok 306 — Offset greater than the length of the array returns the same array. -ok 307 — Offset less than the negative length of the array returns the same array. -ok 308 — Offsetting empty array returns an empty array. - -# PASS test/binomialCoefficient.test.js - -ok 309 — binomialCoefficient is a Function -ok 310 — Returns the appropriate value -ok 311 — Returns the appropriate value -ok 312 — Returns the appropriate value -ok 313 — Returns the appropriate value -ok 314 — Returns the appropriate value -ok 315 — Returns NaN -ok 316 — Returns NaN - -# PASS test/pluralize.test.js - -ok 317 — pluralize is a Function -ok 318 — Produces the plural of the word -ok 319 — Produces the singular of the word -ok 320 — Produces the plural of the word -ok 321 — Prodices the defined plural of the word -ok 322 — Works with a dictionary - -# PASS test/randomIntArrayInRange.test.js - -ok 323 — randomIntArrayInRange is a Function -ok 324 — The returned array contains only integers -ok 325 — The returned array has the proper length -ok 326 — The returned array's values lie between provided lowerLimit and upperLimit (both inclusive). - -# PASS test/getMeridiemSuffixOfInteger.test.js - -ok 327 — getMeridiemSuffixOfInteger is a Function -ok 328 — Gets the correct meridiem suffix. -ok 329 — Gets the correct meridiem suffix. -ok 330 — Gets the correct meridiem suffix. -ok 331 — Gets the correct meridiem suffix. -ok 332 — Gets the correct meridiem suffix. - -# PASS test/getImages.test.js - -ok 333 — getImages is a Function -ok 334 — getImages returns an Array -ok 335 — getImages removes duplicates from images Array - -# PASS test/sampleSize.test.js - -ok 336 — sampleSize is a Function -ok 337 — Returns a single element without n specified -ok 338 — Returns a random sample of specified size from an array -ok 339 — Returns all elements in an array if n >= length -ok 340 — Returns an empty array if original array is empty -ok 341 — Returns an empty array if n = 0 - -# PASS test/orderBy.test.js - -ok 342 — orderBy is a Function -ok 343 — Returns a sorted array of objects ordered by properties and orders. -ok 344 — Returns a sorted array of objects ordered by properties and orders. - -# PASS test/deepFreeze.test.js - -ok 345 — deepFreeze is a Function -ok 346 — modifying deeply freezed object prop throws an error in strict mode -ok 347 — should not modify deeply freezed object inside another object -ok 348 — should not add prop to deeply freezed empty object - -# PASS test/CSVToArray.test.js - -ok 349 — CSVToArray is a Function -ok 350 — CSVToArray works with default delimiter -ok 351 — CSVToArray works with custom delimiter -ok 352 — CSVToArray omits the first row -ok 353 — CSVToArray omits the first row and works with a custom delimiter - -# PASS test/initializeArrayWithRangeRight.test.js - -ok 354 — initializeArrayWithRangeRight is a Function -ok 355 — Initializes an array containing the numbers in the specified range (witout start value) -ok 356 — Initializes an array containing the numbers in the specified range -ok 357 — Initializes an array containing the numbers in the specified range (with step) - -# PASS test/isWritableStream.test.js - -ok 358 — isWritableStream is a Function -ok 359 — isWritableStream returns false for read streams -ok 360 — isWritableStream returns true for write streams -ok 361 — isWritableStream returns true for duplex streams -ok 362 — isWritableStream returns false for non-streams - -# PASS test/isReadableStream.test.js - -ok 363 — isReadableStream is a Function -ok 364 — isReadableStream returns true for read streams -ok 365 — isReadableStream returns false for write streams -ok 366 — isReadableStream returns true for duplex streams -ok 367 — isReadableStream returns false for non-streams - -# PASS test/inRange.test.js - -ok 368 — inRange is a Function -ok 369 — The given number falls within the given range -ok 370 — The given number falls within the given range (reverse) -ok 371 — The given number falls within the given range -ok 372 — The given number does not falls within the given range -ok 373 — The given number does not falls within the given range - -# PASS test/any.test.js - -ok 374 — any is a Function -ok 375 — Returns true for arrays with at least one truthy value -ok 376 — Returns false for arrays with no truthy values -ok 377 — Returns false for arrays with no truthy values -ok 378 — Returns true with predicate function -ok 379 — Returns false with a predicate function - -# PASS test/randomIntegerInRange.test.js - -ok 380 — randomIntegerInRange is a Function -ok 381 — The returned value is an integer -ok 382 — The returned value lies between provided lowerLimit and upperLimit (both inclusive). - -# PASS test/initializeArrayWithRange.test.js - -ok 383 — initializeArrayWithRange is a Function -ok 384 — Initializes an array containing the numbers in the specified range (witout start value) -ok 385 — Initializes an array containing the numbers in the specified range -ok 386 — Initializes an array containing the numbers in the specified range (with step) - -# PASS test/fahrenheitToCelsius.test.js - -ok 387 — fahrenheitToCelsius is a Function -ok 388 — 32 Fahrenheit is 0 Celsius -ok 389 — 212 Fahrenheit is 100 Celsius -ok 390 — 150 Fahrenheit is 65.55555555555556 Celsius -ok 391 — 1000 Fahrenheit is 537.7777777777778 -ok 392 — Not a number value is NaN - -# PASS test/formatDuration.test.js - -ok 393 — formatDuration is a Function -ok 394 — Returns the human readable format of the given number of milliseconds -ok 395 — Returns the human readable format of the given number of milliseconds (negative) -ok 396 — Returns the human readable format of the given number of milliseconds - -# PASS test/randomNumberInRange.test.js - -ok 397 — randomNumberInRange is a Function -ok 398 — The returned value is a number -ok 399 — The returned value lies between provided lowerLimit and upperLimit (both inclusive). - -# PASS test/isDuplexStream.test.js - -ok 400 — isDuplexStream is a Function -ok 401 — isDuplexStream returns false for read streams -ok 402 — isDuplexStream returns false for write streams -ok 403 — isDuplexStream returns true for duplex streams -ok 404 — isDuplexStream returns false for non-streams - -# PASS test/join.test.js - -ok 405 — join is a Function -ok 406 — Joins all elements of an array into a string and returns this string -ok 407 — Joins all elements of an array into a string and returns this string -ok 408 — Joins all elements of an array into a string and returns this string - -# PASS test/toCurrency.test.js - -ok 409 — toCurrency is a Function -ok 410 — currency: Euro | currencyLangFormat: Local -ok 411 — currency: US Dollar | currencyLangFormat: English (United States) -ok 412 — currency: Japanese Yen | currencyLangFormat: Local - -# PASS test/mapObject.test.js - -ok 413 — mapObject is a Function -ok 414 — mapObject([1, 2, 3], a => a * a) returns { 1: 1, 2: 4, 3: 9 } -ok 415 — mapObject([1, 2, 3, 4], (a, b) => b - a) returns { 1: -1, 2: -1, 3: -1, 4: -1 } -ok 416 — mapObject([1, 2, 3, 4], (a, b) => a - b) returns { 1: 1, 2: 1, 3: 1, 4: 1 } - -# PASS test/factorial.test.js - -ok 417 — factorial is a Function -ok 418 — Calculates the factorial of 720 -ok 419 — Calculates the factorial of 0 -ok 420 — Calculates the factorial of 1 -ok 421 — Calculates the factorial of 4 -ok 422 — Calculates the factorial of 10 -ok 423 — Throws TypeError if n < 0 - -# PASS test/geometricProgression.test.js - -ok 424 — geometricProgression is a Function -ok 425 — Initializes an array containing the numbers in the specified range -ok 426 — Initializes an array containing the numbers in the specified range -ok 427 — Initializes an array containing the numbers in the specified range - -# PASS test/mapString.test.js - -ok 428 — mapString is a Function -ok 429 — mapString returns a capitalized string -ok 430 — mapString can deal with indexes -ok 431 — mapString can deal with the full string - -# PASS test/dig.test.js - -ok 432 — dig is a Function -ok 433 — Dig target success -ok 434 — Dig target with falsey value -ok 435 — Dig target with array -ok 436 — Unknown target return undefined - -# PASS test/levenshteinDistance.test.js - -ok 437 — levenshteinDistance is a Function -ok 438 — levenshteinDistance returns the correct results -ok 439 — levenshteinDistance returns the correct result for 0-length string as first argument -ok 440 — levenshteinDistance returns the correct result for 0-length string as second argument - -# PASS test/celsiusToFahrenheit.test.js - -ok 441 — celsiusToFahrenheit is a Function -ok 442 — 0 Celsius is 32 Fahrenheit -ok 443 — 100 Celsius is 212 Fahrenheit -ok 444 — -50 Celsius is -58 Fahrenheit -ok 445 — 1000 Celsius is 1832 Fahrenheit -ok 446 — Not a number value is NaN - -# PASS test/reduceWhich.test.js - -ok 447 — reduceWhich is a Function -ok 448 — Returns the minimum of an array -ok 449 — Returns the maximum of an array -ok 450 — Returns the object with the minimum specified value in an array - -# PASS test/isStream.test.js - -ok 451 — isStream is a Function -ok 452 — isStream returns true for read streams -ok 453 — isStream returns true for write streams -ok 454 — isStream returns true for duplex streams -ok 455 — isStream returns false for non-streams - -# PASS test/factors.test.js - -ok 456 — factors is a Function -ok 457 — factors returns the correct array -ok 458 — factors returns the correct array of primes -ok 459 — factors returns the correct array for negatives -ok 460 — factors returns the correct array of primes for negatives - -# PASS test/invertKeyValues.test.js - -ok 461 — invertKeyValues is a Function -ok 462 — invertKeyValues({ a: 1, b: 2, c: 1 }) returns { 1: [ 'a', 'c' ], 2: [ 'b' ] } -ok 463 — invertKeyValues({ a: 1, b: 2, c: 1 }, value => 'group' + value) returns { group1: [ 'a', 'c' ], group2: [ 'b' ] } - -# PASS test/fromCamelCase.test.js - -ok 464 — fromCamelCase is a Function -ok 465 — Converts a string from camelcase -ok 466 — Converts a string from camelcase -ok 467 — Converts a string from camelcase - -# PASS test/shank.test.js - -ok 468 — shank is a Function -ok 469 — Returns an array with the added elements. -ok 470 — Returns an array with the removed elements. -ok 471 — Does not mutate the original array - -# PASS test/approximatelyEqual.test.js - -ok 472 — approximatelyEqual is a Function -ok 473 — Works for PI / 2 -ok 474 — Works for 0.1 + 0.2 === 0.3 -ok 475 — Works for exactly equal values -ok 476 — Works for a custom epsilon - -# PASS test/none.test.js - -ok 477 — none is a Function -ok 478 — Returns true for arrays with no truthy values -ok 479 — Returns false for arrays with at least one truthy value -ok 480 — Returns true with a predicate function -ok 481 — Returns false with predicate function - -# PASS test/nest.test.js - -ok 482 — nest is a Function -ok 483 — Nests items - -# PASS test/castArray.test.js - -ok 484 — castArray is a Function -ok 485 — Works for single values -ok 486 — Works for arrays with one value -ok 487 — Works for arrays with multiple value -ok 488 — Works for strings -ok 489 — Works for objects - -# PASS test/nthElement.test.js - -ok 490 — nthElement is a Function -ok 491 — Returns the nth element of an array. -ok 492 — Returns the nth element of an array. -ok 493 — Returns the nth element of an array. -ok 494 — Returns the nth element of an array. - -# PASS test/binarySearch.test.js - -ok 495 — binarySearch is a Function -ok 496 — Finds item in array -ok 497 — Returns -1 when not found -ok 498 — Works with empty arrays -ok 499 — Works for one element arrays - -# PASS test/mask.test.js - -ok 500 — mask is a Function -ok 501 — Replaces all but the last num of characters with the specified mask character -ok 502 — Replaces all but the last num of characters with the specified mask character -ok 503 — Replaces all but the last num of characters with the specified mask character - -# PASS test/randomHexColorCode.test.js - -ok 504 — randomHexColorCode is a Function -ok 505 — randomHexColorCode has to proper length -ok 506 — The color code starts with "#" -ok 507 — The color code contains only valid hex-digits - -# PASS test/howManyTimes.test.js - -ok 508 — howManyTimes is a Function -ok 509 — howManyTimes returns the correct result -ok 510 — howManyTimes returns the correct result -ok 511 — howManyTimes returns the correct result -ok 512 — howManyTimes returns the correct result - -# PASS test/JSONtoCSV.test.js - -ok 513 — JSONtoCSV is a Function -ok 514 — JSONtoCSV works with default delimiter -ok 515 — JSONtoCSV works with custom delimiter - -# PASS test/converge.test.js - -ok 516 — converge is a Function -ok 517 — Produces the average of the array -ok 518 — Produces the strange concatenation - -# PASS test/capitalize.test.js - -ok 519 — capitalize is a Function -ok 520 — Capitalizes the first letter of a string -ok 521 — Capitalizes the first letter of a string -ok 522 — Works with characters -ok 523 — "Works with single character words - -# PASS test/toOrdinalSuffix.test.js - -ok 524 — toOrdinalSuffix is a Function -ok 525 — Adds an ordinal suffix to a number -ok 526 — Adds an ordinal suffix to a number -ok 527 — Adds an ordinal suffix to a number -ok 528 — Adds an ordinal suffix to a number - -# PASS test/deepClone.test.js - -ok 529 — deepClone is a Function -ok 530 — Shallow cloning works -ok 531 — Deep cloning works -ok 532 — Array shallow cloning works -ok 533 — Array deep cloning works - -# PASS test/isAnagram.test.js - -ok 534 — isAnagram is a Function -ok 535 — Checks valid anagram -ok 536 — Works with spaces -ok 537 — Ignores case -ok 538 — Ignores special characters - -# PASS test/tomorrow.test.js - -ok 539 — tomorrow is a Function -ok 540 — Returns the correct year -ok 541 — Returns the correct month -ok 542 — Returns the correct date - -# PASS test/shuffle.test.js - -ok 543 — shuffle is a Function -ok 544 — Shuffles the array -ok 545 — New array contains all original elements -ok 546 — Works for empty arrays -ok 547 — Works for single-element arrays - -# PASS test/prettyBytes.test.js - -ok 548 — prettyBytes is a Function -ok 549 — Converts a number in bytes to a human-readable string. -ok 550 — Converts a number in bytes to a human-readable string. -ok 551 — Converts a number in bytes to a human-readable string. - -# PASS test/isString.test.js - -ok 552 — isString is a Function -ok 553 — foo is a string -ok 554 — "10" is a string -ok 555 — Empty string is a string -ok 556 — 10 is not a string -ok 557 — true is not string - -# PASS test/dropRight.test.js - -ok 558 — dropRight is a Function -ok 559 — Returns a new array with n elements removed from the right -ok 560 — Returns a new array with n elements removed from the right -ok 561 — Returns a new array with n elements removed from the right - -# PASS test/hexToRGB.test.js - -ok 562 — hexToRGB is a Function -ok 563 — Converts a color code to a rgb() or rgba() string -ok 564 — Converts a color code to a rgb() or rgba() string -ok 565 — Converts a color code to a rgb() or rgba() string - -# PASS test/partition.test.js - -ok 566 — partition is a Function -ok 567 — Groups the elements into two arrays, depending on the provided function's truthiness for each element. - -# PASS test/isPromiseLike.test.js - -ok 568 — isPromiseLike is a Function -ok 569 — Returns true for a promise-like object -ok 570 — Returns false for an empty object -ok 571 — Returns false for a normal function - -# PASS test/stringPermutations.test.js - -ok 572 — stringPermutations is a Function -ok 573 — Generates all stringPermutations of a string -ok 574 — Works for single-letter strings -ok 575 — Works for empty strings - -# PASS test/sumPower.test.js - -ok 576 — sumPower is a Function -ok 577 — Returns the sum of the powers of all the numbers from start to end -ok 578 — Returns the sum of the powers of all the numbers from start to end -ok 579 — Returns the sum of the powers of all the numbers from start to end - -# PASS test/isObjectLike.test.js - -ok 580 — isObjectLike is a Function -ok 581 — Returns true for an object -ok 582 — Returns true for an array -ok 583 — Returns false for a function -ok 584 — Returns false for null - -# PASS test/untildify.test.js - -ok 585 — untildify is a Function -ok 586 — Contains no tildes -ok 587 — Does not alter the rest of the path -ok 588 — Does not alter paths without tildes - -# PASS test/isObject.test.js - -ok 589 — isObject is a Function -ok 590 — isObject([1, 2, 3, 4]) is a object -ok 591 — isObject([]) is a object -ok 592 — isObject({ a:1 }) is a object -ok 593 — isObject(true) is not a object - -# PASS test/standardDeviation.test.js - -ok 594 — standardDeviation is a Function -ok 595 — Returns the standard deviation of an array of numbers -ok 596 — Returns the standard deviation of an array of numbers - -# PASS test/functionName.test.js - -ok 597 — functionName is a Function -ok 598 — Works for native functions -ok 599 — Works for normal functions -ok 600 — Works for arrow functions - -# PASS test/capitalizeEveryWord.test.js - -ok 601 — capitalizeEveryWord is a Function -ok 602 — Capitalizes the first letter of every word in a string -ok 603 — Works with characters -ok 604 — Works with one word string - -# PASS test/unzip.test.js - -ok 605 — unzip is a Function -ok 606 — unzip([['a', 1, true], ['b', 2, false]]) equals [['a','b'], [1, 2], [true, false]] -ok 607 — unzip([['a', 1, true], ['b', 2]]) equals [['a','b'], [1, 2], [true]] - -# PASS test/take.test.js - -ok 608 — take is a Function -ok 609 — Returns an array with n elements removed from the beginning. -ok 610 — Returns an array with n elements removed from the beginning. -ok 611 — Returns an array with n elements removed from the beginning. - -# PASS test/URLJoin.test.js - -ok 612 — URLJoin is a Function -ok 613 — Returns proper URL -ok 614 — Returns proper URL - -# PASS test/CSVToJSON.test.js - -ok 615 — CSVToJSON is a Function -ok 616 — CSVToJSON works with default delimiter -ok 617 — CSVToJSON works with custom delimiter - -# PASS test/byteSize.test.js - -ok 618 — byteSize is a Function -ok 619 — Works for a single letter -ok 620 — Works for a common string -ok 621 — Works for emoji - -# PASS test/sortedIndex.test.js - -ok 622 — sortedIndex is a Function -ok 623 — Returns the lowest index at which value should be inserted into array in order to maintain its sort order. -ok 624 — Returns the lowest index at which value should be inserted into array in order to maintain its sort order. - -# PASS test/reducedFilter.test.js - -ok 625 — reducedFilter is a Function -ok 626 — Filter an array of objects based on a condition while also filtering out unspecified keys. - -# PASS test/matches.test.js - -ok 627 — matches is a Function -ok 628 — Matches returns true for two similar objects -ok 629 — Matches returns false for two non-similar objects - -# PASS test/uncurry.test.js - -ok 630 — uncurry is a Function -ok 631 — Works without a provided value for n -ok 632 — Works with n = 2 -ok 633 — Works with n = 3 - -# PASS test/pad.test.js - -ok 634 — pad is a Function -ok 635 — cat is padded on both sides -ok 636 — length of string is 8 -ok 637 — pads 42 with "0" -ok 638 — does not truncates if string exceeds length - -# PASS test/initializeArrayWithValues.test.js - -ok 639 — initializeArrayWithValues is a Function -ok 640 — Initializes and fills an array with the specified values -ok 641 — Initializes and fills an array with the specified values (no fill) - -# PASS test/isAbsoluteURL.test.js - -ok 642 — isAbsoluteURL is a Function -ok 643 — Given string is an absolute URL -ok 644 — Given string is an absolute URL -ok 645 — Given string is not an absolute URL - -# PASS test/collectInto.test.js - -ok 646 — collectInto is a Function -ok 647 — Works with multiple promises - -# PASS test/isValidJSON.test.js - -ok 648 — isValidJSON is a Function -ok 649 — {"name":"Adam","age":20} is a valid JSON -ok 650 — {"name":"Adam",age:"20"} is not a valid JSON -ok 651 — null is a valid JSON - -# PASS test/groupBy.test.js - -ok 652 — groupBy is a Function -ok 653 — Groups the elements of an array based on the given function -ok 654 — Groups the elements of an array based on the given function - -# PASS test/uniqueSymmetricDifference.test.js - -ok 655 — uniqueSymmetricDifference is a Function -ok 656 — Returns the symmetric difference between two arrays. -ok 657 — Does not return duplicates from one array - -# PASS test/symmetricDifferenceWith.test.js - -ok 658 — symmetricDifferenceWith is a Function -ok 659 — Returns the symmetric difference between two arrays, using a provided function as a comparator - -# PASS test/initialize2DArray.test.js - -ok 660 — initialize2DArray is a Function -ok 661 — Initializes a 2D array of given width and height and value -ok 662 — Initializes a 2D array of given width and height and value (no fill) - -# PASS test/lowercaseKeys.test.js - -ok 663 — lowercaseKeys is a Function -ok 664 — Lowercases object keys -ok 665 — Does not mutate original object - -# PASS test/collatz.test.js - -ok 666 — collatz is a Function -ok 667 — When n is even, divide by 2 -ok 668 — When n is odd, times by 3 and add 1 -ok 669 — Eventually reaches 1 - -# PASS test/reject.test.js - -ok 670 — reject is a Function -ok 671 — Works with numbers -ok 672 — Works with strings - -# PASS test/matchesWith.test.js - -ok 673 — matchesWith is a Function -ok 674 — Returns true for two objects with similar values, based on the provided function - -# PASS test/zipWith.test.js - -ok 675 — zipWith is a Function -ok 676 — zipWith returns the correct results -ok 677 — zipWith returns the correct results if no function is passed - -# PASS test/luhnCheck.test.js - -ok 678 — luhnCheck is a Function -ok 679 — validates identification number -ok 680 — validates identification number -ok 681 — validates identification number - -# PASS test/nthArg.test.js - -ok 682 — nthArg is a Function -ok 683 — Returns the nth argument -ok 684 — Returns undefined if arguments too few -ok 685 — Works for negative values - -# PASS test/sample.test.js - -ok 686 — sample is a Function -ok 687 — Returns a random element from the array -ok 688 — Works for single-element arrays -ok 689 — Returns undefined for empty array - -# PASS test/UUIDGeneratorNode.test.js - -ok 690 — UUIDGeneratorNode is a Function -ok 691 — Contains dashes in the proper places -ok 692 — Only contains hexadecimal digits - -# PASS test/drop.test.js - -ok 693 — drop is a Function -ok 694 — Works without the last argument -ok 695 — Removes appropriate element count as specified -ok 696 — Empties array given a count greater than length - -# PASS test/isBeforeDate.test.js - -ok 697 — isBeforeDate is a Function -ok 698 — isBeforeDate produces the correct result -ok 699 — isBeforeDate produces the correct result - -# PASS test/median.test.js - -ok 700 — median is a Function -ok 701 — Returns the median of an array of numbers -ok 702 — Returns the median of an array of numbers -ok 703 — Returns the median of an array of numbers - -# PASS test/symmetricDifference.test.js - -ok 704 — symmetricDifference is a Function -ok 705 — Returns the symmetric difference between two arrays. -ok 706 — Returns duplicates from one array - -# PASS test/flattenObject.test.js - -ok 707 — flattenObject is a Function -ok 708 — Flattens an object with the paths for keys -ok 709 — Works with arrays - -# PASS test/intersectionWith.test.js - -ok 710 — intersectionWith is a Function -ok 711 — Returns a list of elements that exist in both arrays, using a provided comparator function - -# PASS test/elo.test.js - -ok 712 — elo is a Function -ok 713 — Standard 1v1s -ok 714 — Standard 1v1s -ok 715 — 4 player FFA, all same rank - -# PASS test/functions.test.js - -ok 716 — functions is a Function -ok 717 — Returns own methods -ok 718 — Returns own and inherited methods - -# PASS test/isAfterDate.test.js - -ok 719 — isAfterDate is a Function -ok 720 — isAfterDate produces the correct result -ok 721 — isBeforeDate produces the correct result - -# PASS test/differenceBy.test.js - -ok 722 — differenceBy is a Function -ok 723 — Works using a native function and numbers -ok 724 — Works with arrow function and objects - -# PASS test/pipeAsyncFunctions.test.js - -ok 725 — pipeAsyncFunctions is a Function -ok 726 — pipeAsyncFunctions result should be 15 - -# PASS test/memoize.test.js - -ok 727 — memoize is a Function -ok 728 — Function works properly -ok 729 — Function works properly -ok 730 — Cache stores values - -# PASS test/renameKeys.test.js - -ok 731 — renameKeys is a Function -ok 732 — renameKeys is a Function - -# PASS test/isSameDate.test.js - -ok 733 — isSameDate is a Function -ok 734 — isSameDate produces the correct result -ok 735 — isSameDate produces the correct result - -# PASS test/averageBy.test.js - -ok 736 — averageBy is a Function -ok 737 — Produces the right result with a function -ok 738 — Produces the right result with a property name - -# PASS test/isLowerCase.test.js - -ok 739 — isLowerCase is a Function -ok 740 — passed string is a lowercase -ok 741 — passed string is a lowercase -ok 742 — passed value is not a lowercase - -# PASS test/initializeNDArray.test.js - -ok 743 — initializeNDArray is a Function -ok 744 — Initializes a n-D array with given data -ok 745 — Initializes a n-D array with given data - -# PASS test/bindKey.test.js - -ok 746 — bindKey is a Function -ok 747 — Binds function to an object context - -# PASS test/getType.test.js - -ok 748 — getType is a Function -ok 749 — Returns the native type of a value -ok 750 — Returns null for null -ok 751 — Returns undefined for undefined - -# PASS test/findLastKey.test.js - -ok 752 — findLastKey is a Function -ok 753 — eturns the appropriate key - -# PASS test/arrayToCSV.test.js - -ok 754 — arrayToCSV is a Function -ok 755 — arrayToCSV works with default delimiter -ok 756 — arrayToCSV works with custom delimiter - -# PASS test/promisify.test.js - -ok 757 — promisify is a Function -ok 758 — Returns a promise -ok 759 — Runs the function provided - -# PASS test/isArrayLike.test.js - -ok 760 — isArrayLike is a Function -ok 761 — Returns true for a string -ok 762 — Returns true for an array -ok 763 — Returns false for null - -# PASS test/takeWhile.test.js - -ok 764 — takeWhile is a Function -ok 765 — Removes elements until the function returns true -ok 766 — Removes elements until the function returns true - -# PASS test/maxBy.test.js - -ok 767 — maxBy is a Function -ok 768 — Produces the right result with a function -ok 769 — Produces the right result with a property name - -# PASS test/minBy.test.js - -ok 770 — minBy is a Function -ok 771 — Produces the right result with a function -ok 772 — Produces the right result with a property name - -# PASS test/symmetricDifferenceBy.test.js - -ok 773 — symmetricDifferenceBy is a Function -ok 774 — Returns the symmetric difference between two arrays, after applying the provided function to each array element of both - -# PASS test/isUpperCase.test.js - -ok 775 — isUpperCase is a Function -ok 776 — ABC is all upper case -ok 777 — abc is not all upper case -ok 778 — A3@$ is all uppercase - -# PASS test/mostPerformant.test.js - -ok 779 — mostPerformant is a Function -ok 780 — mostPerformant returns a number -ok 781 — mostPerformant returns a number - -# PASS test/unzipWith.test.js - -ok 782 — unzipWith is a Function -ok 783 — unzipWith([[1, 10, 100], [2, 20, 200]], (...args) => args.reduce((acc, v) => acc + v, 0)) equals [3, 30, 300] - -# PASS test/truthCheckCollection.test.js - -ok 784 — truthCheckCollection is a Function -ok 785 — second argument is truthy on all elements of a collection - -# PASS test/pullAtValue.test.js - -ok 786 — pullAtValue is a Function -ok 787 — Pulls the specified values -ok 788 — Pulls the specified values - -# PASS test/findKey.test.js - -ok 789 — findKey is a Function -ok 790 — Returns the appropriate key - -# PASS test/merge.test.js - -ok 791 — merge is a Function -ok 792 — Merges two objects - -# PASS test/bind.test.js - -ok 793 — bind is a Function -ok 794 — Binds to an object context - -# PASS test/pullAtIndex.test.js - -ok 795 — pullAtIndex is a Function -ok 796 — Pulls the given values -ok 797 — Pulls the given values - -# PASS test/indentString.test.js - -ok 798 — indentString is a Function -ok 799 — indentString is a Function -ok 800 — indentString is a Function - -# PASS test/takeRight.test.js - -ok 801 — takeRight is a Function -ok 802 — Returns an array with n elements removed from the end -ok 803 — Returns an array with n elements removed from the end - -# PASS test/transform.test.js - -ok 804 — transform is a Function -ok 805 — Transforms an object - -# PASS test/gcd.test.js - -ok 806 — gcd is a Function -ok 807 — Calculates the greatest common divisor between two or more numbers/arrays -ok 808 — Calculates the greatest common divisor between two or more numbers/arrays - -# PASS test/isNil.test.js - -ok 809 — isNil is a Function -ok 810 — Returns true for null -ok 811 — Returns true for undefined -ok 812 — Returns false for an empty string - -# PASS test/coalesceFactory.test.js - -ok 813 — coalesceFactory is a Function -ok 814 — Returns a customized coalesce function - -# PASS test/indexOfAll.test.js - -ok 815 — indexOfAll is a Function -ok 816 — Returns all indices of val in an array -ok 817 — When val is not found, return an empty array - -# PASS test/extendHex.test.js - -ok 818 — extendHex is a Function -ok 819 — Extends a 3-digit color code to a 6-digit color code -ok 820 — Extends a 3-digit color code to a 6-digit color code - -# PASS test/isPlainObject.test.js - -ok 821 — isPlainObject is a Function -ok 822 — Returns true for a plain object -ok 823 — Returns false for a Map (example of non-plain object) - -# PASS test/maxDate.test.js - -ok 824 — maxDate is a Function -ok 825 — maxDate produces the maximum date - -# PASS test/isTravisCI.test.js - -ok 826 — isTravisCI is a Function -ok 827 — Running on Travis, correctly evaluates - -# PASS test/intersectionBy.test.js - -ok 828 — intersectionBy is a Function -ok 829 — Returns a list of elements that exist in both arrays, after applying the provided function to each array element of both - -# PASS test/minDate.test.js - -ok 830 — minDate is a Function -ok 831 — minDate produces the maximum date - -# PASS test/getURLParameters.test.js - -ok 832 — getURLParameters is a Function -ok 833 — Returns an object containing the parameters of the current URL - -# PASS test/pipeFunctions.test.js - -ok 834 — pipeFunctions is a Function -ok 835 — Performs left-to-right function composition - -# PASS test/reduceSuccessive.test.js - -ok 836 — reduceSuccessive is a Function -ok 837 — Returns the array of successively reduced values - -# PASS test/chainAsync.test.js - -ok 838 — chainAsync is a Function -ok 839 — Calls all functions in an array - -# PASS test/sumBy.test.js - -ok 840 — sumBy is a Function -ok 841 — Works with a callback. -ok 842 — Works with a property name. - -# PASS test/countBy.test.js - -ok 843 — countBy is a Function -ok 844 — Works for functions -ok 845 — Works for property names - -# PASS test/insertBefore.test.js - -ok 846 — insertBefore is a Function -ok 847 — Does not throw error if the element exists - -# PASS test/cleanObj.test.js - -ok 848 — cleanObj is a Function -ok 849 — Removes any properties except the ones specified from a JSON object - -# PASS test/runPromisesInSeries.test.js - -ok 850 — runPromisesInSeries is a Function -ok 851 — Runs promises in series - -# PASS test/overArgs.test.js - -ok 852 — overArgs is a Function -ok 853 — Invokes the provided function with its arguments transformed - -# PASS test/insertAfter.test.js - -ok 854 — insertAfter is a Function -ok 855 — Does not throw error if the element exists - -# PASS test/hashNode.test.js - -ok 856 — hashNode is a Function -ok 857 — Produces the appropriate hash - -# PASS test/spreadOver.test.js - -ok 858 — spreadOver is a Function -ok 859 — Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function. - -# PASS test/decapitalize.test.js - -ok 860 — decapitalize is a Function -ok 861 — Works with default parameter -ok 862 — Works with second parameter set to true - -# PASS test/minN.test.js - -ok 863 — minN is a Function -ok 864 — Returns the n minimum elements from the provided array -ok 865 — Returns the n minimum elements from the provided array - -# PASS test/maxN.test.js - -ok 866 — maxN is a Function -ok 867 — Returns the n maximum elements from the provided array -ok 868 — Returns the n maximum elements from the provided array - -# PASS test/shallowClone.test.js - -ok 869 — shallowClone is a Function -ok 870 — Shallow cloning works -ok 871 — Does not clone deeply - -# PASS test/isArmstrongNumber.test.js - -ok 872 — isArmstrongNumber is a Function -ok 873 — isArmstrongNumber returns true -ok 874 — isArmstrongNumber returns false - -# PASS test/when.test.js - -ok 875 — when is a Function -ok 876 — Returns the proper result -ok 877 — Returns the proper result - -# PASS test/flatten.test.js - -ok 878 — flatten is a Function -ok 879 — Flattens an array -ok 880 — Flattens an array - -# PASS test/partialRight.test.js - -ok 881 — partialRight is a Function -ok 882 — Appends arguments - -# PASS test/composeRight.test.js - -ok 883 — composeRight is a Function -ok 884 — Performs left-to-right function composition - -# PASS test/permutations.test.js - -ok 885 — permutations is a Function -ok 886 — Generates all permutations of an array - -# PASS test/compose.test.js - -ok 887 — compose is a Function -ok 888 — Performs right-to-left function composition - -# PASS test/lcm.test.js - -ok 889 — lcm is a Function -ok 890 — Returns the least common multiple of two or more numbers. -ok 891 — Returns the least common multiple of two or more numbers. - -# PASS test/splitLines.test.js - -ok 892 — splitLines is a Function -ok 893 — Splits a multiline string into an array of lines. - -# PASS test/solveRPN.test.js - -ok 894 — solveRPN is a Function -ok 895 — solveRPN returns the correct result -ok 896 — solveRPN returns the correct result - -# PASS test/bindAll.test.js - -ok 897 — bindAll is a Function -ok 898 — Binds to an object context - -# PASS test/sortedLastIndexBy.test.js - -ok 899 — sortedLastIndexBy is a Function -ok 900 — Returns the highest index to insert the element without messing up the list order - -# PASS test/percentile.test.js - -ok 901 — percentile is a Function -ok 902 — Uses the percentile formula to calculate how many numbers in the given array are less or equal to the given value. - -# PASS test/getDaysDiffBetweenDates.test.js - -ok 903 — getDaysDiffBetweenDates is a Function -ok 904 — Returns the difference in days between two dates - -# PASS test/differenceWith.test.js - -ok 905 — differenceWith is a Function -ok 906 — Filters out all values from an array - -# PASS test/countVowels.test.js - -ok 907 — countVowels is a Function -ok 908 — countVowels returns the correct count -ok 909 — countVowels returns the correct count - -# PASS test/partial.test.js - -ok 910 — partial is a Function -ok 911 — Prepends arguments - -# PASS test/size.test.js - -ok 912 — size is a Function -ok 913 — Get size of arrays, objects or strings. -ok 914 — Get size of arrays, objects or strings. - -# PASS test/mapValues.test.js - -ok 915 — mapValues is a Function -ok 916 — Maps values - -# PASS test/unionWith.test.js - -ok 917 — unionWith is a Function -ok 918 — Produces the appropriate results - -# PASS test/palindrome.test.js - -ok 919 — palindrome is a Function -ok 920 — Given string is a palindrome -ok 921 — Given string is not a palindrome - -# PASS test/bifurcate.test.js - -ok 922 — bifurcate is a Function -ok 923 — Splits the collection into two groups - -# PASS test/bifurcateBy.test.js - -ok 924 — bifurcateBy is a Function -ok 925 — Splits the collection into two groups - -# PASS test/attempt.test.js - -ok 926 — attempt is a Function -ok 927 — Returns a value -ok 928 — Returns an error - -# PASS test/getColonTimeFromDate.test.js - -ok 929 — getColonTimeFromDate is a Function -ok 930 — Gets the time in the proper format. - -# PASS test/degreesToRads.test.js - -ok 931 — degreesToRads is a Function -ok 932 — Returns the appropriate value - -# PASS test/rearg.test.js - -ok 933 — rearg is a Function -ok 934 — Reorders arguments in invoked function - -# PASS test/forOwnRight.test.js - -ok 935 — forOwnRight is a Function -ok 936 — Iterates over an element's key-value pairs in reverse - -# PASS test/pickBy.test.js - -ok 937 — pickBy is a Function -ok 938 — Creates an object composed of the properties the given function returns truthy for. - -# PASS test/flip.test.js - -ok 939 — flip is a Function -ok 940 — Flips argument order - -# PASS test/sortedIndexBy.test.js - -ok 941 — sortedIndexBy is a Function -ok 942 — Returns the lowest index to insert the element without messing up the list order - -# PASS test/dropRightWhile.test.js - -ok 943 — dropRightWhile is a Function -ok 944 — Removes elements from the end of an array until the passed function returns true. - -# PASS test/isSimilar.test.js - -ok 945 — isSimilar is a Function -ok 946 — isSimilar returns true -ok 947 — isSimilar returns false - -# PASS test/get.test.js - -ok 948 — get is a Function -ok 949 — Retrieve a property indicated by the selector from an object. - -# PASS test/omitBy.test.js - -ok 950 — omitBy is a Function -ok 951 — Creates an object composed of the properties the given function returns falsey for - -# PASS test/compact.test.js - -ok 952 — compact is a Function -ok 953 — Removes falsey values from an array - -# PASS test/unescapeHTML.test.js - -ok 954 — unescapeHTML is a Function -ok 955 — Unescapes escaped HTML characters. - -# PASS test/createElement.test.js - -ok 956 — createElement is a Function -ok 957 — createElement creates an element - -# PASS test/isFunction.test.js - -ok 958 — isFunction is a Function -ok 959 — passed value is a function -ok 960 — passed value is not a function - -# PASS test/pullBy.test.js - -ok 961 — pullBy is a Function -ok 962 — Pulls the specified values - -# PASS test/removeVowels.test.js - -ok 963 — removeVowels is a Function -ok 964 — Removes vowels. -ok 965 — Replaces vowels. - -# PASS test/sortedLastIndex.test.js - -ok 966 — sortedLastIndex is a Function -ok 967 — Returns the highest index to insert the element without messing up the list order - -# PASS test/isBoolean.test.js - -ok 968 — isBoolean is a Function -ok 969 — passed value is not a boolean -ok 970 — passed value is not a boolean - -# PASS test/escapeHTML.test.js - -ok 971 — escapeHTML is a Function -ok 972 — Escapes a string for use in HTML - -# PASS test/xProd.test.js - -ok 973 — xProd is a Function -ok 974 — xProd([1, 2], ['a', 'b']) returns [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']] - -# PASS test/unflattenObject.test.js - -ok 975 — unflattenObject is a Function -ok 976 — Unflattens an object with the paths for keys - -# PASS test/isNumber.test.js - -ok 977 — isNumber is a Function -ok 978 — passed argument is a number -ok 979 — passed argument is not a number - -# PASS test/stableSort.test.js - -ok 980 — stableSort is a Function -ok 981 — Array is properly sorted - -# PASS test/sortCharactersInString.test.js - -ok 982 — sortCharactersInString is a Function -ok 983 — Alphabetically sorts the characters in a string. - -# PASS test/unfold.test.js - -ok 984 — unfold is a Function -ok 985 — Works with a given function, producing an array - -# PASS test/forEachRight.test.js - -ok 986 — forEachRight is a Function -ok 987 — Iterates over the array in reverse - -# PASS test/ary.test.js - -ok 988 — ary is a Function -ok 989 — Discards arguments with index >=n - -# PASS test/stripHTMLTags.test.js - -ok 990 — stripHTMLTags is a Function -ok 991 — Removes HTML tags - -# PASS test/objectToPairs.test.js - -ok 992 — objectToPairs is a Function -ok 993 — Creates an array of key-value pair arrays from an object. - -# PASS test/objectFromPairs.test.js - -ok 994 — objectFromPairs is a Function -ok 995 — Creates an object from the given key-value pairs. - -# PASS test/curry.test.js - -ok 996 — curry is a Function -ok 997 — curries a Math.pow -ok 998 — curries a Math.min - -# PASS test/toDecimalMark.test.js - -ok 999 — toDecimalMark is a Function -ok 1000 — convert a float-point arithmetic to the Decimal mark form - -# PASS test/forOwn.test.js - -ok 1001 — forOwn is a Function -ok 1002 — Iterates over an element's key-value pairs - -# PASS test/findLastIndex.test.js - -ok 1003 — findLastIndex is a Function -ok 1004 — Finds last index for which the given function returns true - -# PASS test/pick.test.js - -ok 1005 — pick is a Function -ok 1006 — Picks the key-value pairs corresponding to the given keys from an object. - -# PASS test/isNull.test.js - -ok 1007 — isNull is a Function -ok 1008 — passed argument is a null -ok 1009 — passed argument is a null - -# PASS test/filterNonUnique.test.js - -ok 1010 — filterNonUnique is a Function -ok 1011 — Filters out the non-unique values in an array - -# PASS test/dropWhile.test.js - -ok 1012 — dropWhile is a Function -ok 1013 — Removes elements in an array until the passed function returns true. - -# PASS test/takeRightWhile.test.js - -ok 1014 — takeRightWhile is a Function -ok 1015 — Removes elements until the function returns true - -# PASS test/atob.test.js - -ok 1016 — atob is a Function -ok 1017 — atob("Zm9vYmFy") equals "foobar" -ok 1018 — atob("Z") returns "" - -# PASS test/removeNonASCII.test.js - -ok 1019 — removeNonASCII is a Function -ok 1020 — Removes non-ASCII characters - -# PASS test/delay.test.js - -ok 1021 — delay is a Function -ok 1022 — Works as expecting, passing arguments properly - -# PASS test/remove.test.js - -ok 1023 — remove is a Function -ok 1024 — Removes elements from an array for which the given function returns false - -# PASS test/hz.test.js - -ok 1025 — hz is a Function -ok 1026 — hz returns a number -ok 1027 — hz returns a number - -# PASS test/defaults.test.js - -ok 1028 — defaults is a Function -ok 1029 — Assigns default values for undefined properties - -# PASS test/countOccurrences.test.js - -ok 1030 — countOccurrences is a Function -ok 1031 — Counts the occurrences of a value in an array - -# PASS test/omit.test.js - -ok 1032 — omit is a Function -ok 1033 — Omits the key-value pairs corresponding to the given keys from an object - -# PASS test/clampNumber.test.js - -ok 1034 — clampNumber is a Function -ok 1035 — Clamps num within the inclusive range specified by the boundary values a and b - -# PASS test/intersection.test.js - -ok 1036 — intersection is a Function -ok 1037 — Returns a list of elements that exist in both arrays - -# PASS test/over.test.js - -ok 1038 — over is a Function -ok 1039 — Applies given functions over multiple arguments - -# PASS test/truncateString.test.js - -ok 1040 — truncateString is a Function -ok 1041 — Truncates a "boomerang" up to a specified length. - -# PASS test/parseCookie.test.js - -ok 1042 — parseCookie is a Function -ok 1043 — Parses the cookie - -# PASS test/pull.test.js - -ok 1044 — pull is a Function -ok 1045 — Pulls the specified values - -# PASS test/isBrowserTabFocused.test.js - -ok 1046 — isBrowserTabFocused is a Function -ok 1047 — isBrowserTabFocused is a Function - -# PASS test/similarity.test.js - -ok 1048 — similarity is a Function -ok 1049 — Returns an array of elements that appear in both arrays. - -# PASS test/isEven.test.js - -ok 1050 — isEven is a Function -ok 1051 — 4 is even number -ok 1052 — 5 is not an even number - -# PASS test/findLast.test.js - -ok 1053 — findLast is a Function -ok 1054 — Finds last element for which the given function returns true - -# PASS test/fibonacciUntilNum.test.js - -ok 1055 — fibonacciUntilNum is a Function -ok 1056 — Returns the correct sequence - -# PASS test/times.test.js - -ok 1057 — times is a Function -ok 1058 — Runs a function the specified amount of times - -# PASS test/fibonacciCountUntilNum.test.js - -ok 1059 — fibonacciCountUntilNum is a Function -ok 1060 — Returns the correct number - -# PASS test/cloneRegExp.test.js - -ok 1061 — cloneRegExp is a Function -ok 1062 — Clones regular expressions properly - -# PASS test/coalesce.test.js - -ok 1063 — coalesce is a Function -ok 1064 — Returns the first non-null/undefined argument - -# PASS test/escapeRegExp.test.js - -ok 1065 — escapeRegExp is a Function -ok 1066 — Escapes a string to use in a regular expression - -# PASS test/JSONToDate.test.js - -ok 1067 — JSONToDate is a Function -ok 1068 — JSONToDate returns the correct date string - -# PASS test/tail.test.js - -ok 1069 — tail is a Function -ok 1070 — Returns tail -ok 1071 — Returns tail - -# PASS test/primes.test.js - -ok 1072 — primes is a Function -ok 1073 — Generates primes up to a given number, using the Sieve of Eratosthenes. - -# PASS test/powerset.test.js - -ok 1074 — powerset is a Function -ok 1075 — Returns the powerset of a given array of numbers. - -# PASS test/fibonacci.test.js - -ok 1076 — fibonacci is a Function -ok 1077 — Generates an array, containing the Fibonacci sequence - -# PASS test/distance.test.js - -ok 1078 — distance is a Function -ok 1079 — Calculates the distance between two points - -# PASS test/difference.test.js - -ok 1080 — difference is a Function -ok 1081 — Returns the difference between two arrays - -# PASS test/negate.test.js - -ok 1082 — negate is a Function -ok 1083 — Negates a predicate function - -# PASS test/deepFlatten.test.js - -ok 1084 — deepFlatten is a Function -ok 1085 — Deep flattens an array - -# PASS test/RGBToHex.test.js - -ok 1086 — RGBToHex is a Function -ok 1087 — Converts the values of RGB components to a color code. - -# PASS test/hammingDistance.test.js - -ok 1088 — hammingDistance is a Function -ok 1089 — retuns hamming disance between 2 values - -# PASS test/currentURL.test.js - -ok 1090 — currentURL is a Function -ok 1091 — currentURL returns the appropriate value - -# PASS test/everyNth.test.js - -ok 1092 — everyNth is a Function -ok 1093 — Returns every nth element in an array - -# PASS test/initial.test.js - -ok 1094 — initial is a Function -ok 1095 — Returns all the elements of an array except the last one - -# PASS test/unionBy.test.js - -ok 1096 — unionBy is a Function -ok 1097 — Produces the appropriate results - -# PASS test/serializeCookie.test.js - -ok 1098 — serializeCookie is a Function -ok 1099 — Serializes the cookie - -# PASS test/sleep.test.js - -ok 1100 — sleep is a Function -ok 1101 — Works as expected - -# PASS test/unary.test.js - -ok 1102 — unary is a Function -ok 1103 — Discards arguments after the first one - -# PASS test/mapKeys.test.js - -ok 1104 — mapKeys is a Function -ok 1105 — Maps keys - -# PASS test/radsToDegrees.test.js - -ok 1106 — radsToDegrees is a Function -ok 1107 — Returns the appropriate value - -# PASS test/isSymbol.test.js - -ok 1108 — isSymbol is a Function -ok 1109 — Checks if the given argument is a symbol - -# PASS test/digitize.test.js - -ok 1110 — digitize is a Function -ok 1111 — Converts a number to an array of digits - -# PASS test/call.test.js - -ok 1112 — call is a Function -ok 1113 — Calls function on given object - -# PASS test/reverseString.test.js - -ok 1114 — reverseString is a Function -ok 1115 — Reverses a string. - -# PASS test/isUndefined.test.js - -ok 1116 — isUndefined is a Function -ok 1117 — Returns true for undefined - -# PASS test/isDivisible.test.js - -ok 1118 — isDivisible is a Function -ok 1119 — The number 6 is divisible by 3 - -# PASS test/heronArea.test.js - -ok 1120 — heronArea is a Function -ok 1121 — howManyTimes returns the correct result - -# PASS test/colorize.test.js - -ok 1122 — colorize is a Function -ok 1123 — Returns the appropriate value - -# PASS test/sdbm.test.js - -ok 1124 — sdbm is a Function -ok 1125 — Hashes the input string into a whole number. - -# PASS test/mphToKmph.test.js - -ok 1126 — mphToKmph is a Function -ok 1127 — Returns kph from mph. - -# PASS test/debounce.test.js - -ok 1128 — debounce is a Function -ok 1129 — Works as expected - -# PASS test/sum.test.js - -ok 1130 — sum is a Function -ok 1131 — Returns the sum of two or more numbers/arrays. - -# PASS test/isBrowser.test.js - -ok 1132 — isBrowser is a Function -ok 1133 — isBrowser is a Function - -# PASS test/prefix.test.js - -ok 1134 — prefix is a Function -ok 1135 — prefix is a Function - -# PASS test/timeTaken.test.js - -ok 1136 — timeTaken is a Function -ok 1137 — timeTaken is a Function - -# PASS test/kmphToMph.test.js - -ok 1138 — kmphToMph is a Function -ok 1139 — Returns mph from kph. - -# PASS test/pipeLog.test.js - -ok 1140 — pipeLog is a Function -ok 1141 — pipeLog returns the given value - -# PASS test/btoa.test.js - -ok 1142 — btoa is a Function -ok 1143 — btoa("foobar") equals "Zm9vYmFy" - -# PASS test/isPrime.test.js - -ok 1144 — isPrime is a Function -ok 1145 — passed number is a prime - -# PASS test/once.test.js - -ok 1146 — once is a Function -ok 1147 — once is a Function - -# PASS test/elementIsVisibleInViewport.test.js - -ok 1148 — elementIsVisibleInViewport is a Function - -# PASS test/recordAnimationFrames.test.js - -ok 1149 — recordAnimationFrames is a Function - -# PASS test/UUIDGeneratorBrowser.test.js - -ok 1150 — UUIDGeneratorBrowser is a Function - -# PASS test/getScrollPosition.test.js - -ok 1151 — getScrollPosition is a Function - -# PASS test/onUserInputChange.test.js - -ok 1152 — onUserInputChange is a Function - -# PASS test/detectDeviceType.test.js - -ok 1153 — detectDeviceType is a Function - -# PASS test/observeMutations.test.js - -ok 1154 — observeMutations is a Function - -# PASS test/nodeListToArray.test.js - -ok 1155 — nodeListToArray is a Function - -# PASS test/speechSynthesis.test.js - -ok 1156 — speechSynthesis is a Function - -# PASS test/copyToClipboard.test.js - -ok 1157 — copyToClipboard is a Function - -# PASS test/arrayToHtmlList.test.js - -ok 1158 — arrayToHtmlList is a Function - -# PASS test/elementContains.test.js - -ok 1159 — elementContains is a Function - -# PASS test/createEventHub.test.js - -ok 1160 — createEventHub is a Function - -# PASS test/readFileLines.test.js - -ok 1161 — readFileLines is a Function - -# PASS test/httpsRedirect.test.js - -ok 1162 — httpsRedirect is a Function - -# PASS test/bottomVisible.test.js - -ok 1163 — bottomVisible is a Function - -# PASS test/smoothScroll.test.js - -ok 1164 — smoothScroll is a Function - -# PASS test/triggerEvent.test.js - -ok 1165 — triggerEvent is a Function - -# PASS test/hashBrowser.test.js - -ok 1166 — hashBrowser is a Function - -# PASS test/toggleClass.test.js - -ok 1167 — toggleClass is a Function - -# PASS test/scrollToTop.test.js - -ok 1168 — scrollToTop is a Function - -# PASS test/httpDelete.test.js - -ok 1169 — httpDelete is a Function - -# PASS test/JSONToFile.test.js - -ok 1170 — JSONToFile is a Function - -# PASS test/dayOfYear.test.js - -ok 1171 — dayOfYear is a Function - -# PASS test/squareSum.test.js - -ok 1172 — squareSum is a Function - -# PASS test/hasFlags.test.js - -ok 1173 — hasFlags is a Function - -# PASS test/setStyle.test.js - -ok 1174 — setStyle is a Function - -# PASS test/getStyle.test.js - -ok 1175 — getStyle is a Function - -# PASS test/redirect.test.js - -ok 1176 — redirect is a Function - -# PASS test/httpPost.test.js - -ok 1177 — httpPost is a Function - -# PASS test/runAsync.test.js - -ok 1178 — runAsync is a Function - -# PASS test/hasClass.test.js - -ok 1179 — hasClass is a Function - -# PASS test/throttle.test.js - -ok 1180 — throttle is a Function - -# PASS test/httpPut.test.js - -ok 1181 — httpPut is a Function - -# PASS test/httpGet.test.js - -ok 1182 — httpGet is a Function - -# PASS test/counter.test.js - -ok 1183 — counter is a Function - -# PASS test/toHash.test.js - -ok 1184 — toHash is a Function - -# PASS test/defer.test.js - -ok 1185 — defer is a Function - -# PASS test/show.test.js - -ok 1186 — show is a Function - -# PASS test/hide.test.js - -ok 1187 — hide is a Function - -# PASS test/off.test.js - -ok 1188 — off is a Function - -# PASS test/on.test.js - -ok 1189 — on is a Function - -1..1189 - -# Test Suites: 100% ██████████, 360 passed, 360 total -# Tests: 100% ██████████, 1189 passed, 1189 total -# Time: 25.907s - -# Ran all test suites. - diff --git a/test/throttle.test.js b/test/throttle.test.js index 646e93fa3..f1b4578d3 100644 --- a/test/throttle.test.js +++ b/test/throttle.test.js @@ -4,3 +4,8 @@ const {throttle} = require('./_30s.js'); test('throttle is a Function', () => { expect(throttle).toBeInstanceOf(Function); }); +test('throttle returns a function', () => { + let throttled = throttle(x => x, 100000); + expect(throttled).toBeInstanceOf(Function); + expect(throttled(10)).toBe(undefined); +}); diff --git a/test/toHash.test.js b/test/toHash.test.js index 7913d0591..8e742a86b 100644 --- a/test/toHash.test.js +++ b/test/toHash.test.js @@ -4,3 +4,9 @@ const {toHash} = require('./_30s.js'); test('toHash is a Function', () => { expect(toHash).toBeInstanceOf(Function); }); +test('toHash works properly with indexes', () => { + expect(toHash([4, 3, 2, 1])).toEqual({ 0: 4, 1: 3, 2: 2, 3: 1 }); +}); +test('toHash works properly with keys', () => { + expect(toHash([{ a: 'label' }], 'a')).toEqual({ label: { a: 'label' } }); +}); diff --git a/test/toggleClass.test.js b/test/toggleClass.test.js index 2ec708391..ed55029ec 100644 --- a/test/toggleClass.test.js +++ b/test/toggleClass.test.js @@ -4,3 +4,9 @@ const {toggleClass} = require('./_30s.js'); test('toggleClass is a Function', () => { expect(toggleClass).toBeInstanceOf(Function); }); +test('toggleClass toggles the class', () => { + let el = document.createElement('div'); + el.classList.add('myClass'); + toggleClass(el, 'myClass'); + expect(el.classList.contains('myClass')).toBeFalsy(); +}); diff --git a/test/triggerEvent.test.js b/test/triggerEvent.test.js index 13df31d08..864954008 100644 --- a/test/triggerEvent.test.js +++ b/test/triggerEvent.test.js @@ -4,3 +4,11 @@ const {triggerEvent} = require('./_30s.js'); test('triggerEvent is a Function', () => { expect(triggerEvent).toBeInstanceOf(Function); }); +test('triggerEvent triggers an event', () => { + let el = document.createElement('div'); + let val = false; + const fn = () => val = true; + el.addEventListener('click', fn); + triggerEvent(el, 'click', {}); + expect(val).toBeTruthy(); +}); diff --git a/test/uncurry.test.js b/test/uncurry.test.js index 8e298929a..e3cdcfedb 100644 --- a/test/uncurry.test.js +++ b/test/uncurry.test.js @@ -17,3 +17,8 @@ test('Works with n = 2', () => { test('Works with n = 3', () => { expect(add3(1, 2, 3)).toBe(6); }); +test('Throws RangeError if arguments are too few', () => { + expect(() => { + add2(2); + }).toThrow(RangeError); +}); diff --git a/vscode_snippets/snippets.json b/vscode_snippets/snippets.json index b2eee7bfa..ea5effec4 100644 --- a/vscode_snippets/snippets.json +++ b/vscode_snippets/snippets.json @@ -1123,7 +1123,7 @@ "hide": { "prefix": "30s_hide", "body": [ - "const hide = els => els.forEach(e => (e.style.display = 'none'));" + "const hide = (...el) => [...el].forEach(e => (e.style.display = 'none'));" ], "description": "Hides all the elements specified.\n\nUse `NodeList.prototype.forEach()` to apply `display: none` to each element specified" },