diff --git a/package.json b/package.json index b35078a90..75d6f5d68 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,10 @@ ] }, "dependencies": { + "@auto-it/released": "^9.40.5", "@babel/plugin-proposal-decorators": "^7.13.5", "@babel/plugin-syntax-jsx": "^7.12.13", + "auto": "^9.40.5", "babel-eslint": "^10.0.2", "eslint": "^6.1.0", "eslint-config-airbnb-base": "^14.0.0", @@ -19,8 +21,6 @@ "eslint-plugin-import": "^2.18.2", "eslint-plugin-prettier": "^3.1.0", "lerna": "3.17.0", - "auto": "^9.40.5", - "@auto-it/released": "^9.40.5", "prettier": "^2.2.1", "pretty-quick": "^3.1.0" }, diff --git a/packages/cli/bin/archive.js b/packages/cli/bin/archive.js index 9d7a6989c..e27696977 100644 --- a/packages/cli/bin/archive.js +++ b/packages/cli/bin/archive.js @@ -31,7 +31,7 @@ function exportPatterns(config) { ); }); - archive.on('error', function(err) { + archive.on('error', function (err) { throw new TypeError( `export: An error occured during zipping the patterns: ${err}` ); diff --git a/packages/cli/bin/ask.js b/packages/cli/bin/ask.js index 55a337230..652fbda3b 100644 --- a/packages/cli/bin/ask.js +++ b/packages/cli/bin/ask.js @@ -12,8 +12,8 @@ const ask = inquirer.prompt; * @param {object} options - Options passed in from CLI * @param {boolean} options.force - Flag whether to force install in existing project directory. May overwrite stuff. */ -const init = options => - wrapsAsync(function*() { +const init = (options) => + wrapsAsync(function* () { /** * @property {string} project_root="./" - Path to the project root directory * @property {string|Symbol} edition - The name of the edition npm package or a Symbol for no install diff --git a/packages/cli/bin/cli-actions/build.js b/packages/cli/bin/cli-actions/build.js index c6a34434a..aca73760c 100644 --- a/packages/cli/bin/cli-actions/build.js +++ b/packages/cli/bin/cli-actions/build.js @@ -3,8 +3,8 @@ const buildPatterns = require('../build'); const resolveConfig = require('../resolve-config'); const { error, info, wrapAsync } = require('../utils'); -const build = options => - wrapAsync(function*() { +const build = (options) => + wrapAsync(function* () { try { const config = yield resolveConfig(options.parent.config); yield buildPatterns(config, options); diff --git a/packages/cli/bin/cli-actions/disable.js b/packages/cli/bin/cli-actions/disable.js index 6c53cb5a2..75a534b5a 100644 --- a/packages/cli/bin/cli-actions/disable.js +++ b/packages/cli/bin/cli-actions/disable.js @@ -10,8 +10,8 @@ const writeJsonAsync = require('../utils').writeJsonAsync; * @desc Handles deactivation of starterkits/plugins * @param {object} options */ -const enable = options => - wrapAsync(function*() { +const enable = (options) => + wrapAsync(function* () { const { parent: { config: configPath }, plugins, @@ -24,7 +24,7 @@ const enable = options => spinner.succeed( `⊙ patternlab → Disable following plugins: ${plugins.join(', ')}` ); - plugins.map(plugin => { + plugins.map((plugin) => { if (_.has(config, `plugins[${plugin}]`)) { _.set(config, `plugins[${plugin}]['enabled']`, false); spinner.succeed( diff --git a/packages/cli/bin/cli-actions/enable.js b/packages/cli/bin/cli-actions/enable.js index 0edb57401..4c493cc51 100644 --- a/packages/cli/bin/cli-actions/enable.js +++ b/packages/cli/bin/cli-actions/enable.js @@ -10,8 +10,8 @@ const writeJsonAsync = require('../utils').writeJsonAsync; * @desc Handles activation of starterkits/plugins * @param {object} options */ -const enable = options => - wrapAsync(function*() { +const enable = (options) => + wrapAsync(function* () { const { parent: { config: configPath }, plugins, @@ -24,7 +24,7 @@ const enable = options => spinner.succeed( `⊙ patternlab → Enable following plugins: ${plugins.join(', ')}` ); - plugins.map(plugin => { + plugins.map((plugin) => { if (_.has(config, `plugins[${plugin}]`)) { _.set(config, `plugins[${plugin}]['enabled']`, true); spinner.succeed(`⊙ patternlab → Enabled following plugin: ${plugin}`); diff --git a/packages/cli/bin/cli-actions/export.js b/packages/cli/bin/cli-actions/export.js index 5f4f4ebc7..8f67251e2 100644 --- a/packages/cli/bin/cli-actions/export.js +++ b/packages/cli/bin/cli-actions/export.js @@ -3,8 +3,8 @@ const archive = require('../archive'); const resolveConfig = require('../resolve-config'); const wrapAsync = require('../utils').wrapAsync; -const _export = options => - wrapAsync(function*() { +const _export = (options) => + wrapAsync(function* () { const config = yield resolveConfig(options.parent.config); archive(config); }); diff --git a/packages/cli/bin/cli-actions/init.js b/packages/cli/bin/cli-actions/init.js index f7bbd2f34..5016a68df 100644 --- a/packages/cli/bin/cli-actions/init.js +++ b/packages/cli/bin/cli-actions/init.js @@ -16,8 +16,8 @@ const defaultPatternlabConfig = patternlab.getDefaultConfig(); // https://github.com/TehShrike/deepmerge#overwrite-array const overwriteMerge = (destinationArray, sourceArray, options) => sourceArray; -const init = options => - wrapAsync(function*() { +const init = (options) => + wrapAsync(function* () { const sourceDir = 'source'; const publicDir = 'public'; const exportDir = 'pattern_exports'; diff --git a/packages/cli/bin/cli-actions/install.js b/packages/cli/bin/cli-actions/install.js index 28aa8a445..9c070bb17 100644 --- a/packages/cli/bin/cli-actions/install.js +++ b/packages/cli/bin/cli-actions/install.js @@ -11,8 +11,8 @@ const writeJsonAsync = require('../utils').writeJsonAsync; * @desc Handles async install and activation of starterkits/plugins * @param {object} options */ -const install = options => - wrapAsync(function*() { +const install = (options) => + wrapAsync(function* () { const config = yield resolveConfig(options.parent.config); const spinner = ora( @@ -21,8 +21,8 @@ const install = options => if (options.starterkits && Array.isArray(options.starterkits)) { const starterkits = yield Promise.all( - options.starterkits.map(starterkit => - wrapAsync(function*() { + options.starterkits.map((starterkit) => + wrapAsync(function* () { spinner.text = `⊙ patternlab → Installing starterkit: ${starterkit}`; return yield installStarterkit( { @@ -42,8 +42,8 @@ const install = options => } if (options.plugins && Array.isArray(options.plugins)) { const plugins = yield Promise.all( - options.plugins.map(plugin => - wrapAsync(function*() { + options.plugins.map((plugin) => + wrapAsync(function* () { return yield installPlugin( { name: plugin, diff --git a/packages/cli/bin/cli-actions/serve.js b/packages/cli/bin/cli-actions/serve.js index 6e2cc8fd2..9ef4e42f2 100644 --- a/packages/cli/bin/cli-actions/serve.js +++ b/packages/cli/bin/cli-actions/serve.js @@ -3,8 +3,8 @@ const resolveConfig = require('../resolve-config'); const servePatterns = require('../serve'); const wrapAsync = require('../utils').wrapAsync; -const serve = options => - wrapAsync(function*() { +const serve = (options) => + wrapAsync(function* () { const config = yield resolveConfig(options.parent.config); servePatterns(config, options); }); diff --git a/packages/cli/bin/inquiries/edition.js b/packages/cli/bin/inquiries/edition.js index f62dba232..fca4958f2 100644 --- a/packages/cli/bin/inquiries/edition.js +++ b/packages/cli/bin/inquiries/edition.js @@ -28,7 +28,7 @@ const editionSetup = [ value: false, }, ], - default: function() { + default: function () { return { name: 'Handlebars', value: '@pattern-lab/edition-node', diff --git a/packages/cli/bin/install-edition.js b/packages/cli/bin/install-edition.js index 3d6047fb6..41392c8c9 100644 --- a/packages/cli/bin/install-edition.js +++ b/packages/cli/bin/install-edition.js @@ -22,7 +22,7 @@ const overwriteMerge = (destinationArray, sourceArray, options) => sourceArray; const installEdition = (edition, config, projectDir) => { const pkg = require(path.resolve(projectDir, 'package.json')); - return wrapAsync(function*() { + return wrapAsync(function* () { /** * 1. Trigger edition install * 2. Copy over the mandatory edition files to sourceDir diff --git a/packages/cli/bin/install-plugin.js b/packages/cli/bin/install-plugin.js index ee1d18d5d..f152076b0 100644 --- a/packages/cli/bin/install-plugin.js +++ b/packages/cli/bin/install-plugin.js @@ -6,7 +6,7 @@ const { checkAndInstallPackage, wrapAsync } = require('./utils'); const { resolveFileInPackage } = require('@pattern-lab/core/src/lib/resolver'); const installPlugin = (plugin, config) => - wrapAsync(function*() { + wrapAsync(function* () { const name = plugin.name || plugin; yield checkAndInstallPackage(name); // Put the installed plugin in the patternlab-config.json diff --git a/packages/cli/bin/install-starterkit.js b/packages/cli/bin/install-starterkit.js index 5de245b1e..016548737 100644 --- a/packages/cli/bin/install-starterkit.js +++ b/packages/cli/bin/install-starterkit.js @@ -13,7 +13,7 @@ const { } = require('@pattern-lab/core/src/lib/resolver'); const installStarterkit = (starterkit, config) => - wrapAsync(function*() { + wrapAsync(function* () { const sourceDir = config.paths.source.root; const name = starterkit.value || starterkit; yield checkAndInstallPackage(name); diff --git a/packages/cli/bin/patternlab.js b/packages/cli/bin/patternlab.js index 80c12acfb..e2ed6cd1e 100755 --- a/packages/cli/bin/patternlab.js +++ b/packages/cli/bin/patternlab.js @@ -16,11 +16,11 @@ const { error, log } = require('./utils'); const pkg = require('../package.json'); // Register info and error logging -log.on('patternlab.error', err => console.log(err)); // eslint-disable-line -log.on('patternlab.info', msg => console.log(msg)); // eslint-disable-line +log.on('patternlab.error', (err) => console.log(err)); // eslint-disable-line +log.on('patternlab.info', (msg) => console.log(msg)); // eslint-disable-line // Conditionally register verbose logging -const verboseLogs = () => log.on('patternlab.debug', msg => console.log(msg)); // eslint-disable-line +const verboseLogs = () => log.on('patternlab.debug', (msg) => console.log(msg)); // eslint-disable-line // Conditionally unregister all logging const silenceLogs = () => { @@ -30,7 +30,7 @@ const silenceLogs = () => { }; // Split strings into an array -const list = val => val.split(','); +const list = (val) => val.split(','); /** * Hook up cli version, usage and options @@ -42,7 +42,7 @@ cli .option( '-c, --config ', 'Specify config file. Default looks up the project dir', - val => val.trim(), + (val) => val.trim(), path.resolve(process.cwd(), 'patternlab-config.json') ) .option('-v, --verbose', 'Show verbose console logs', verboseLogs) diff --git a/packages/cli/bin/resolve-config.js b/packages/cli/bin/resolve-config.js index f34c5e083..968719b0d 100644 --- a/packages/cli/bin/resolve-config.js +++ b/packages/cli/bin/resolve-config.js @@ -12,7 +12,7 @@ const wrapAsync = require('./utils').wrapAsync; * @return {object|boolean} Returns the config object or false otherwise. */ function resolveConfig(configPath) { - return wrapAsync(function*() { + return wrapAsync(function* () { if (typeof configPath !== 'string') { error( 'resolveConfig: If configPath is set, it is expected to be of type string.' diff --git a/packages/cli/bin/scaffold.js b/packages/cli/bin/scaffold.js index de1e4df73..ac2b4378b 100644 --- a/packages/cli/bin/scaffold.js +++ b/packages/cli/bin/scaffold.js @@ -15,7 +15,7 @@ const mkdirsAsync = require('./utils').mkdirsAsync; * @return {void} */ const scaffold = (projectDir, sourceDir, publicDir, exportDir) => - wrapAsync(function*() { + wrapAsync(function* () { const projectPath = path.join(process.cwd(), projectDir); if (!fs.existsSync(path.join(projectPath, 'package.json'))) { fs.ensureDirSync(projectPath); diff --git a/packages/cli/bin/utils.js b/packages/cli/bin/utils.js index a9cdcaf63..dbf6e3aa8 100644 --- a/packages/cli/bin/utils.js +++ b/packages/cli/bin/utils.js @@ -66,7 +66,7 @@ const error = log.error.bind(log); * @desc Wraps an generator function to yield out promisified stuff * @param {function} fn - Takes a generator function */ -const wrapAsync = fn => +const wrapAsync = (fn) => new Promise((resolve, reject) => { const generator = fn(); /* eslint-disable */ @@ -84,9 +84,7 @@ const wrapAsync = fn => if (res.done) { return resolve(v); } - Promise.resolve(v) - .then(spwn) - .catch(spwn); + Promise.resolve(v).then(spwn).catch(spwn); })(); /* eslint-enable */ }); @@ -114,13 +112,13 @@ const asyncGlob = (pattern, opts) => * @return {Promise} */ const copyWithPattern = (cwd, pattern, dest) => - wrapAsync(function*() { + wrapAsync(function* () { const files = yield asyncGlob(pattern, { cwd: cwd }); if (files.length === 0) { debug('copy: Nothing to copy'); } // Copy concurrently - const promises = files.map(file => + const promises = files.map((file) => fs.copy(path.join(cwd, file), path.join(dest, file)) ); return yield Promise.all(promises); @@ -131,8 +129,8 @@ const copyWithPattern = (cwd, pattern, dest) => * @desc Fetches packages from an npm package registry and adds a reference in the package.json under dependencies * @param {string} packageName - The package name */ -const fetchPackage = packageName => - wrapAsync(function*() { +const fetchPackage = (packageName) => + wrapAsync(function* () { const useYarn = hasYarn(); const pm = useYarn ? 'yarn' : 'npm'; const installCmd = useYarn ? 'add' : 'install'; @@ -159,8 +157,8 @@ const fetchPackage = packageName => * @param {string} packageName - The package name * @return {boolean} */ -const checkAndInstallPackage = packageName => - wrapAsync(function*() { +const checkAndInstallPackage = (packageName) => + wrapAsync(function* () { try { resolvePackageFolder(packageName); return true; @@ -186,7 +184,7 @@ const noop = () => {}; * @param {object} data */ const writeJsonAsync = (filePath, data) => - wrapAsync(function*() { + wrapAsync(function* () { yield fs.outputJSON(filePath, data, { spaces: 2 }); }); @@ -198,7 +196,7 @@ const writeJsonAsync = (filePath, data) => * @param {object} fileName - the filePath of the JSON */ const getJSONKey = (packageName, key, fileName = 'package.json') => - wrapAsync(function*() { + wrapAsync(function* () { yield checkAndInstallPackage(packageName); const jsonData = yield fs.readJson( resolveFileInPackage(packageName, fileName) diff --git a/packages/cli/test/build.test.js b/packages/cli/test/build.test.js index 6a56cb6fe..8ee4770f4 100644 --- a/packages/cli/test/build.test.js +++ b/packages/cli/test/build.test.js @@ -10,7 +10,7 @@ const build = proxyquire('../bin/build', { }); const opts = { patternsOnly: true }; -tap.test('Build ->', t => { +tap.test('Build ->', (t) => { t.throws( () => { build(); diff --git a/packages/cli/test/cli-build.test.js b/packages/cli/test/cli-build.test.js index d6712deae..893aa98ea 100644 --- a/packages/cli/test/cli-build.test.js +++ b/packages/cli/test/cli-build.test.js @@ -7,8 +7,8 @@ const wrapAsync = require('../bin/utils').wrapAsync; const projectRoot = getUniqueProjectPath(); -tap.test('Init and build ->', t => - wrapAsync(function*() { +tap.test('Init and build ->', (t) => + wrapAsync(function* () { yield spawnCmd([ 'init', '--verbose', diff --git a/packages/cli/test/cli-disable.test.js b/packages/cli/test/cli-disable.test.js index 64715b882..c21a1adf1 100644 --- a/packages/cli/test/cli-disable.test.js +++ b/packages/cli/test/cli-disable.test.js @@ -6,8 +6,8 @@ const wrapAsync = require('../bin/utils').wrapAsync; const projectRoot = getUniqueProjectPath(); -tap.test('Disable ->', t => - wrapAsync(function*() { +tap.test('Disable ->', (t) => + wrapAsync(function* () { yield spawnCmd([ 'init', '--verbose', diff --git a/packages/cli/test/cli-enable.test.js b/packages/cli/test/cli-enable.test.js index 62b7d837a..160c5ed49 100644 --- a/packages/cli/test/cli-enable.test.js +++ b/packages/cli/test/cli-enable.test.js @@ -6,8 +6,8 @@ const wrapAsync = require('../bin/utils').wrapAsync; const projectRoot = getUniqueProjectPath(); -tap.test('Enable ->', t => - wrapAsync(function*() { +tap.test('Enable ->', (t) => + wrapAsync(function* () { yield spawnCmd([ 'init', '--verbose', diff --git a/packages/cli/test/cli-export.test.js b/packages/cli/test/cli-export.test.js index 63e82ba06..b476eeec2 100644 --- a/packages/cli/test/cli-export.test.js +++ b/packages/cli/test/cli-export.test.js @@ -7,8 +7,8 @@ const wrapAsync = require('../bin/utils').wrapAsync; const projectRoot = getUniqueProjectPath(); -tap.test('Init and export ->', t => - wrapAsync(function*() { +tap.test('Init and export ->', (t) => + wrapAsync(function* () { yield spawnCmd([ 'init', '--verbose', diff --git a/packages/cli/test/cli-init.test.js b/packages/cli/test/cli-init.test.js index a80c031ff..06174ffb6 100644 --- a/packages/cli/test/cli-init.test.js +++ b/packages/cli/test/cli-init.test.js @@ -7,8 +7,8 @@ const wrapAsync = require('../bin/utils').wrapAsync; const projectRoot = getUniqueProjectPath(); -tap.test('Init ->', t => - wrapAsync(function*() { +tap.test('Init ->', (t) => + wrapAsync(function* () { yield spawnCmd([ 'init', '--verbose', diff --git a/packages/cli/test/export.test.js b/packages/cli/test/export.test.js index 169b60771..e9b600b24 100644 --- a/packages/cli/test/export.test.js +++ b/packages/cli/test/export.test.js @@ -2,10 +2,10 @@ const exportPatterns = require('../bin/cli-actions/export'); const tap = require('tap'); const wrapAsync = require('../bin/utils').wrapAsync; -tap.test('Export ->', t => { +tap.test('Export ->', (t) => { t.plan(2); - t.test('with options empty', tt => - wrapAsync(function*() { + t.test('with options empty', (tt) => + wrapAsync(function* () { try { yield exportPatterns(); } catch (err) { @@ -14,8 +14,8 @@ tap.test('Export ->', t => { } }) ); - t.test('with options not an object', tt => - wrapAsync(function*() { + t.test('with options not an object', (tt) => + wrapAsync(function* () { try { yield exportPatterns(123); } catch (err) { diff --git a/packages/cli/test/install-plugin.test.js b/packages/cli/test/install-plugin.test.js index 269953007..c941d95d1 100644 --- a/packages/cli/test/install-plugin.test.js +++ b/packages/cli/test/install-plugin.test.js @@ -14,8 +14,8 @@ const minimalConfig = { }, }; -tap.test('Install plugin-tab ->', t => - wrapAsync(function*() { +tap.test('Install plugin-tab ->', (t) => + wrapAsync(function* () { yield installPlugin('@pattern-lab/plugin-tab', minimalConfig); const pkg = yield moduleExist('@pattern-lab/plugin-tab'); t.ok(pkg, 'module should exist after install'); diff --git a/packages/cli/test/install-starterkit.test.js b/packages/cli/test/install-starterkit.test.js index 0cda685c9..fc651eca9 100644 --- a/packages/cli/test/install-starterkit.test.js +++ b/packages/cli/test/install-starterkit.test.js @@ -14,8 +14,8 @@ const minimalConfig = { }, }; -tap.test('Install starterkit-mustache-demo ->', t => - wrapAsync(function*() { +tap.test('Install starterkit-mustache-demo ->', (t) => + wrapAsync(function* () { yield installStarterkit( '@pattern-lab/starterkit-mustache-demo', minimalConfig @@ -26,8 +26,8 @@ tap.test('Install starterkit-mustache-demo ->', t => }) ); -tap.test('Install starterkit-mustache-base ->', t => - wrapAsync(function*() { +tap.test('Install starterkit-mustache-base ->', (t) => + wrapAsync(function* () { yield installStarterkit( '@pattern-lab/starterkit-mustache-base', minimalConfig @@ -38,8 +38,8 @@ tap.test('Install starterkit-mustache-base ->', t => }) ); -tap.test('Install starterkit-mustache-bootstrap ->', t => - wrapAsync(function*() { +tap.test('Install starterkit-mustache-bootstrap ->', (t) => + wrapAsync(function* () { yield installStarterkit('starterkit-mustache-bootstrap', minimalConfig); const pkg = yield moduleExist('starterkit-mustache-bootstrap'); t.ok(pkg, 'module should exist after install'); @@ -47,8 +47,8 @@ tap.test('Install starterkit-mustache-bootstrap ->', t => }) ); -tap.test('Install starterkit-mustache-foundation ->', t => - wrapAsync(function*() { +tap.test('Install starterkit-mustache-foundation ->', (t) => + wrapAsync(function* () { yield installStarterkit('starterkit-mustache-foundation', minimalConfig); const pkg = yield moduleExist('starterkit-mustache-foundation'); t.ok(pkg, 'module should exist after install'); @@ -56,8 +56,8 @@ tap.test('Install starterkit-mustache-foundation ->', t => }) ); -tap.test('Install starterkit-mustache-acidtest ->', t => - wrapAsync(function*() { +tap.test('Install starterkit-mustache-acidtest ->', (t) => + wrapAsync(function* () { yield installStarterkit('starterkit-mustache-acidtest', minimalConfig); const pkg = yield moduleExist('starterkit-mustache-acidtest'); t.ok(pkg, 'module should exist after install'); @@ -65,8 +65,8 @@ tap.test('Install starterkit-mustache-acidtest ->', t => }) ); -tap.test('Install starterkit-mustache-materialdesign ->', t => - wrapAsync(function*() { +tap.test('Install starterkit-mustache-materialdesign ->', (t) => + wrapAsync(function* () { yield installStarterkit( 'starterkit-mustache-materialdesign', minimalConfig diff --git a/packages/cli/test/mocks/liverserver.mock.js b/packages/cli/test/mocks/liverserver.mock.js index 754fd5fc1..868f34fd5 100644 --- a/packages/cli/test/mocks/liverserver.mock.js +++ b/packages/cli/test/mocks/liverserver.mock.js @@ -1,12 +1,12 @@ function liveServerMock() { return { - reload: function() { + reload: function () { return true; }, - refreshCSS: function() { + refreshCSS: function () { return true; }, - start: function() { + start: function () { return true; }, }; diff --git a/packages/cli/test/mocks/patternlab.mock.js b/packages/cli/test/mocks/patternlab.mock.js index 7186ca734..718767245 100644 --- a/packages/cli/test/mocks/patternlab.mock.js +++ b/packages/cli/test/mocks/patternlab.mock.js @@ -1,18 +1,18 @@ function patternLabMock() { return { - build: function() { + build: function () { return true; }, - help: function() { + help: function () { return true; }, - patternsonly: function() { + patternsonly: function () { return true; }, - liststarterkits: function() { + liststarterkits: function () { return true; }, - loadstarterkit: function() { + loadstarterkit: function () { return true; }, }; diff --git a/packages/cli/test/replace_config_paths.test.js b/packages/cli/test/replace_config_paths.test.js index 6a98385ac..11d5bd84d 100644 --- a/packages/cli/test/replace_config_paths.test.js +++ b/packages/cli/test/replace_config_paths.test.js @@ -3,7 +3,7 @@ const tap = require('tap'); const replaceConfigPaths = require('../bin/replace-config'); const config = patternlab.getDefaultConfig(); -tap.test('replaceConfigPaths ->', t => { +tap.test('replaceConfigPaths ->', (t) => { const newConfig = replaceConfigPaths( config, 'projectDir', diff --git a/packages/cli/test/resolve_config.test.js b/packages/cli/test/resolve_config.test.js index 36c250d9a..87feb8231 100644 --- a/packages/cli/test/resolve_config.test.js +++ b/packages/cli/test/resolve_config.test.js @@ -2,8 +2,8 @@ const tap = require('tap'); const wrapAsync = require('../bin/utils').wrapAsync; const resolveConfig = require('../bin/resolve-config'); -tap.test('resolveConfig ->', t => - wrapAsync(function*() { +tap.test('resolveConfig ->', (t) => + wrapAsync(function* () { const config = yield resolveConfig( './test/fixtures/patternlab-config.json' ); diff --git a/packages/cli/test/scaffold.test.js b/packages/cli/test/scaffold.test.js index c63d2365d..0db92165b 100644 --- a/packages/cli/test/scaffold.test.js +++ b/packages/cli/test/scaffold.test.js @@ -10,8 +10,8 @@ const sourceDir = 'source'; const publicDir = 'public'; const exportDir = 'patterns_export'; -tap.test('Scaffold ->', t => - wrapAsync(function*() { +tap.test('Scaffold ->', (t) => + wrapAsync(function* () { yield scaffold(projectDir, sourceDir, publicDir, exportDir); t.ok(exists.sync(path.resolve(projectDir)), 'should create project dir'); t.ok( diff --git a/packages/cli/test/serve.test.js b/packages/cli/test/serve.test.js index c322cc41d..0d733cde0 100644 --- a/packages/cli/test/serve.test.js +++ b/packages/cli/test/serve.test.js @@ -10,8 +10,8 @@ const preview = proxyquire('../bin/serve', { '@pattern-lab/core': patternLabMock, }); -tap.test('Serve ->', t => - wrapAsync(function*() { +tap.test('Serve ->', (t) => + wrapAsync(function* () { const config = yield resolveConfig( './test/fixtures/patternlab-config.json' ); diff --git a/packages/cli/test/utils/spawnCmd.js b/packages/cli/test/utils/spawnCmd.js index 4d0623515..f02cb91d4 100644 --- a/packages/cli/test/utils/spawnCmd.js +++ b/packages/cli/test/utils/spawnCmd.js @@ -4,8 +4,8 @@ const wrapAsync = require('../../bin/utils').wrapAsync; const cli = path.resolve(__dirname, '../../bin/patternlab.js'); const spawnCmd = (args, endFn) => - wrapAsync(function*() { - const fn = endFn || function() {}; + wrapAsync(function* () { + const fn = endFn || function () {}; yield spawn('node', [cli].concat(args)); fn(); }); diff --git a/packages/core/scripts/docs.js b/packages/core/scripts/docs.js index 8b0907aca..92d16092c 100644 --- a/packages/core/scripts/docs.js +++ b/packages/core/scripts/docs.js @@ -18,7 +18,7 @@ doc 'name-format': 'backticks', template: fs.readFileSync('./scripts/api.handlebars', 'utf8'), }) - .then(x => { + .then((x) => { fs.outputFile(path.resolve(process.cwd(), './docs/README.md'), x); }); @@ -29,6 +29,6 @@ doc 'name-format': 'backticks', template: fs.readFileSync('./scripts/events.handlebars', 'utf8'), }) - .then(x => { + .then((x) => { fs.outputFile(path.resolve(process.cwd(), './docs/events.md'), x); }); diff --git a/packages/core/src/index.js b/packages/core/src/index.js index 1d26387ea..371c6c149 100644 --- a/packages/core/src/index.js +++ b/packages/core/src/index.js @@ -41,7 +41,7 @@ updateNotifier({ * @static * @return {object} Returns the object representation of the `patternlab-config.json` */ -const getDefaultConfig = function() { +const getDefaultConfig = function () { return defaultConfig; }; @@ -53,11 +53,11 @@ const getDefaultConfig = function() { * @static * @returns {string} current @pattern-lab/core version as defined in `package.json` */ -const getVersion = function() { +const getVersion = function () { return packageInfo.version; }; -const patternlab_module = function(config) { +const patternlab_module = function (config) { const PatternLabClass = require('./lib/patternlab'); const patternlab = new PatternLabClass(config); const server = serverModule(patternlab); @@ -71,7 +71,7 @@ const patternlab_module = function(config) { * @instance * @returns {string} current patternlab-node version as defined in `package.json`, as string */ - version: function() { + version: function () { return patternlab.getVersion(); }, @@ -95,7 +95,7 @@ const patternlab_module = function(config) { * @instance * @returns {boolean} if pattern lab is currently busy compiling */ - isBusy: function() { + isBusy: function () { return patternlab.isBusy; }, @@ -114,7 +114,7 @@ const patternlab_module = function(config) { * @see {@link ./events.md|all events} * @returns {Promise} a promise fulfilled when build is complete */ - build: async function(options) { + build: async function (options) { // process.on('unhandledRejection', (reason, p) => { // console.log('Unhandled Rejection at: Promise', p, 'reason:', reason); // // application specific logging, throwing an error, or other logic here @@ -186,7 +186,7 @@ const patternlab_module = function(config) { * @instance * @return {object} Returns the object representation of the `patternlab-config.json` */ - getDefaultConfig: function() { + getDefaultConfig: function () { return getDefaultConfig(); }, @@ -198,7 +198,7 @@ const patternlab_module = function(config) { * @instance * @returns {Array} all supported file extensions */ - getSupportedTemplateExtensions: function() { + getSupportedTemplateExtensions: function () { return patternlab.getSupportedTemplateExtensions(); }, @@ -210,7 +210,7 @@ const patternlab_module = function(config) { * @instance * @returns {Promise} Returns an Array<{name,url}> for the starterkit repos */ - liststarterkits: function() { + liststarterkits: function () { return patternlab.listStarterkits(); }, @@ -224,7 +224,7 @@ const patternlab_module = function(config) { * @param {boolean} clean whether or not to delete contents of source/ before load * @returns {void} */ - loadstarterkit: function(starterkitName, clean) { + loadstarterkit: function (starterkitName, clean) { patternlab.loadStarterKit(starterkitName, clean); }, @@ -239,7 +239,7 @@ const patternlab_module = function(config) { * @param {bool} [options.watch=true] whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild * @returns {Promise} a promise fulfilled when build is complete */ - patternsonly: async function(options) { + patternsonly: async function (options) { if (patternlab && patternlab.isBusy) { logger.info( 'Pattern Lab is busy building a previous run - returning early.' @@ -274,11 +274,11 @@ const patternlab_module = function(config) { * @param {bool} [options.watch=true] whether or not Pattern Lab should watch configured `source/` directories for changes to rebuild * @returns {Promise} a promise fulfilled when build is complete */ - serve: options => { + serve: (options) => { return _api .build(options) .then(() => server.serve()) - .catch(e => + .catch((e) => logger.error(`error inside core index.js server serve: ${e}`) ); }, diff --git a/packages/core/src/lib/object_factory.js b/packages/core/src/lib/object_factory.js index 0b0337dfc..bce935228 100644 --- a/packages/core/src/lib/object_factory.js +++ b/packages/core/src/lib/object_factory.js @@ -55,7 +55,7 @@ const Pattern = function ( this.fileExtension = pathObj.ext; // '.mustache' // TODO: Remove if block when dropping ordering by prefix and keep else code - // (When we dorp the info about the old ordering is deprecated) + // (When we drop the info about the old ordering is deprecated) if ( (prefixMatcherDeprecationCheckOrder.test(this.getDirLevel(0, info)) || prefixMatcherDeprecationCheckOrder.test(this.getDirLevel(1, info)) || diff --git a/packages/core/test/addPattern_tests.js b/packages/core/test/addPattern_tests.js index 23edb6c0b..cf495cccb 100644 --- a/packages/core/test/addPattern_tests.js +++ b/packages/core/test/addPattern_tests.js @@ -10,7 +10,7 @@ const patterns_dir = './test/files/_patterns'; tap.test( 'addPattern - adds pattern extended template to patternlab partial object', - function(test) { + function (test) { //arrange const patternlab = util.fakePatternLab(patterns_dir); @@ -22,16 +22,16 @@ tap.test( addPattern(pattern, patternlab); //assert - test.equals(patternlab.patterns.length, 1); - test.equals(patternlab.partials['test-bar'] !== undefined, true); - test.equals(patternlab.partials['test-bar'], 'barExtended'); + test.equal(patternlab.patterns.length, 1); + test.equal(patternlab.partials['test-bar'] !== undefined, true); + test.equal(patternlab.partials['test-bar'], 'barExtended'); test.end(); } ); tap.test( 'addPattern - adds pattern template to patternlab partial object if extendedtemplate does not exist yet', - function(test) { + function (test) { //arrange const patternlab = util.fakePatternLab(patterns_dir); @@ -43,9 +43,9 @@ tap.test( addPattern(pattern, patternlab); //assert - test.equals(patternlab.patterns.length, 1); - test.equals(patternlab.partials['test-bar'] !== undefined, true); - test.equals(patternlab.partials['test-bar'], 'bar'); + test.equal(patternlab.patterns.length, 1); + test.equal(patternlab.partials['test-bar'] !== undefined, true); + test.equal(patternlab.partials['test-bar'], 'bar'); test.end(); } ); diff --git a/packages/core/test/annotation_exporter_tests.js b/packages/core/test/annotation_exporter_tests.js index 68c7b2f48..01b71e6d8 100644 --- a/packages/core/test/annotation_exporter_tests.js +++ b/packages/core/test/annotation_exporter_tests.js @@ -22,16 +22,16 @@ function createFakePatternLab(anPath, customProps) { var patternlab = createFakePatternLab(anPath); var ae = require('../src/lib/annotation_exporter')(patternlab); -tap.test('converts old JS annotations into new format', function(test) { +tap.test('converts old JS annotations into new format', function (test) { //arrange //act var annotations = ae.gatherJS(); //assert - test.equals(annotations.length, 2); - test.equals(annotations[1].el, '.logo'); - test.equals(annotations[1].title, 'Logo'); - test.equals( + test.equal(annotations.length, 2); + test.equal(annotations[1].el, '.logo'); + test.equal(annotations[1].title, 'Logo'); + test.equal( annotations[1].comment, 'The logo image is an SVG file, which ensures that the logo displays crisply even on high resolution displays. A PNG fallback is provided for browsers that don\'t support SVG images.

Further reading: Optimizing Web Experiences for High Resolution Screens

' ); @@ -39,16 +39,16 @@ tap.test('converts old JS annotations into new format', function(test) { test.end(); }); -tap.test('converts new markdown annotations into an array', function(test) { +tap.test('converts new markdown annotations into an array', function (test) { //arrange //act var annotations = ae.gatherMD(); //assert - test.equals(annotations.length, 3); - test.equals(annotations[1].el, '.logo'); - test.equals(annotations[1].title, 'Logo'); - test.equals( + test.equal(annotations.length, 3); + test.equal(annotations[1].el, '.logo'); + test.equal(annotations[1].title, 'Logo'); + test.equal( annotations[1].comment.replace(/\r?\n|\r/gm, ''), '

The logo image is an SVG file.

' ); @@ -56,17 +56,17 @@ tap.test('converts new markdown annotations into an array', function(test) { test.end(); }); -tap.test('merges both annotation methods into one array', function(test) { +tap.test('merges both annotation methods into one array', function (test) { //arrange //act var annotations = ae.gather(); //assert - test.equals(annotations.length, 3); - test.equals(annotations[2].el, '#nav'); - test.equals(annotations[2].title, 'Navigation'); - test.equals( + test.equal(annotations.length, 3); + test.equal(annotations[2].el, '#nav'); + test.equal(annotations[2].title, 'Navigation'); + test.equal( annotations[2].comment.replace(/\r?\n|\r/gm, ''), '

Navigation for adaptive web experiences can be tricky. Refer to these repsonsive patterns when evaluating solutions.

' ); @@ -74,12 +74,12 @@ tap.test('merges both annotation methods into one array', function(test) { test.end(); }); -tap.test('when there are 0 annotation files', function(test) { +tap.test('when there are 0 annotation files', function (test) { var emptyAnPath = './test/files/empty/'; var patternlab2 = createFakePatternLab(emptyAnPath); var ae2 = require('../src/lib/annotation_exporter')(patternlab2); var annotations = ae2.gather(); - test.equals(annotations.length, 0); + test.equal(annotations.length, 0); test.end(); }); diff --git a/packages/core/test/buildListItems_tests.js b/packages/core/test/buildListItems_tests.js index 757c8f1aa..10e5ee22f 100644 --- a/packages/core/test/buildListItems_tests.js +++ b/packages/core/test/buildListItems_tests.js @@ -7,7 +7,7 @@ const listItems = require('./files/_data/listitems.json'); const buildlistItems = rewire('../src/lib/buildListItems'); const _Mock = { - shuffle: function(list) { + shuffle: function (list) { return list; }, }; @@ -19,7 +19,7 @@ buildlistItems.__set__({ tap.test( 'buildlistItems transforms container of listItems with one value', - test => { + (test) => { // do this to avoid the shuffling for now const container = Object.assign({}, { listitems: { '1': listItems['1'] } }); buildlistItems(container); @@ -38,7 +38,7 @@ tap.test( tap.test( 'buildlistItems transforms container of listItems with three values', - test => { + (test) => { // do this to avoid the shuffling for now const container = { listitems: listItems }; buildlistItems(container); diff --git a/packages/core/test/changes_hunter_tests.js b/packages/core/test/changes_hunter_tests.js index 68b6c054d..a9050af0a 100644 --- a/packages/core/test/changes_hunter_tests.js +++ b/packages/core/test/changes_hunter_tests.js @@ -6,7 +6,7 @@ const rewire = require('rewire'); const ch = rewire('../src/lib/changes_hunter'); const fsMock = { - statSync: function() { + statSync: function () { return { mtime: { getTime: () => { @@ -27,41 +27,41 @@ ch.__set__({ const changes_hunter = new ch(); -tap.test('checkLastModified - sets lastModified to fileTime ', function(test) { +tap.test('checkLastModified - sets lastModified to fileTime ', function (test) { //arrange const mockPattern = { lastModified: 0 }; //act changes_hunter.checkLastModified(mockPattern, {}); //assert - test.equals(mockPattern.lastModified, 100); + test.equal(mockPattern.lastModified, 100); test.end(); }); tap.test( 'checkLastModified - does not alter pattern if file not found', - function(test) { + function (test) { //arrange const mockPattern = { lastModified: 1010 }; //act changes_hunter.checkLastModified(mockPattern, null); //assert - test.equals(mockPattern.lastModified, 1010); + test.equal(mockPattern.lastModified, 1010); test.end(); } ); tap.test( 'checkLastModified - uses pattern.lastModified if greater than file time', - function(test) { + function (test) { //arrange const mockPattern = { lastModified: 101 }; //act changes_hunter.checkLastModified(mockPattern, {}); //assert - test.equals(mockPattern.lastModified, 101); + test.equal(mockPattern.lastModified, 101); test.end(); } ); diff --git a/packages/core/test/copier_tests.js b/packages/core/test/copier_tests.js index 388300a01..b7e57af3d 100644 --- a/packages/core/test/copier_tests.js +++ b/packages/core/test/copier_tests.js @@ -52,7 +52,7 @@ function createFakePatternLab(customProps) { tap.test( 'transformConfigPaths takes configuration.paths() and maps to a better key store', - function(test) { + function (test) { //arrange var patternlab = createFakePatternLab({}); @@ -60,10 +60,10 @@ tap.test( var result = copier.transformConfigPaths(patternlab.config.paths); //assert - test.equals(result.img.source, './test/img'); - test.equals(result.img.public, './test/output/img'); - test.equals(result.css.source, './test/css'); - test.equals(result.css.public, './test/output/css'); + test.equal(result.img.source, './test/img'); + test.equal(result.img.public, './test/output/img'); + test.equal(result.css.source, './test/css'); + test.equal(result.css.public, './test/output/css'); test.end(); } ); diff --git a/packages/core/test/data_loader_tests.js b/packages/core/test/data_loader_tests.js index 9eaa8864b..2eae23311 100644 --- a/packages/core/test/data_loader_tests.js +++ b/packages/core/test/data_loader_tests.js @@ -2,12 +2,12 @@ const tap = require('tap'); -tap.test('loadDataFromFile - Load ', function(test) { +tap.test('loadDataFromFile - Load ', function (test) { const fs = require('fs-extra'), dataLoader = require('../src/lib/data_loader')(), data_dir = `${__dirname}/files/_data/`; let data = dataLoader.loadDataFromFile(data_dir + 'foo', fs); - test.equals(data.foo, 'bar'); + test.equal(data.foo, 'bar'); test.end(); }); diff --git a/packages/core/test/engine_handlebars_tests.js b/packages/core/test/engine_handlebars_tests.js index 5376e2bbd..f842c4357 100644 --- a/packages/core/test/engine_handlebars_tests.js +++ b/packages/core/test/engine_handlebars_tests.js @@ -24,7 +24,7 @@ engineLoader.loadAllEngines(config); // don't run these tests unless handlebars is installed if (!engineLoader.handlebars) { - tap.test('Handlebars engine not installed, skipping tests.', function(test) { + tap.test('Handlebars engine not installed, skipping tests.', function (test) { test.end(); }); return; @@ -74,15 +74,15 @@ function testFindPartials(test, partialTests) { var results = currentPattern.findPartials(); // assert - test.equals(results.length, partialTests.length); - partialTests.forEach(function(testString, index) { - test.equals(results[index], testString); + test.equal(results.length, partialTests.length); + partialTests.forEach(function (testString, index) { + test.equal(results[index], testString); }); test.end(); } -tap.test('hello world handlebars pattern renders', function(test) { +tap.test('hello world handlebars pattern renders', function (test) { test.plan(1); var patternPath = path.join('atoms', 'global', 'helloworld.hbs'); @@ -91,10 +91,10 @@ tap.test('hello world handlebars pattern renders', function(test) { var patternlab = new fakePatternLab(); var helloWorldPattern = loadPattern(patternPath, patternlab); - processIterative(helloWorldPattern, patternlab).then(helloWorldPattern => { + processIterative(helloWorldPattern, patternlab).then((helloWorldPattern) => { processRecursive(patternPath, patternlab).then(() => { - helloWorldPattern.render().then(results => { - test.equals(results, 'Hello world!' + eol); + helloWorldPattern.render().then((results) => { + test.equal(results, 'Hello world!' + eol); test.end(); }); }); @@ -103,7 +103,7 @@ tap.test('hello world handlebars pattern renders', function(test) { tap.test( 'hello worlds handlebars pattern can see the atoms-helloworld partial and renders it twice', - function(test) { + function (test) { test.plan(1); // pattern paths @@ -124,8 +124,8 @@ tap.test( processRecursive(pattern1Path, patternlab).then(() => { processRecursive(pattern2Path, patternlab).then(() => { // test - pattern2.render().then(results => { - test.equals( + pattern2.render().then((results) => { + test.equal( results, 'Hello world!' + eol + ' and Hello world!' + eol + eol ); @@ -137,7 +137,7 @@ tap.test( } ); -tap.test('handlebars partials can render JSON values', function(test) { +tap.test('handlebars partials can render JSON values', function (test) { test.plan(1); // pattern paths @@ -152,8 +152,8 @@ tap.test('handlebars partials can render JSON values', function(test) { processIterative(helloWorldWithData, patternlab).then(() => { processRecursive(pattern1Path, patternlab).then(() => { // test - helloWorldWithData.render().then(results => { - test.equals( + helloWorldWithData.render().then((results) => { + test.equal( results, 'Hello world!' + eol + @@ -168,7 +168,7 @@ tap.test('handlebars partials can render JSON values', function(test) { tap.test( 'handlebars partials use the JSON environment from the calling pattern and can accept passed parameters', - function(test) { + function (test) { test.plan(1); // pattern paths @@ -192,9 +192,9 @@ tap.test( processRecursive(atomPath, patternlab), processRecursive(molPath, patternlab), ]).then(() => { - mol.render().then(results => { + mol.render().then((results) => { // test - test.equals( + test.equal( results, '

Call with default JSON environment:

' + eol + @@ -217,7 +217,7 @@ tap.test( } ); -tap.only('find_pattern_partials finds partials', function(test) { +tap.only('find_pattern_partials finds partials', function (test) { testFindPartials(test, [ '{{> molecules-comment-header}}', '{{> molecules-comment-header}}', @@ -227,7 +227,7 @@ tap.only('find_pattern_partials finds partials', function(test) { ]); }); -tap.test('find_pattern_partials finds verbose partials', function(test) { +tap.test('find_pattern_partials finds verbose partials', function (test) { testFindPartials(test, [ '{{> molecules/components/comment-header.hbs }}', "{{> molecules/components/single-comment.hbs(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}", @@ -240,7 +240,7 @@ tap.test('find_pattern_partials finds verbose partials', function(test) { tap.test( 'find_pattern_partials finds simple partials with parameters', - function(test) { + function (test) { testFindPartials(test, [ "{{> molecules-single-comment(description: 'A life isn't like a garden. Perfect moments can be had, but not preserved, except in memory.') }}", '{{> molecules-single-comment(description:"A life is like a "garden". Perfect moments can be had, but not preserved, except in memory.") }}', @@ -250,14 +250,14 @@ tap.test( tap.test( 'find_pattern_partials finds simple partials with style modifiers', - function(test) { + function (test) { testFindPartials(test, ['{{> molecules-single-comment:foo }}']); } ); tap.test( 'find_pattern_partials finds partials with handlebars parameters', - function(test) { + function (test) { testFindPartials(test, [ '{{> atoms-title title="bravo" headingLevel="2" headingSize="bravo" position="left"}}', '{{> atoms-title title="bravo"' + @@ -277,15 +277,16 @@ tap.test( } ); -tap.test('find_pattern_partials finds handlebars block partials', function( - test -) { - testFindPartials(test, ['{{#> myPartial }}']); -}); +tap.test( + 'find_pattern_partials finds handlebars block partials', + function (test) { + testFindPartials(test, ['{{#> myPartial }}']); + } +); tap.only( 'hidden handlebars patterns can be called by their nice names', - function(test) { + function (test) { //arrange const testPatternsPath = path.resolve( __dirname, @@ -310,9 +311,9 @@ tap.only( processRecursive(hiddenPatternPath, pl), processRecursive(testPatternPath, pl), ]).then(() => { - testPattern.render().then(results => { + testPattern.render().then((results) => { //act - test.equals( + test.equal( util.sanitized(results), util.sanitized("Here's the hidden atom: [I'm the hidden atom\n]\n") ); @@ -324,7 +325,7 @@ tap.only( tap.test( '@partial-block template should render without throwing (@geoffp repo issue #3)', - function(test) { + function (test) { test.plan(1); var patternPath = path.join('atoms', 'global', 'at-partial-block.hbs'); @@ -335,7 +336,7 @@ tap.test( processIterative(atPartialBlockPattern, patternlab).then(() => { processRecursive(patternPath, patternlab).then(() => { - atPartialBlockPattern.render().then(results => { + atPartialBlockPattern.render().then((results) => { var expectedResults = '{{> @partial-block }}' + eol + 'It worked!' + eol; test.equal(results, expectedResults); @@ -347,7 +348,7 @@ tap.test( tap.test( 'A template calling a @partial-block template should render correctly', - function(test) { + function (test) { test.plan(1); // pattern paths @@ -371,10 +372,10 @@ tap.test( processRecursive(pattern1Path, patternlab), processRecursive(pattern2Path, patternlab), ]).then(() => { - callAtPartialBlockPattern.render().then(results => { + callAtPartialBlockPattern.render().then((results) => { // test var expectedResults = 'Hello World!' + eol + 'It worked!' + eol; - test.equals(results, expectedResults); + test.equal(results, expectedResults); }); }); } diff --git a/packages/core/test/engine_liquid_tests.js b/packages/core/test/engine_liquid_tests.js index 177d41677..728eba75a 100644 --- a/packages/core/test/engine_liquid_tests.js +++ b/packages/core/test/engine_liquid_tests.js @@ -12,7 +12,7 @@ var eol = require('os').EOL; // don't run these tests unless liquid is installed var engineLoader = require('../src/lib/pattern_engines'); if (!engineLoader.liquid) { - tap.test('Liquid engine not installed, skipping tests.', function(test) { + tap.test('Liquid engine not installed, skipping tests.', function (test) { test.end(); }); return; @@ -62,15 +62,15 @@ function testFindPartials(test, partialTests) { var results = currentPattern.findPartials(); // assert - test.equals(results.length, partialTests.length); - partialTests.forEach(function(testString, index) { - test.equals(results[index], testString); + test.equal(results.length, partialTests.length); + partialTests.forEach(function (testString, index) { + test.equal(results[index], testString); }); test.end(); } -tap.test('button liquid pattern renders', function(test) { +tap.test('button liquid pattern renders', function (test) { test.plan(1); var patternPath = path.join('atoms', 'general', 'button.liquid'); @@ -105,13 +105,13 @@ tap.test('button liquid pattern renders', function(test) { .then(() => { assembler.process_pattern_recursive(patternPath, patternlab); - test.equals(helloWorldPattern.render(), expectedValue); + test.equal(helloWorldPattern.render(), expectedValue); }); }); tap.test( 'media object liquid pattern can see the atoms-button and atoms-image partials and renders them', - function(test) { + function (test) { test.plan(1); // pattern paths @@ -145,7 +145,7 @@ tap.test( // test // this pattern is too long - so just remove line endings on both sides and compare output - test.equals( + test.equal( mediaObjectPattern.render().replace(/\r?\n|\r/gm, ''), expectedValue.replace(/\r?\n|\r/gm, '') ); @@ -153,41 +153,43 @@ tap.test( } ); -tap.test('liquid partials can render JSON values', { skip: true }, function( - test -) { - test.plan(1); +tap.test( + 'liquid partials can render JSON values', + { skip: true }, + function (test) { + test.plan(1); - // pattern paths - var pattern1Path = path.resolve( - testPatternsPath, - 'atoms', - 'global', - 'helloworld-withdata.hbs' - ); + // pattern paths + var pattern1Path = path.resolve( + testPatternsPath, + 'atoms', + 'global', + 'helloworld-withdata.hbs' + ); - // set up environment - var patternlab = new fakePatternLab(); // environment + // set up environment + var patternlab = new fakePatternLab(); // environment - // do all the normal processing of the pattern - var helloWorldWithData = assembler.process_pattern_iterative( - pattern1Path, - patternlab - ); - assembler.process_pattern_recursive(pattern1Path, patternlab); + // do all the normal processing of the pattern + var helloWorldWithData = assembler.process_pattern_iterative( + pattern1Path, + patternlab + ); + assembler.process_pattern_recursive(pattern1Path, patternlab); - // test - test.equals( - helloWorldWithData.render(), - 'Hello world!\nYeah, we got the subtitle from the JSON.\n' - ); - test.end(); -}); + // test + test.equal( + helloWorldWithData.render(), + 'Hello world!\nYeah, we got the subtitle from the JSON.\n' + ); + test.end(); + } +); tap.test( 'liquid partials use the JSON environment from the calling pattern and can accept passed parameters', { skip: true }, - function(test) { + function (test) { test.plan(1); // pattern paths @@ -214,7 +216,7 @@ tap.test( assembler.process_pattern_recursive(molPath, patternlab); // test - test.equals( + test.equal( mol.render(), '

Call with default JSON environment:

\nThis is Hello world!\nfrom the default JSON.\n\n\n

Call with passed parameter:

\nHowever, this is Hello world!\nfrom a totally different blob.\n\n' ); @@ -222,7 +224,7 @@ tap.test( } ); -tap.test('find_pattern_partials finds partials', function(test) { +tap.test('find_pattern_partials finds partials', function (test) { testFindPartials(test, [ '{% include "atoms-image" %}', "{% include 'atoms-image' %}", @@ -233,7 +235,7 @@ tap.test('find_pattern_partials finds partials', function(test) { ]); }); -tap.test('find_pattern_partials finds verbose partials', function(test) { +tap.test('find_pattern_partials finds verbose partials', function (test) { testFindPartials(test, [ "{% include 'molecules/components/comment-header.liquid' %}", "{% include 'atoms/global/test' %}", @@ -242,7 +244,7 @@ tap.test('find_pattern_partials finds verbose partials', function(test) { tap.test( 'find_pattern_partials finds partials with liquid parameters', - function(test) { + function (test) { testFindPartials(test, [ "{% include 'molecules-template' with {'foo': 'bar'} %}", "{% include 'molecules-template' with vars %}", diff --git a/packages/core/test/engine_mustache_tests.js b/packages/core/test/engine_mustache_tests.js index de1cb210c..1bfcf8cee 100644 --- a/packages/core/test/engine_mustache_tests.js +++ b/packages/core/test/engine_mustache_tests.js @@ -13,7 +13,7 @@ var config = require('./util/patternlab-config.json'); var engineLoader = require('../src/lib/pattern_engines'); engineLoader.loadAllEngines(config); if (!engineLoader.mustache) { - tap.test('Mustache engine not installed, skipping tests.', function(test) { + tap.test('Mustache engine not installed, skipping tests.', function (test) { test.end(); }); return; @@ -63,9 +63,9 @@ function testFindPartials(test, partialTests) { var results = currentPattern.findPartials(); // assert - test.equals(results.length, partialTests.length); - partialTests.forEach(function(testString, index) { - test.equals(results[index], testString); + test.equal(results.length, partialTests.length); + partialTests.forEach(function (testString, index) { + test.equal(results[index], testString); }); test.end(); @@ -89,9 +89,9 @@ function testFindPartialsWithStyleModifiers(test, partialTests) { var results = currentPattern.findPartialsWithStyleModifiers(); // assert - test.equals(results.length, partialTests.length); - partialTests.forEach(function(testString, index) { - test.equals(results[index], testString); + test.equal(results.length, partialTests.length); + partialTests.forEach(function (testString, index) { + test.equal(results[index], testString); }); test.end(); @@ -115,21 +115,21 @@ function testFindPartialsWithPatternParameters(test, partialTests) { var results = currentPattern.findPartialsWithPatternParameters(); // assert - test.equals(results.length, partialTests.length); - partialTests.forEach(function(testString, index) { - test.equals(results[index], testString); + test.equal(results.length, partialTests.length); + partialTests.forEach(function (testString, index) { + test.equal(results[index], testString); }); test.end(); } -tap.test('find_pattern_partials finds one simple partial', function(test) { +tap.test('find_pattern_partials finds one simple partial', function (test) { testFindPartials(test, ['{{> molecules-comment-header}}']); }); tap.test( 'find_pattern_partials finds simple partials under stressed circumstances', - function(test) { + function (test) { testFindPartials(test, [ '{{>molecules-comment-header}}', '{{> ' + eol + ' molecules-comment-header' + eol + '}}', @@ -138,29 +138,31 @@ tap.test( } ); -tap.test('find_pattern_partials finds one simple verbose partial', function( - test -) { - testFindPartials(test, ['{{> atoms/global/test }}']); -}); +tap.test( + 'find_pattern_partials finds one simple verbose partial', + function (test) { + testFindPartials(test, ['{{> atoms/global/test }}']); + } +); -tap.test('find_pattern_partials finds partials with parameters', function( - test -) { - testFindPartials(test, [ - '{{> molecules-single-comment(description: true) }}', - '{{> molecules-single-comment(description: 42) }}', - "{{> molecules-single-comment(description: '42') }}", - '{{> molecules-single-comment(description: "42") }}', - "{{> molecules-single-comment(description: 'test', anotherThing: 'retest') }}", - '{{> molecules-single-comment(description: false, anotherThing: "retest") }}', - '{{> molecules-single-comment(description:"A life is like a "garden". Perfect moments can be had, but not preserved, except in memory.") }}', - ]); -}); +tap.test( + 'find_pattern_partials finds partials with parameters', + function (test) { + testFindPartials(test, [ + '{{> molecules-single-comment(description: true) }}', + '{{> molecules-single-comment(description: 42) }}', + "{{> molecules-single-comment(description: '42') }}", + '{{> molecules-single-comment(description: "42") }}', + "{{> molecules-single-comment(description: 'test', anotherThing: 'retest') }}", + '{{> molecules-single-comment(description: false, anotherThing: "retest") }}', + '{{> molecules-single-comment(description:"A life is like a "garden". Perfect moments can be had, but not preserved, except in memory.") }}', + ]); + } +); tap.test( 'find_pattern_partials finds simple partials with style modifiers', - function(test) { + function (test) { testFindPartials(test, [ '{{> molecules-single-comment:foo }}', '{{> molecules-single-comment:foo|bar }}', @@ -168,7 +170,7 @@ tap.test( } ); -tap.test('find_pattern_partials finds mixed partials', function(test) { +tap.test('find_pattern_partials finds mixed partials', function (test) { testFindPartials(test, [ '{{> molecules-single-comment:foo(description: "test", anotherThing: true) }}', '{{> molecules-single-comment:foo|bar(description: true) }}', @@ -177,7 +179,7 @@ tap.test('find_pattern_partials finds mixed partials', function(test) { tap.test( 'find_pattern_partials finds one simple partial with styleModifier', - function(test) { + function (test) { testFindPartialsWithStyleModifiers(test, [ '{{> molecules-comment-header:test}}', ]); @@ -186,7 +188,7 @@ tap.test( tap.test( 'find_pattern_partials finds partial with many styleModifiers', - function(test) { + function (test) { testFindPartialsWithStyleModifiers(test, [ '{{> molecules-comment-header:test|test2|test3}}', ]); @@ -195,7 +197,7 @@ tap.test( tap.test( 'find_pattern_partials finds partials with differing styleModifiers', - function(test) { + function (test) { testFindPartialsWithStyleModifiers(test, [ '{{> molecules-comment-header:test|test2|test3}}', '{{> molecules-comment-header:foo-1}}', @@ -206,7 +208,7 @@ tap.test( tap.test( 'find_pattern_partials finds partials with styleModifiers when parameters present', - function(test) { + function (test) { testFindPartialsWithStyleModifiers(test, [ '{{> molecules-comment-header:test|test2|test3(description: true)}}', "{{> molecules-comment-header:foo-1(description: 'foo')}}", @@ -217,7 +219,7 @@ tap.test( tap.test( 'find_pattern_partials_with_parameters finds one simple partial with parameters', - function(test) { + function (test) { testFindPartialsWithPatternParameters(test, [ "{{> molecules-comment-header(description: 'test')}}", ]); @@ -226,7 +228,7 @@ tap.test( tap.test( 'find_pattern_partials_with_parameters finds partials with parameters', - function(test) { + function (test) { testFindPartialsWithPatternParameters(test, [ '{{> molecules-single-comment(description: true) }}', '{{> molecules-single-comment(description: 42) }}', @@ -241,7 +243,7 @@ tap.test( tap.test( 'find_pattern_partials finds partials with parameters when styleModifiers present', - function(test) { + function (test) { testFindPartialsWithPatternParameters(test, [ '{{> molecules-comment-header:test|test2|test3(description: true)}}', "{{> molecules-comment-header:foo-1(description: 'foo')}}", diff --git a/packages/core/test/engine_react_tests.js b/packages/core/test/engine_react_tests.js index da7b92f47..8e34d5338 100644 --- a/packages/core/test/engine_react_tests.js +++ b/packages/core/test/engine_react_tests.js @@ -15,13 +15,13 @@ engineLoader.loadAllEngines(config); // don't run these tests unless the react engine is installed if (!engineLoader.react) { - tap.test('React engine not installed, skipping tests.', test => { + tap.test('React engine not installed, skipping tests.', (test) => { test.end(); }); } else { const fpl = testUtils.fakePatternLab(testPatternsPath); - tap.test('Load the hello world pattern and verify contents', test => { + tap.test('Load the hello world pattern and verify contents', (test) => { const patternPath = path.join( testPatternsPath, 'atoms/general/HelloWorld.jsx' @@ -29,19 +29,19 @@ if (!engineLoader.react) { const patternContent = fs.readFileSync(patternPath, { encoding: 'utf8' }); const pattern = loadPattern(patternPath, fpl); - test.equals(pattern.template, patternContent); + test.equal(pattern.template, patternContent); test.end(); }); - tap.test('Load the hello world pattern and verify output', test => { + tap.test('Load the hello world pattern and verify output', (test) => { const patternPath = path.join( testPatternsPath, 'atoms/general/HelloWorld.jsx' ); const pattern = loadPattern(patternPath, fpl); - return pattern.render().then(output => { - test.equals(output, '
Hello world!
\n'); + return pattern.render().then((output) => { + test.equal(output, '
Hello world!
\n'); }); }); } diff --git a/packages/core/test/engine_twig_tests.js b/packages/core/test/engine_twig_tests.js index 310a07803..73c80e9a0 100644 --- a/packages/core/test/engine_twig_tests.js +++ b/packages/core/test/engine_twig_tests.js @@ -12,7 +12,7 @@ var eol = require('os').EOL; // don't run these tests unless twig is installed var engineLoader = require('../src/lib/pattern_engines'); if (!engineLoader.twig) { - tap.test('Twig engine not installed, skipping tests.', function(test) { + tap.test('Twig engine not installed, skipping tests.', function (test) { test.end(); }); return; @@ -62,15 +62,15 @@ function testFindPartials(test, partialTests) { var results = currentPattern.findPartials(); // assert - test.equals(results.length, partialTests.length); - partialTests.forEach(function(testString, index) { - test.equals(results[index], testString); + test.equal(results.length, partialTests.length); + partialTests.forEach(function (testString, index) { + test.equal(results[index], testString); }); test.end(); } -tap.test('button twig pattern renders', function(test) { +tap.test('button twig pattern renders', function (test) { test.plan(1); var patternPath = path.join('atoms', 'general', 'button.twig'); @@ -105,13 +105,13 @@ tap.test('button twig pattern renders', function(test) { .then(() => { assembler.process_pattern_recursive(patternPath, patternlab); - test.equals(helloWorldPattern.render(), expectedValue); + test.equal(helloWorldPattern.render(), expectedValue); }); }); tap.test( 'media object twig pattern can see the atoms-button and atoms-image partials and renders them', - function(test) { + function (test) { test.plan(1); // pattern paths @@ -145,7 +145,7 @@ tap.test( // test // this pattern is too long - so just remove line endings on both sides and compare output - test.equals( + test.equal( mediaObjectPattern.render().replace(/\r?\n|\r/gm, ''), expectedValue.replace(/\r?\n|\r/gm, '') ); @@ -153,41 +153,43 @@ tap.test( } ); -tap.test('twig partials can render JSON values', { skip: true }, function( - test -) { - test.plan(1); +tap.test( + 'twig partials can render JSON values', + { skip: true }, + function (test) { + test.plan(1); - // pattern paths - var pattern1Path = path.resolve( - testPatternsPath, - 'atoms', - 'global', - 'helloworld-withdata.hbs' - ); + // pattern paths + var pattern1Path = path.resolve( + testPatternsPath, + 'atoms', + 'global', + 'helloworld-withdata.hbs' + ); - // set up environment - var patternlab = new fakePatternLab(); // environment + // set up environment + var patternlab = new fakePatternLab(); // environment - // do all the normal processing of the pattern - var helloWorldWithData = assembler.process_pattern_iterative( - pattern1Path, - patternlab - ); - assembler.process_pattern_recursive(pattern1Path, patternlab); + // do all the normal processing of the pattern + var helloWorldWithData = assembler.process_pattern_iterative( + pattern1Path, + patternlab + ); + assembler.process_pattern_recursive(pattern1Path, patternlab); - // test - test.equals( - helloWorldWithData.render(), - 'Hello world!\nYeah, we got the subtitle from the JSON.\n' - ); - test.end(); -}); + // test + test.equal( + helloWorldWithData.render(), + 'Hello world!\nYeah, we got the subtitle from the JSON.\n' + ); + test.end(); + } +); tap.test( 'twig partials use the JSON environment from the calling pattern and can accept passed parameters', { skip: true }, - function(test) { + function (test) { test.plan(1); // pattern paths @@ -214,7 +216,7 @@ tap.test( assembler.process_pattern_recursive(molPath, patternlab); // test - test.equals( + test.equal( mol.render(), '

Call with default JSON environment:

\nThis is Hello world!\nfrom the default JSON.\n\n\n

Call with passed parameter:

\nHowever, this is Hello world!\nfrom a totally different blob.\n\n' ); @@ -222,7 +224,7 @@ tap.test( } ); -tap.test('find_pattern_partials finds partials', function(test) { +tap.test('find_pattern_partials finds partials', function (test) { testFindPartials(test, [ '{% include "atoms-image" %}', "{% include 'atoms-image' %}", @@ -233,20 +235,21 @@ tap.test('find_pattern_partials finds partials', function(test) { ]); }); -tap.test('find_pattern_partials finds verbose partials', function(test) { +tap.test('find_pattern_partials finds verbose partials', function (test) { testFindPartials(test, [ "{% include 'molecules/components/comment-header.twig' %}", "{% include 'atoms/global/test' %}", ]); }); -tap.test('find_pattern_partials finds partials with twig parameters', function( - test -) { - testFindPartials(test, [ - "{% include 'molecules-template' with {'foo': 'bar'} %}", - "{% include 'molecules-template' with vars %}", - "{% include 'molecules-template.twig' with {'foo': 'bar'} only %}", - "{% include 'organisms-sidebar' ignore missing with {'foo': 'bar'} %}", - ]); -}); +tap.test( + 'find_pattern_partials finds partials with twig parameters', + function (test) { + testFindPartials(test, [ + "{% include 'molecules-template' with {'foo': 'bar'} %}", + "{% include 'molecules-template' with vars %}", + "{% include 'molecules-template.twig' with {'foo': 'bar'} only %}", + "{% include 'organisms-sidebar' ignore missing with {'foo': 'bar'} %}", + ]); + } +); diff --git a/packages/core/test/engine_underscore_tests.js b/packages/core/test/engine_underscore_tests.js index 01204fefe..a944e830b 100644 --- a/packages/core/test/engine_underscore_tests.js +++ b/packages/core/test/engine_underscore_tests.js @@ -14,7 +14,7 @@ var eol = require('os').EOL; // don't run tests unless underscore is installed var engineLoader = require('../src/lib/pattern_engines'); if (!engineLoader.underscore) { - tap.test('Underscore engine not installed, skipping tests', function(test) { + tap.test('Underscore engine not installed, skipping tests', function (test) { test.end(); }); return; @@ -45,7 +45,7 @@ function fakePatternLab() { return fpl; } -tap.test('hello world underscore pattern renders', function(test) { +tap.test('hello world underscore pattern renders', function (test) { test.plan(1); var patternPath = path.resolve( @@ -65,11 +65,11 @@ tap.test('hello world underscore pattern renders', function(test) { .then(() => { assembler.process_pattern_recursive(patternPath, patternlab); - test.equals(helloWorldPattern.render(), 'Hello world!' + eol); + test.equal(helloWorldPattern.render(), 'Hello world!' + eol); }); }); -tap.test('underscore partials can render JSON values', function(test) { +tap.test('underscore partials can render JSON values', function (test) { test.plan(1); // pattern paths @@ -91,7 +91,7 @@ tap.test('underscore partials can render JSON values', function(test) { assembler.process_pattern_recursive(pattern1Path, patternlab); // test - test.equals( + test.equal( helloWorldWithData.render(), 'Hello world!' + eol + 'Yeah, we got the subtitle from the JSON.' + eol ); @@ -100,7 +100,7 @@ tap.test('underscore partials can render JSON values', function(test) { tap.test( 'findPartial return the ID of the partial, given a whole partial call', - function(test) { + function (test) { var engineLoader = require('../src/lib/pattern_engines'); var underscoreEngine = engineLoader.underscore; @@ -108,7 +108,7 @@ tap.test( // do all the normal processing of the pattern // test - test.equals( + test.equal( underscoreEngine.findPartial( "<%= _.renderNamedPartial('molecules-details', obj) %>" ), @@ -120,7 +120,7 @@ tap.test( tap.test( 'hidden underscore patterns can be called by their nice names', - function(test) { + function (test) { const util = require('./util/test_utils.js'); //arrange @@ -149,7 +149,7 @@ tap.test( pattern_assembler.process_pattern_recursive(testPatternPath, pl); //act - test.equals( + test.equal( util.sanitized(testPattern.render()), util.sanitized("Here's the hidden atom: [I'm the hidden atom\n]\n") ); diff --git a/packages/core/test/exportData_tests.js b/packages/core/test/exportData_tests.js index 3e0a7df67..2443dde76 100644 --- a/packages/core/test/exportData_tests.js +++ b/packages/core/test/exportData_tests.js @@ -10,7 +10,7 @@ const util = require('./util/test_utils.js'); const testPatternsPath = path.resolve(__dirname, 'files', '_patterns'); const fsMock = { - outputFileSync: function(path, content) { + outputFileSync: function (path, content) { /* INTENTIONAL NOOP */ }, }; @@ -28,70 +28,70 @@ const uikitFoo = { excludedTags: ['baz'], }; -tap.test('exportData exports config', function(test) { +tap.test('exportData exports config', function (test) { const patternlab = util.fakePatternLab(testPatternsPath); const result = exportData(patternlab, uikitFoo); - test.equals(result.indexOf('config') > -1, true); - test.equals(result.indexOf('paths') > -1, true); - test.equals(result.indexOf('theme') > -1, true); + test.equal(result.indexOf('config') > -1, true); + test.equal(result.indexOf('paths') > -1, true); + test.equal(result.indexOf('theme') > -1, true); test.end(); }); -tap.test('exportData exports ishControls', function(test) { +tap.test('exportData exports ishControls', function (test) { const patternlab = util.fakePatternLab(testPatternsPath); const result = exportData(patternlab, uikitFoo); - test.equals(result.indexOf('ishControlsHide') > -1, true); + test.equal(result.indexOf('ishControlsHide') > -1, true); test.end(); }); -tap.test('exportData exports navItems', function(test) { +tap.test('exportData exports navItems', function (test) { const patternlab = util.fakePatternLab(testPatternsPath); const result = exportData(patternlab, uikitFoo); - test.equals(result.indexOf('patternGroups') > -1, true); + test.equal(result.indexOf('patternGroups') > -1, true); test.end(); }); -tap.test('exportData exports patternPaths', function(test) { +tap.test('exportData exports patternPaths', function (test) { const patternlab = util.fakePatternLab(testPatternsPath); const result = exportData(patternlab, uikitFoo); - test.equals(result.indexOf('patternPaths') > -1, true); + test.equal(result.indexOf('patternPaths') > -1, true); test.end(); }); -tap.test('exportData exports viewAllPaths', function(test) { +tap.test('exportData exports viewAllPaths', function (test) { const patternlab = util.fakePatternLab(testPatternsPath); const result = exportData(patternlab, uikitFoo); - test.equals(result.indexOf('viewAllPaths') > -1, true); + test.equal(result.indexOf('viewAllPaths') > -1, true); test.end(); }); -tap.test('exportData exports plugins', function(test) { +tap.test('exportData exports plugins', function (test) { const patternlab = util.fakePatternLab(testPatternsPath); const result = exportData(patternlab, uikitFoo); - test.equals(result.indexOf('plugins') > -1, true); + test.equal(result.indexOf('plugins') > -1, true); test.end(); }); -tap.test('exportData exports defaultShowPatternInfo', function(test) { +tap.test('exportData exports defaultShowPatternInfo', function (test) { const patternlab = util.fakePatternLab(testPatternsPath); const result = exportData(patternlab, uikitFoo); - test.equals(result.indexOf('defaultShowPatternInfo') > -1, true); - test.equals(result.indexOf('"defaultShowPatternInfo":false') > -1, true); + test.equal(result.indexOf('defaultShowPatternInfo') > -1, true); + test.equal(result.indexOf('"defaultShowPatternInfo":false') > -1, true); test.end(); }); -tap.test('exportData exports defaultPattern', function(test) { +tap.test('exportData exports defaultPattern', function (test) { const patternlab = util.fakePatternLab(testPatternsPath); const result = exportData(patternlab, uikitFoo); - test.equals(result.indexOf('defaultPattern') > -1, true); - test.equals(result.indexOf('"defaultPattern":"all"') > -1, true); + test.equal(result.indexOf('defaultPattern') > -1, true); + test.equal(result.indexOf('"defaultPattern":"all"') > -1, true); test.end(); }); diff --git a/packages/core/test/files/_meta/_head.html b/packages/core/test/files/_meta/_head.html index b1f5c1ce0..56d9a2432 100644 --- a/packages/core/test/files/_meta/_head.html +++ b/packages/core/test/files/_meta/_head.html @@ -2,15 +2,22 @@ {{ title }} - + - - + + {{{ patternLabHead }}} - diff --git a/packages/core/test/get_tests.js b/packages/core/test/get_tests.js index 5e954182c..59be0fd20 100644 --- a/packages/core/test/get_tests.js +++ b/packages/core/test/get_tests.js @@ -7,29 +7,30 @@ const getPartial = require('../src/lib/get'); const patterns_dir = './test/files/_patterns'; -tap.test('getPartial - returns the fuzzy result when no others found', function( - test -) { - //arrange - const patternlab = util.fakePatternLab(patterns_dir); - patternlab.patterns = []; +tap.test( + 'getPartial - returns the fuzzy result when no others found', + function (test) { + //arrange + const patternlab = util.fakePatternLab(patterns_dir); + patternlab.patterns = []; - patternlab.patterns.push({ - patternPartial: 'character-han-solo', - subdir: 'character', - fileName: 'han-solo', - verbosePartial: 'character/han-solo', - }); + patternlab.patterns.push({ + patternPartial: 'character-han-solo', + subdir: 'character', + fileName: 'han-solo', + verbosePartial: 'character/han-solo', + }); - //act - var result = getPartial('character-han', patternlab); + //act + var result = getPartial('character-han', patternlab); - //assert - test.equals(result, patternlab.patterns[0]); - test.end(); -}); + //assert + test.equal(result, patternlab.patterns[0]); + test.end(); + } +); -tap.test('getPartial - returns the verbose result if found', function(test) { +tap.test('getPartial - returns the verbose result if found', function (test) { //arrange const patternlab = util.fakePatternLab(patterns_dir); patternlab.patterns = []; @@ -53,11 +54,11 @@ tap.test('getPartial - returns the verbose result if found', function(test) { var result = getPartial('molecules/primary-nav', patternlab); //assert - test.equals(result, patternlab.patterns[1]); + test.equal(result, patternlab.patterns[1]); test.end(); }); -tap.test('getPartial - returns the exact key if found', function(test) { +tap.test('getPartial - returns the exact key if found', function (test) { //arrange const patternlab = util.fakePatternLab(patterns_dir); patternlab.patterns = []; @@ -79,6 +80,6 @@ tap.test('getPartial - returns the exact key if found', function(test) { var result = getPartial('molecules-primary-nav', patternlab); //assert - test.equals(result, patternlab.patterns[1]); + test.equal(result, patternlab.patterns[1]); test.end(); }); diff --git a/packages/core/test/index_tests.js b/packages/core/test/index_tests.js index 8f851cb26..f8b49ff61 100644 --- a/packages/core/test/index_tests.js +++ b/packages/core/test/index_tests.js @@ -15,33 +15,33 @@ process.env.PATTERNLAB_ENV = 'CI'; //set up a global mocks - we don't want to be writing/rendering any files right now -const copierMock = function() { +const copierMock = function () { return { - copyAndWatch: function() { + copyAndWatch: function () { return Promise.resolve(); }, }; }; -const uiBuilderMock = function() { +const uiBuilderMock = function () { return { - buildFrontend: function() { + buildFrontend: function () { return Promise.resolve(); }, }; }; const fsMock = { - outputFileSync: function(path, content) { + outputFileSync: function (path, content) { /* INTENTIONAL NOOP */ }, - readJSONSync: function(path, encoding) { + readJSONSync: function (path, encoding) { return fs.readJSONSync(path, encoding); }, - emptyDir: function(path) { + emptyDir: function (path) { return fs.emptyDir(path); }, - readFileSync: function(path, encoding) { + readFileSync: function (path, encoding) { return fs.readFileSync(path, encoding); }, }; @@ -57,29 +57,29 @@ entry.__set__({ copier: copierMock, }); -tap.test('version - should call patternlab.getVersion', test => { +tap.test('version - should call patternlab.getVersion', (test) => { //arrange const pl = new entry(testConfig); //act //assert - test.equals(pl.version(), packageInfo.version); + test.equal(pl.version(), packageInfo.version); test.end(); }); tap.test( 'getDefaultConfig - static method should return the default config object', - test => { + (test) => { const requestedConfig = entry.getDefaultConfig(); test.type(requestedConfig, 'object'); - test.equals(requestedConfig, defaultConfig); + test.equal(requestedConfig, defaultConfig); test.end(); } ); tap.test( 'getDefaultConfig - instance method should return the default config object', - test => { + (test) => { //arrange const pl = new entry(testConfig); @@ -87,12 +87,12 @@ tap.test( //assert const requestedConfig = pl.getDefaultConfig(); test.type(requestedConfig, 'object'); - test.equals(requestedConfig, defaultConfig); + test.equal(requestedConfig, defaultConfig); test.end(); } ); -tap.test('patternsonly a promise', test => { +tap.test('patternsonly a promise', (test) => { //arrange const revert = entry.__set__('buildPatterns', buildPatternsMock); const pl = new entry(testConfig); @@ -104,7 +104,7 @@ tap.test('patternsonly a promise', test => { }); }); -tap.test('patternsonly calls buildPatterns', test => { +tap.test('patternsonly calls buildPatterns', (test) => { //arrange const revert = entry.__set__( 'buildPatterns', @@ -113,7 +113,7 @@ tap.test('patternsonly calls buildPatterns', test => { test.ok(cleanPublic); test.type(patternlab, 'object'); test.type(data, 'object'); - test.equals(data.foo, 'bar'); + test.equal(data.foo, 'bar'); return Promise.resolve(); } ); @@ -128,9 +128,9 @@ tap.test('patternsonly calls buildPatterns', test => { }); }); -tap.test('serve calls serve', test => { +tap.test('serve calls serve', (test) => { //arrange - const revert = entry.__set__('serverModule', patternlab => { + const revert = entry.__set__('serverModule', (patternlab) => { return { serve: () => { test.ok(1); @@ -149,7 +149,7 @@ tap.test('serve calls serve', test => { }); }); -tap.test('buildPatterns suite', test => { +tap.test('buildPatterns suite', (test) => { //arrange const patternExporterMock = { @@ -158,17 +158,17 @@ tap.test('buildPatterns suite', test => { the contents of the patterns look like. This, coupled with a mocking of fs and the ui_builder, allow us to focus only on the order of events within build. */ - export_patterns: function(patternlab) { + export_patterns: function (patternlab) { tap.test( 'replace data link even when pattern parameter present', - function(test) { + function (test) { var pattern = get('test-paramParent', patternlab); - test.equals( + test.equal( util.sanitized(pattern.extendedTemplate), '', 'partial inclusion completes' ); - test.equals( + test.equal( pattern.patternPartialCode.indexOf('test-foo.rendered.html') > -1, true, 'data link should be replaced properly' @@ -179,9 +179,9 @@ tap.test('buildPatterns suite', test => { tap.test( 'finds partials with their own parameters and renders them too', - function(test) { + function (test) { var pattern = get('test-c', patternlab); - test.equals( + test.equal( util.sanitized(pattern.patternPartialCode), util.sanitized(`c b @@ -195,9 +195,9 @@ tap.test('buildPatterns suite', test => { tap.test( 'finds and extends templates with mixed parameter and global data', - function(test) { + function (test) { var pattern = get('test-sticky-comment', patternlab); - test.equals( + test.equal( util.sanitized(pattern.patternPartialCode), util.sanitized( `

Bar

A life is like a garden. Perfect moments can be had, but not preserved, except in memory.

` @@ -207,9 +207,9 @@ tap.test('buildPatterns suite', test => { } ); - tap.test('expands links inside parameters', function(test) { + tap.test('expands links inside parameters', function (test) { var pattern = get('test-linkInParameter', patternlab); - test.equals( + test.equal( util.sanitized(pattern.patternPartialCode), util.sanitized( `Cool Dude` @@ -218,10 +218,10 @@ tap.test('buildPatterns suite', test => { test.end(); }); - tap.test('uses global listItem property', test => { + tap.test('uses global listItem property', (test) => { var pattern = get('test-listWithPartial', patternlab); let assertionCount = 0; - ['dA', 'dB', 'dC'].forEach(d => { + ['dA', 'dB', 'dC'].forEach((d) => { if (pattern.patternPartialCode.indexOf(d) > -1) { assertionCount++; } @@ -232,7 +232,7 @@ tap.test('buildPatterns suite', test => { tap.test( 'overwrites listItem property if that property is in local .listitem.json', - test => { + (test) => { var pattern = get('test-listWithListItems', patternlab); test.ok(pattern.patternPartialCode.indexOf('tX') > -1); test.ok(pattern.patternPartialCode.indexOf('tY') > -1); @@ -244,7 +244,7 @@ tap.test('buildPatterns suite', test => { tap.test( 'uses global listItem property after merging local .listitem.json', - test => { + (test) => { var pattern = get('test-listWithListItems', patternlab); test.ok(pattern.patternPartialCode.indexOf('dA') > -1); test.ok(pattern.patternPartialCode.indexOf('dB') > -1); @@ -255,9 +255,9 @@ tap.test('buildPatterns suite', test => { tap.test( 'correctly ignores bookended partials without a style modifier when the same partial has a style modifier between', - test => { + (test) => { var pattern = get('test-bookend-listitem', patternlab); - test.equals( + test.equal( util.sanitized(pattern.extendedTemplate), util.sanitized(`
{{#listItems-two}} @@ -283,9 +283,9 @@ tap.test('buildPatterns suite', test => { tap.test( 'listItems keys (`one` through `twelve`) can be used more than once per pattern', - test => { + (test) => { var pattern = get('test-repeatedListItems', patternlab); - test.equals( + test.equal( util.sanitized(pattern.patternPartialCode), util.sanitized(`AAA BBB`) ); @@ -298,7 +298,7 @@ tap.test('buildPatterns suite', test => { // From issue #145 https://github.com/pattern-lab/patternlab-node/issues/145 // tap.test(' parses parameters containing html tags', function (test) { // var pattern = get('test-parameterTags', patternlab); - // test.equals(util.sanitized(pattern.patternPartialCode), util.sanitized(`

Single-quoted

Double-quoted

With attributes

`)); + // test.equal(util.sanitized(pattern.patternPartialCode), util.sanitized(`

Single-quoted

Double-quoted

With attributes

`)); // test.end(); // }); @@ -313,7 +313,7 @@ tap.test('buildPatterns suite', test => { testConfig.patternExportPatternPartials = ['test-paramParent']; const pl = new entry(testConfig); - test.equals(pl.events.eventNames().length, 0); + test.equal(pl.events.eventNames().length, 0); //act return pl @@ -325,12 +325,12 @@ tap.test('buildPatterns suite', test => { }, }) .then(() => { - test.equals( + test.equal( pl.events.eventNames().length, 2, 'should register two events' ); - test.equals(pl.events.listenerCount(events.PATTERNLAB_PATTERN_CHANGE), 1); - test.equals(pl.events.listenerCount(events.PATTERNLAB_GLOBAL_CHANGE), 1); + test.equal(pl.events.listenerCount(events.PATTERNLAB_PATTERN_CHANGE), 1); + test.equal(pl.events.listenerCount(events.PATTERNLAB_GLOBAL_CHANGE), 1); }); }); diff --git a/packages/core/test/lineage_hunter_tests.js b/packages/core/test/lineage_hunter_tests.js index 87d6a868d..3ac79646a 100644 --- a/packages/core/test/lineage_hunter_tests.js +++ b/packages/core/test/lineage_hunter_tests.js @@ -58,7 +58,7 @@ function createBasePatternLabObject() { return pl; } -tap.test('find_lineage - finds lineage', function(test) { +tap.test('find_lineage - finds lineage', function (test) { //setup current pattern from what we would have during execution var currentPattern = new Pattern( 'organisms/global/header.mustache', // relative path now @@ -148,7 +148,7 @@ tap.test('find_lineage - finds lineage', function(test) { }, }; // BAD: This "patches" the relative path which is unset when using "createEmpty" - patternlab.patterns.forEach(p => (p.relPath = p.patternLink)); + patternlab.patterns.forEach((p) => (p.relPath = p.patternLink)); lineage_hunter.find_lineage(currentPattern, patternlab); @@ -156,10 +156,10 @@ tap.test('find_lineage - finds lineage', function(test) { // Ensure compatibility for (let i of [currentPattern.lineageIndex, graphLineageIndex]) { - test.equals(i.length, 3); - test.equals(i[0], 'atoms-logo'); - test.equals(i[1], 'molecules-primary-nav'); - test.equals(i[2], 'molecules-search'); + test.equal(i.length, 3); + test.equal(i[0], 'atoms-logo'); + test.equal(i[1], 'molecules-primary-nav'); + test.equal(i[2], 'molecules-search'); } test.end(); @@ -167,7 +167,7 @@ tap.test('find_lineage - finds lineage', function(test) { tap.test( 'find_lineage - finds lineage with spaced pattern parameters', - function(test) { + function (test) { //setup current pattern from what we would have during execution var currentPattern = createFakeEmptyErrorPattern(); extend(currentPattern, { @@ -194,10 +194,10 @@ tap.test( lineage_hunter.find_lineage(currentPattern, patternlab); - test.equals(currentPattern.lineageIndex.length, 1); - test.equals(currentPattern.lineageIndex[0], 'atoms-error'); - test.equals(patternlab.patterns[0].lineageRIndex.length, 1); - test.equals( + test.equal(currentPattern.lineageIndex.length, 1); + test.equal(currentPattern.lineageIndex[0], 'atoms-error'); + test.equal(patternlab.patterns[0].lineageRIndex.length, 1); + test.equal( patternlab.patterns[0].lineageR[0].lineagePattern, 'molecules-error' ); @@ -212,14 +212,14 @@ tap.test( ); var currentPatternLineageIndex = graph.lineageIndex(currentPattern); - test.equals(currentPatternLineageIndex.length, 1); - test.equals(currentPatternLineageIndex[0], 'atoms-error'); + test.equal(currentPatternLineageIndex.length, 1); + test.equal(currentPatternLineageIndex[0], 'atoms-error'); var patternlabPattern0_lineageRIndex = graph.lineageRIndex( patternlab.patterns[0] ); - test.equals(patternlabPattern0_lineageRIndex.length, 1); - test.equals(patternlabPattern0_lineageRIndex[0], 'molecules-error'); + test.equal(patternlabPattern0_lineageRIndex.length, 1); + test.equal(patternlabPattern0_lineageRIndex[0], 'molecules-error'); test.end(); } @@ -227,7 +227,7 @@ tap.test( tap.test( 'cascade_pattern_states promotes a lower pattern state up to the consumer', - function(test) { + function (test) { //arrange var pl = createBasePatternLabObject(); @@ -257,14 +257,14 @@ tap.test( //assert var consumerPatternReturned = getPartial('test-foo', pl); - test.equals(consumerPatternReturned.patternState, 'inreview'); + test.equal(consumerPatternReturned.patternState, 'inreview'); test.end(); } ); tap.test( 'cascade_pattern_states promotes a lower pattern state up to the consumers lineage', - function(test) { + function (test) { //arrange var pl = createBasePatternLabObject(); @@ -295,14 +295,14 @@ tap.test( //assert var consumerPatternReturned = getPartial('test-foo', pl); const lineage = pl.graph.lineage(consumerPatternReturned); - test.equals(lineage[0].lineageState, 'inreview'); + test.equal(lineage[0].lineageState, 'inreview'); test.end(); } ); tap.test( 'cascade_pattern_states sets the pattern state on any lineage patterns reverse lineage', - function(test) { + function (test) { //arrange var pl = createBasePatternLabObject(); @@ -317,7 +317,7 @@ tap.test( //assert var consumedPatternReturned = getPartial('test-bar', pl); let lineageR = pl.graph.lineageR(consumedPatternReturned); - test.equals(lineageR[0].lineageState, 'inreview'); + test.equal(lineageR[0].lineageState, 'inreview'); test.end(); } @@ -325,7 +325,7 @@ tap.test( tap.test( 'cascade_pattern_states promotes lower pattern state when consumer does not have its own state', - function(test) { + function (test) { //arrange var pl = createBasePatternLabObject(); @@ -354,16 +354,16 @@ tap.test( //assert var consumerPatternReturned = getPartial('test-foo', pl); - test.equals(consumerPatternReturned.lineage.length, 1); - test.equals(consumerPatternReturned.lineage[0].lineageState, 'inreview'); - test.equals(consumerPatternReturned.patternState, 'inreview'); + test.equal(consumerPatternReturned.lineage.length, 1); + test.equal(consumerPatternReturned.lineage[0].lineageState, 'inreview'); + test.equal(consumerPatternReturned.patternState, 'inreview'); test.end(); } ); tap.test( 'find_lineage - finds lineage with unspaced pattern parameters', - function(test) { + function (test) { //setup current pattern from what we would have during execution var currentPattern = createFakeEmptyErrorPattern(); extend(currentPattern, { @@ -405,10 +405,10 @@ tap.test( lineage_hunter.find_lineage(currentPattern, patternlab); - test.equals(currentPattern.lineageIndex.length, 1); - test.equals(currentPattern.lineageIndex[0], 'atoms-error'); - test.equals(patternlab.patterns[0].lineageRIndex.length, 1); - test.equals( + test.equal(currentPattern.lineageIndex.length, 1); + test.equal(currentPattern.lineageIndex[0], 'atoms-error'); + test.equal(patternlab.patterns[0].lineageRIndex.length, 1); + test.equal( patternlab.patterns[0].lineageR[0].lineagePattern, 'molecules-error' ); @@ -416,148 +416,150 @@ tap.test( var currentPatternLineageIndex = patternlab.graph.lineageIndex( currentPattern ); - test.equals(currentPatternLineageIndex.length, 1); - test.equals(currentPatternLineageIndex[0], 'atoms-error'); + test.equal(currentPatternLineageIndex.length, 1); + test.equal(currentPatternLineageIndex[0], 'atoms-error'); var pattern0LineageRIndex = patternlab.graph.lineageRIndex( patternlab.patterns[0] ); - test.equals(pattern0LineageRIndex.length, 1); - test.equals(pattern0LineageRIndex[0], 'molecules-error'); + test.equal(pattern0LineageRIndex.length, 1); + test.equal(pattern0LineageRIndex[0], 'molecules-error'); test.end(); } ); -tap.test('find_lineage - finds lineage with spaced styleModifier', function( - test -) { - //setup current pattern from what we would have during execution - var currentPattern = Pattern.createEmpty({ - name: 'molecules-toast-error', - subdir: 'molecules\\toast', - filename: 'error.mustache', - data: null, - template: '{{> atoms-error:foo }}', - extendedTemplate: '{{> atoms-error:foo }}', - patternBaseName: 'error', - patternLink: 'molecules-toast-error/molecules-toast-error.html', - patternGroup: 'molecules', - patternSubgroup: 'molecules\\toast', - flatPatternPath: 'molecules\\toast', - patternPartial: 'molecules-error', - patternState: '', - lineage: [], - lineageIndex: [], - lineageR: [], - lineageRIndex: [], - }); - var patternlab = { - graph: new PatternGraph(null, 0), - patterns: [ - Pattern.createEmpty({ - name: 'atoms-alerts-error', - subdir: 'atoms\\alerts', - filename: 'error.mustache', - data: null, - template: '

{{message}}

', - extendedTemplate: '

{{message}}

', - patternBaseName: 'error', - patternLink: 'atoms-alerts-error/atoms-alerts-error.html', - patternGroup: 'atoms', - patternSubgroup: 'atoms\\alerts', - flatPatternPath: 'atoms\\alerts', - patternPartial: 'atoms-error', - patternState: '', - lineage: [], - lineageIndex: [], - lineageR: [], - lineageRIndex: [], - }), - ], - config: { - outputFileSuffixes: { - rendered: '.rendered', - rawTemplate: '', - markupOnly: '.markup-only', +tap.test( + 'find_lineage - finds lineage with spaced styleModifier', + function (test) { + //setup current pattern from what we would have during execution + var currentPattern = Pattern.createEmpty({ + name: 'molecules-toast-error', + subdir: 'molecules\\toast', + filename: 'error.mustache', + data: null, + template: '{{> atoms-error:foo }}', + extendedTemplate: '{{> atoms-error:foo }}', + patternBaseName: 'error', + patternLink: 'molecules-toast-error/molecules-toast-error.html', + patternGroup: 'molecules', + patternSubgroup: 'molecules\\toast', + flatPatternPath: 'molecules\\toast', + patternPartial: 'molecules-error', + patternState: '', + lineage: [], + lineageIndex: [], + lineageR: [], + lineageRIndex: [], + }); + var patternlab = { + graph: new PatternGraph(null, 0), + patterns: [ + Pattern.createEmpty({ + name: 'atoms-alerts-error', + subdir: 'atoms\\alerts', + filename: 'error.mustache', + data: null, + template: '

{{message}}

', + extendedTemplate: '

{{message}}

', + patternBaseName: 'error', + patternLink: 'atoms-alerts-error/atoms-alerts-error.html', + patternGroup: 'atoms', + patternSubgroup: 'atoms\\alerts', + flatPatternPath: 'atoms\\alerts', + patternPartial: 'atoms-error', + patternState: '', + lineage: [], + lineageIndex: [], + lineageR: [], + lineageRIndex: [], + }), + ], + config: { + outputFileSuffixes: { + rendered: '.rendered', + rawTemplate: '', + markupOnly: '.markup-only', + }, }, - }, - }; + }; - lineage_hunter.find_lineage(currentPattern, patternlab); + lineage_hunter.find_lineage(currentPattern, patternlab); - test.equals(currentPattern.lineageIndex.length, 1); - test.equals(currentPattern.lineageIndex[0], 'atoms-error'); + test.equal(currentPattern.lineageIndex.length, 1); + test.equal(currentPattern.lineageIndex[0], 'atoms-error'); - test.end(); -}); + test.end(); + } +); -tap.test('find_lineage - finds lineage with unspaced styleModifier', function( - test -) { - //setup current pattern from what we would have during execution - var currentPattern = Pattern.createEmpty({ - name: 'molecules-toast-error', - subdir: 'molecules\\toast', - filename: 'error.mustache', - data: null, - template: '{{> atoms-error:foo }}', - extendedTemplate: '{{>atoms-error:foo}}', - patternBaseName: 'error', - patternLink: 'molecules-toast-error/molecules-toast-error.html', - patternGroup: 'molecules', - patternSubgroup: 'molecules\\toast', - flatPatternPath: 'molecules\\toast', - patternPartial: 'molecules-error', - patternState: '', - lineage: [], - lineageIndex: [], - lineageR: [], - lineageRIndex: [], - }); - var patternlab = { - graph: PatternGraph.empty(), - patterns: [ - Pattern.createEmpty({ - name: 'atoms-alerts-error', - subdir: 'atoms\\alerts', - filename: 'error.mustache', - data: null, - template: '

{{message}}

', - extendedTemlpate: '

{{message}}

', - patternBaseName: 'error', - patternLink: 'atoms-alerts-error/atoms-alerts-error.html', - patternGroup: 'atoms', - patternSubgroup: 'atoms\\alerts', - flatPatternPath: 'atoms\\alerts', - patternPartial: 'atoms-error', - patternState: '', - lineage: [], - lineageIndex: [], - lineageR: [], - lineageRIndex: [], - }), - ], - config: { - outputFileSuffixes: { - rendered: '.rendered', - rawTemplate: '', - markupOnly: '.markup-only', +tap.test( + 'find_lineage - finds lineage with unspaced styleModifier', + function (test) { + //setup current pattern from what we would have during execution + var currentPattern = Pattern.createEmpty({ + name: 'molecules-toast-error', + subdir: 'molecules\\toast', + filename: 'error.mustache', + data: null, + template: '{{> atoms-error:foo }}', + extendedTemplate: '{{>atoms-error:foo}}', + patternBaseName: 'error', + patternLink: 'molecules-toast-error/molecules-toast-error.html', + patternGroup: 'molecules', + patternSubgroup: 'molecules\\toast', + flatPatternPath: 'molecules\\toast', + patternPartial: 'molecules-error', + patternState: '', + lineage: [], + lineageIndex: [], + lineageR: [], + lineageRIndex: [], + }); + var patternlab = { + graph: PatternGraph.empty(), + patterns: [ + Pattern.createEmpty({ + name: 'atoms-alerts-error', + subdir: 'atoms\\alerts', + filename: 'error.mustache', + data: null, + template: '

{{message}}

', + extendedTemlpate: '

{{message}}

', + patternBaseName: 'error', + patternLink: 'atoms-alerts-error/atoms-alerts-error.html', + patternGroup: 'atoms', + patternSubgroup: 'atoms\\alerts', + flatPatternPath: 'atoms\\alerts', + patternPartial: 'atoms-error', + patternState: '', + lineage: [], + lineageIndex: [], + lineageR: [], + lineageRIndex: [], + }), + ], + config: { + outputFileSuffixes: { + rendered: '.rendered', + rawTemplate: '', + markupOnly: '.markup-only', + }, }, - }, - }; + }; - lineage_hunter.find_lineage(currentPattern, patternlab); + lineage_hunter.find_lineage(currentPattern, patternlab); - test.equals(currentPattern.lineageIndex.length, 1); - test.equals(currentPattern.lineageIndex[0], 'atoms-error'); + test.equal(currentPattern.lineageIndex.length, 1); + test.equal(currentPattern.lineageIndex[0], 'atoms-error'); - test.end(); -}); + test.end(); + } +); tap.test( 'find_lineage - finds lineage with fuzzy partial with styleModifier', - function(test) { + function (test) { //setup current pattern from what we would have during execution var currentPattern = Pattern.createEmpty({ name: 'molecules-toast-error', @@ -613,14 +615,14 @@ tap.test( var lineage_hunter = new lh(); lineage_hunter.find_lineage(currentPattern, patternlab); - test.equals(currentPattern.lineageIndex.length, 1); - test.equals(currentPattern.lineageIndex[0], 'atoms-error'); + test.equal(currentPattern.lineageIndex.length, 1); + test.equal(currentPattern.lineageIndex[0], 'atoms-error'); test.end(); } ); -tap.test('find_lineage - does not apply lineage twice', function(test) { +tap.test('find_lineage - does not apply lineage twice', function (test) { //setup current pattern from what we would have during execution var currentPattern = createFakeEmptyErrorPattern(); extend(currentPattern, { @@ -663,10 +665,10 @@ tap.test('find_lineage - does not apply lineage twice', function(test) { lineage_hunter.find_lineage(currentPattern, patternlab); lineage_hunter.find_lineage(currentPattern, patternlab); - test.equals(currentPattern.lineageIndex.length, 1); - test.equals(currentPattern.lineageIndex[0], 'atoms-error'); - test.equals(patternlab.patterns[0].lineageRIndex.length, 1); - test.equals( + test.equal(currentPattern.lineageIndex.length, 1); + test.equal(currentPattern.lineageIndex[0], 'atoms-error'); + test.equal(patternlab.patterns[0].lineageRIndex.length, 1); + test.equal( patternlab.patterns[0].lineageR[0].lineagePattern, 'molecules-error' ); @@ -674,11 +676,11 @@ tap.test('find_lineage - does not apply lineage twice', function(test) { var graph = patternlab.graph; var currentPatternLineageIndex = graph.lineageIndex(currentPattern); - test.equals(currentPatternLineageIndex.length, 1); - test.equals(currentPatternLineageIndex[0], 'atoms-error'); + test.equal(currentPatternLineageIndex.length, 1); + test.equal(currentPatternLineageIndex[0], 'atoms-error'); var patternZeroLineageR = graph.lineageR(patternlab.patterns[0]); - test.equals(patternZeroLineageR.length, 1); - test.equals(patternZeroLineageR[0].patternPartial, 'molecules-error'); + test.equal(patternZeroLineageR.length, 1); + test.equal(patternZeroLineageR[0].patternPartial, 'molecules-error'); test.end(); }); diff --git a/packages/core/test/list_item_hunter_tests.js b/packages/core/test/list_item_hunter_tests.js index 516eb3468..5447f194f 100644 --- a/packages/core/test/list_item_hunter_tests.js +++ b/packages/core/test/list_item_hunter_tests.js @@ -16,7 +16,7 @@ engineLoader.loadAllEngines(config); tap.test( 'process_list_item_partials converts partial to simpler format', - test => { + (test) => { //arrange const pl = util.fakePatternLab(testPatternsPath); const listPath = path.join('test', 'list.mustache'); @@ -28,7 +28,7 @@ tap.test( //act list_item_hunter.process_list_item_partials(testPattern, pl).then(() => { //assert - test.equals( + test.equal( util.sanitized(testPattern.extendedTemplate), util.sanitized(` {{#listItems-three}} @@ -43,7 +43,7 @@ tap.test( tap.test( 'process_list_item_partials converts partial with includes to simpler format', - test => { + (test) => { //arrange const pl = util.fakePatternLab(testPatternsPath); const listPath = path.join('test', 'listWithPartial.mustache'); @@ -55,7 +55,7 @@ tap.test( //act list_item_hunter.process_list_item_partials(testPattern, pl).then(() => { //assert - test.equals( + test.equal( util.sanitized(testPattern.extendedTemplate), util.sanitized(` {{#listItems-two}} diff --git a/packages/core/test/loadPattern_tests.js b/packages/core/test/loadPattern_tests.js index 00643666e..d2903a6c0 100644 --- a/packages/core/test/loadPattern_tests.js +++ b/packages/core/test/loadPattern_tests.js @@ -12,20 +12,23 @@ patternEngines.loadAllEngines(config); const patterns_dir = `${__dirname}/files/_patterns`; -tap.test('loadPattern - returns null if file is not a pattern', function(test) { - //arrange - const patternlab = util.fakePatternLab(patterns_dir); - var patternPath = path.join('test', 'styled-atom.json'); +tap.test( + 'loadPattern - returns null if file is not a pattern', + function (test) { + //arrange + const patternlab = util.fakePatternLab(patterns_dir); + var patternPath = path.join('test', 'styled-atom.json'); - //act - var result = loadPattern(patternPath, patternlab); + //act + var result = loadPattern(patternPath, patternlab); - //assert - test.equals(result, null); - test.end(); -}); + //assert + test.equal(result, null); + test.end(); + } +); -tap.test('loadPattern - loads pattern sibling json if found', function(test) { +tap.test('loadPattern - loads pattern sibling json if found', function (test) { //arrange const patternlab = util.fakePatternLab(patterns_dir); var patternPath = path.join('test', 'styled-atom.mustache'); @@ -34,13 +37,13 @@ tap.test('loadPattern - loads pattern sibling json if found', function(test) { var result = loadPattern(patternPath, patternlab); //assert - test.equals(result.jsonFileData.message, 'baseMessage'); + test.equal(result.jsonFileData.message, 'baseMessage'); test.end(); }); tap.test( 'loadPattern - adds the pattern to the patternlab.partials object', - function(test) { + function (test) { //arrange const patternlab = util.fakePatternLab(patterns_dir); var fooPatternPath = path.join('test', 'bar.mustache'); @@ -49,25 +52,26 @@ tap.test( var result = loadPattern(fooPatternPath, patternlab); //assert - test.equals(util.sanitized(patternlab.partials['test-bar']), 'bar'); + test.equal(util.sanitized(patternlab.partials['test-bar']), 'bar'); test.end(); } ); -tap.test('loadPattern - returns pattern with template populated', function( - test -) { - //arrange - const patternlab = util.fakePatternLab(patterns_dir); - var fooPatternPath = path.join('test', 'bar.mustache'); +tap.test( + 'loadPattern - returns pattern with template populated', + function (test) { + //arrange + const patternlab = util.fakePatternLab(patterns_dir); + var fooPatternPath = path.join('test', 'bar.mustache'); - //act - var result = loadPattern(fooPatternPath, patternlab); + //act + var result = loadPattern(fooPatternPath, patternlab); - //assert - test.equals(util.sanitized(result.template), util.sanitized('bar')); - test.end(); -}); + //assert + test.equal(util.sanitized(result.template), util.sanitized('bar')); + test.end(); + } +); // TODO: Fix doc pattern test when new logic in loadPattern is implemented // tap.test('loadPattern - adds a markdown pattern if encountered', function( @@ -83,21 +87,21 @@ tap.test('loadPattern - returns pattern with template populated', function( // //assert // const subgroupPattern = // patternlab.subgroupPatterns['patternGroup1-patternSubgroup1']; -// test.equals(subgroupPattern.patternSectionSubgroup, true); -// test.equals(subgroupPattern.isPattern, false); -// test.equals(subgroupPattern.patternDesc, '

Colors

\n'); -// test.equals(subgroupPattern.engine, null); -// test.equals( +// test.equal(subgroupPattern.patternSectionSubgroup, true); +// test.equal(subgroupPattern.isPattern, false); +// test.equal(subgroupPattern.patternDesc, '

Colors

\n'); +// test.equal(subgroupPattern.engine, null); +// test.equal( // subgroupPattern.flatPatternPath, // 'patternGroup1-patternSubgroup1' // ); -// test.equals(result, subgroupPattern); +// test.equal(result, subgroupPattern); // test.end(); // }); tap.test( 'loadPattern - does not load pseudopattern data on the base pattern', - test => { + (test) => { //arrange const patternlab = util.fakePatternLab(patterns_dir); const basePatternPath = path.join('test', 'pseudomodifier.mustache'); @@ -114,7 +118,7 @@ tap.test( tap.test( 'loadPattern - group and subgroup ordering will be taken from markdown files', - test => { + (test) => { //arrange const patternlab = util.fakePatternLab(patterns_dir); diff --git a/packages/core/test/loaduitkits_tests.js b/packages/core/test/loaduitkits_tests.js index 7cdc16401..a4cf2bd3b 100644 --- a/packages/core/test/loaduitkits_tests.js +++ b/packages/core/test/loaduitkits_tests.js @@ -9,7 +9,7 @@ const loaduikits = rewire('../src/lib/loaduikits'); const testConfig = require('./util/patternlab-config.json'); -tap.test('loaduikits - does warn on missing package property', test => { +tap.test('loaduikits - does warn on missing package property', (test) => { //arrange const patternlab = { config: testConfig, @@ -17,7 +17,7 @@ tap.test('loaduikits - does warn on missing package property', test => { }; patternlab.config.logLevel = 'warning'; - logger.log.on('warning', msg => test.ok(msg.includes('package:'))); + logger.log.on('warning', (msg) => test.ok(msg.includes('package:'))); //act loaduikits(patternlab).then(() => { @@ -26,7 +26,7 @@ tap.test('loaduikits - does warn on missing package property', test => { }); }); -tap.test('loaduikits - maps fields correctly', function(test) { +tap.test('loaduikits - maps fields correctly', function (test) { //arrange const patternlab = { config: testConfig, @@ -36,8 +36,8 @@ tap.test('loaduikits - maps fields correctly', function(test) { //act loaduikits(patternlab).then(() => { //assert - test.equals(patternlab.uikits['uikit-workshop'].name, 'uikit-workshop'); - test.equals( + test.equal(patternlab.uikits['uikit-workshop'].name, 'uikit-workshop'); + test.equal( patternlab.uikits['uikit-workshop'].package, '@pattern-lab/uikit-workshop' ); @@ -46,7 +46,7 @@ tap.test('loaduikits - maps fields correctly', function(test) { path.join('packages', 'uikit-workshop') ); test.ok(patternlab.uikits['uikit-workshop'].enabled); - test.equals(patternlab.uikits['uikit-workshop'].outputDir, 'test/'); + test.equal(patternlab.uikits['uikit-workshop'].outputDir, 'test/'); test.deepEquals(patternlab.uikits['uikit-workshop'].excludedPatternStates, [ 'legacy', ]); @@ -55,7 +55,7 @@ tap.test('loaduikits - maps fields correctly', function(test) { }); }); -tap.test('loaduikits - only adds files for enabled uikits', function(test) { +tap.test('loaduikits - only adds files for enabled uikits', function (test) { //arrange const patternlab = { config: testConfig, diff --git a/packages/core/test/markModifiedPatterns_tests.js b/packages/core/test/markModifiedPatterns_tests.js index 432937ef8..18f06d646 100644 --- a/packages/core/test/markModifiedPatterns_tests.js +++ b/packages/core/test/markModifiedPatterns_tests.js @@ -13,7 +13,7 @@ const markModifiedPatterns = rewire('../src/lib/markModifiedPatterns'); const config = require('./util/patternlab-config.json'); const fsMock = { - readFileSync: function(path, encoding, cb) { + readFileSync: function (path, encoding, cb) { return ''; }, }; @@ -28,7 +28,7 @@ const public_dir = './test/public'; tap.only( 'markModifiedPatterns - finds patterns modified since a given date', - function(test) { + function (test) { //arrange markModifiedPatterns.__set__('fs', fsMock); @@ -75,7 +75,7 @@ tap.only( tap.test( 'markModifiedPatterns - finds patterns when modification date is missing', - function(test) { + function (test) { //arrange var patternlab = emptyPatternLab(); patternlab.partials = {}; @@ -96,24 +96,25 @@ tap.test( ); // This is the case when we want to force recompilation -tap.test('markModifiedPatterns - finds patterns via compile state', function( - test -) { - //arrange - var patternlab = emptyPatternLab(); - patternlab.partials = {}; - patternlab.data = { link: {} }; - patternlab.config = { logLevel: 'quiet' }; - patternlab.config.outputFileSuffixes = { rendered: '' }; - - var pattern = new Pattern('test/bar.mustache'); - pattern.extendedTemplate = undefined; - pattern.template = 'bar'; - pattern.lastModified = 100000; - pattern.compileState = CompileState.NEEDS_REBUILD; - patternlab.patterns = [pattern]; - - let p = markModifiedPatterns(1000, patternlab); - test.same(p.modified.length, 1); - test.end(); -}); +tap.test( + 'markModifiedPatterns - finds patterns via compile state', + function (test) { + //arrange + var patternlab = emptyPatternLab(); + patternlab.partials = {}; + patternlab.data = { link: {} }; + patternlab.config = { logLevel: 'quiet' }; + patternlab.config.outputFileSuffixes = { rendered: '' }; + + var pattern = new Pattern('test/bar.mustache'); + pattern.extendedTemplate = undefined; + pattern.template = 'bar'; + pattern.lastModified = 100000; + pattern.compileState = CompileState.NEEDS_REBUILD; + patternlab.patterns = [pattern]; + + let p = markModifiedPatterns(1000, patternlab); + test.same(p.modified.length, 1); + test.end(); + } +); diff --git a/packages/core/test/markdown_parser_tests.js b/packages/core/test/markdown_parser_tests.js index dbd9673c8..717f5b27f 100644 --- a/packages/core/test/markdown_parser_tests.js +++ b/packages/core/test/markdown_parser_tests.js @@ -9,7 +9,7 @@ var markdown_parser = new mp(); tap.test( 'parses pattern description block correctly when frontmatter not present', - function(test) { + function (test) { //arrange var markdownFileName = path.resolve( `${__dirname}/files/_patterns/test/baz.md` @@ -20,14 +20,14 @@ tap.test( var returnObject = markdown_parser.parse(markdownFileContents); //assert - test.equals(returnObject.markdown, '

Only baz

\n'); + test.equal(returnObject.markdown, '

Only baz

\n'); test.end(); } ); tap.test( 'parses pattern description block correctly when frontmatter present', - function(test) { + function (test) { //arrange var markdownFileName = path.resolve( `${__dirname}/files/_patterns/test/bar.md` @@ -38,16 +38,16 @@ tap.test( var returnObject = markdown_parser.parse(markdownFileContents); //assert - test.equals( + test.equal( returnObject.markdown, '

A Simple Bit of Markup

\n

Foo cannot get simpler than bar, amiright?

\n' ); - test.equals(returnObject.state, 'complete'); + test.equal(returnObject.state, 'complete'); test.end(); } ); -tap.test('parses frontmatter only when no markdown present', function(test) { +tap.test('parses frontmatter only when no markdown present', function (test) { //arrange var markdownFileName = path.resolve( `${__dirname}/files/_patterns/test/styled-atom.md` @@ -58,7 +58,7 @@ tap.test('parses frontmatter only when no markdown present', function(test) { var returnObject = markdown_parser.parse(markdownFileContents); //assert - test.equals(returnObject.markdown, ''); - test.equals(returnObject.state, 'inprogress'); + test.equal(returnObject.markdown, ''); + test.equal(returnObject.state, 'inprogress'); test.end(); }); diff --git a/packages/core/test/object_factory_tests.js b/packages/core/test/object_factory_tests.js index 435a3c936..6684628df 100644 --- a/packages/core/test/object_factory_tests.js +++ b/packages/core/test/object_factory_tests.js @@ -30,44 +30,44 @@ var pl = fakePatternLab(); var engineLoader = require('../src/lib/pattern_engines'); engineLoader.loadAllEngines(config); -tap.test('test Pattern initializes correctly', function(test) { +tap.test('test Pattern initializes correctly', function (test) { var p = new Pattern('atoms/global/colors.mustache', { d: 123 }); - test.equals( + test.equal( p.relPath, 'atoms' + path.sep + 'global' + path.sep + 'colors.mustache' ); - test.equals(p.name, 'atoms-global-colors'); - test.equals(p.subdir, 'atoms' + path.sep + 'global'); - test.equals(p.fileName, 'colors'); - test.equals(p.fileExtension, '.mustache'); - test.equals(p.jsonFileData.d, 123); - test.equals(p.patternBaseName, 'colors'); - test.equals(p.patternName, 'Colors'); - test.equals( + test.equal(p.name, 'atoms-global-colors'); + test.equal(p.subdir, 'atoms' + path.sep + 'global'); + test.equal(p.fileName, 'colors'); + test.equal(p.fileExtension, '.mustache'); + test.equal(p.jsonFileData.d, 123); + test.equal(p.patternBaseName, 'colors'); + test.equal(p.patternName, 'Colors'); + test.equal( p.getPatternLink(pl), 'atoms-global-colors' + path.sep + 'atoms-global-colors.rendered.html' ); - test.equals(p.patternGroup, 'atoms'); - test.equals(p.patternSubgroup, 'global'); - test.equals(p.flatPatternPath, 'atoms-global'); - test.equals(p.patternPartial, 'atoms-colors'); - test.equals(p.template, ''); - test.equals(p.patternPartialCode, ''); - test.equals(p.lineage.length, 0); - test.equals(p.lineageIndex.length, 0); - test.equals(p.lineageR.length, 0); - test.equals(p.lineageRIndex.length, 0); - test.equals(p.patternState, ''); + test.equal(p.patternGroup, 'atoms'); + test.equal(p.patternSubgroup, 'global'); + test.equal(p.flatPatternPath, 'atoms-global'); + test.equal(p.patternPartial, 'atoms-colors'); + test.equal(p.template, ''); + test.equal(p.patternPartialCode, ''); + test.equal(p.lineage.length, 0); + test.equal(p.lineageIndex.length, 0); + test.equal(p.lineageR.length, 0); + test.equal(p.lineageRIndex.length, 0); + test.equal(p.patternState, ''); test.end(); }); tap.test( 'test Pattern initializes correctly with pattern in sepatated directory', - function(test) { + function (test) { var p = new Pattern('atoms/global/colors/colors.mustache', { d: 123, }); - test.equals( + test.equal( p.relPath, 'atoms' + path.sep + @@ -77,245 +77,254 @@ tap.test( path.sep + 'colors.mustache' ); - test.equals(p.name, 'atoms-global-colors'); - test.equals(p.subdir, path.join('atoms', 'global', 'colors')); - test.equals(p.fileName, 'colors'); - test.equals(p.fileExtension, '.mustache'); - test.equals(p.jsonFileData.d, 123); - test.equals(p.patternBaseName, 'colors'); - test.equals(p.patternName, 'Colors'); - test.equals( + test.equal(p.name, 'atoms-global-colors'); + test.equal(p.subdir, path.join('atoms', 'global', 'colors')); + test.equal(p.fileName, 'colors'); + test.equal(p.fileExtension, '.mustache'); + test.equal(p.jsonFileData.d, 123); + test.equal(p.patternBaseName, 'colors'); + test.equal(p.patternName, 'Colors'); + test.equal( p.getPatternLink(pl), 'atoms-global-colors' + path.sep + 'atoms-global-colors.rendered.html' ); - test.equals(p.patternGroup, 'atoms'); - test.equals(p.patternSubgroup, 'global'); - test.equals(p.flatPatternPath, 'atoms-global'); - test.equals(p.patternPartial, 'atoms-colors'); - test.equals(p.template, ''); - test.equals(p.patternPartialCode, ''); - test.equals(p.lineage.length, 0); - test.equals(p.lineageIndex.length, 0); - test.equals(p.lineageR.length, 0); - test.equals(p.lineageRIndex.length, 0); - test.equals(p.patternState, ''); + test.equal(p.patternGroup, 'atoms'); + test.equal(p.patternSubgroup, 'global'); + test.equal(p.flatPatternPath, 'atoms-global'); + test.equal(p.patternPartial, 'atoms-colors'); + test.equal(p.template, ''); + test.equal(p.patternPartialCode, ''); + test.equal(p.lineage.length, 0); + test.equal(p.lineageIndex.length, 0); + test.equal(p.lineageR.length, 0); + test.equal(p.lineageRIndex.length, 0); + test.equal(p.patternState, ''); test.end(); } ); -tap.test('test Pattern name for variants correctly initialzed', function(test) { - var p1 = new Pattern('atoms/global/colors/colors~variant.mustache', { - d: 123, - }); - var p2 = new Pattern('atoms/global/colors/colors~variant-minus.json', { - d: 123, - }); - test.equals(p1.name, 'atoms-global-colors-variant'); - test.equals(p2.name, 'atoms-global-colors-variant-minus'); - test.end(); -}); +tap.test( + 'test Pattern name for variants correctly initialzed', + function (test) { + var p1 = new Pattern('atoms/global/colors/colors~variant.mustache', { + d: 123, + }); + var p2 = new Pattern('atoms/global/colors/colors~variant-minus.json', { + d: 123, + }); + test.equal(p1.name, 'atoms-global-colors-variant'); + test.equal(p2.name, 'atoms-global-colors-variant-minus'); + test.end(); + } +); -tap.test('test Pattern with one-directory subdir works as expected', function( - test -) { - var p = new Pattern('atoms/colors.mustache', { d: 123 }); - test.equals(p.relPath, 'atoms' + path.sep + 'colors.mustache'); - test.equals(p.name, 'atoms-colors'); - test.equals(p.subdir, 'atoms'); - test.equals(p.fileName, 'colors'); - test.equals(p.fileExtension, '.mustache'); - test.equals(p.jsonFileData.d, 123); - test.equals(p.patternBaseName, 'colors'); - test.equals(p.patternName, 'Colors'); - test.equals( - p.getPatternLink(pl), - 'atoms-colors' + path.sep + 'atoms-colors.rendered.html' - ); - test.equals(p.patternGroup, 'atoms'); - test.equals(p.flatPatternPath, 'atoms'); - test.equals(p.patternPartial, 'atoms-colors'); - test.equals(p.template, ''); - test.equals(p.lineage.length, 0); - test.equals(p.lineageIndex.length, 0); - test.equals(p.lineageR.length, 0); - test.equals(p.lineageRIndex.length, 0); - test.end(); -}); +tap.test( + 'test Pattern with one-directory subdir works as expected', + function (test) { + var p = new Pattern('atoms/colors.mustache', { d: 123 }); + test.equal(p.relPath, 'atoms' + path.sep + 'colors.mustache'); + test.equal(p.name, 'atoms-colors'); + test.equal(p.subdir, 'atoms'); + test.equal(p.fileName, 'colors'); + test.equal(p.fileExtension, '.mustache'); + test.equal(p.jsonFileData.d, 123); + test.equal(p.patternBaseName, 'colors'); + test.equal(p.patternName, 'Colors'); + test.equal( + p.getPatternLink(pl), + 'atoms-colors' + path.sep + 'atoms-colors.rendered.html' + ); + test.equal(p.patternGroup, 'atoms'); + test.equal(p.flatPatternPath, 'atoms'); + test.equal(p.patternPartial, 'atoms-colors'); + test.equal(p.template, ''); + test.equal(p.lineage.length, 0); + test.equal(p.lineageIndex.length, 0); + test.equal(p.lineageR.length, 0); + test.equal(p.lineageRIndex.length, 0); + test.end(); + } +); -tap.test('test Pattern with own-directory gets resetted as expected', function( - test -) { - var p = new Pattern('atoms/button/button.mustache', { d: 123 }, pl); - p.promoteFromDirectoryToFlatPattern(pl); +tap.test( + 'test Pattern with own-directory gets resetted as expected', + function (test) { + var p = new Pattern('atoms/button/button.mustache', { d: 123 }, pl); + p.promoteFromDirectoryToFlatPattern(pl); - test.equals(p.relPath, path.join('atoms', 'button', 'button.mustache')); - test.equals(p.name, 'atoms-button'); - test.equals(p.subdir, path.join('atoms', 'button')); - test.equals(p.fileName, 'button'); - test.equals(p.fileExtension, '.mustache'); - test.equals(p.jsonFileData.d, 123); - test.equals(p.patternBaseName, 'button'); - test.equals(p.patternName, 'Button'); - test.equals( - p.getPatternLink(pl), - path.join('atoms-button', 'atoms-button.rendered.html') - ); - test.equals(p.patternGroup, 'atoms'); - test.equals(p.flatPatternPath, 'atoms'); - test.equals(p.patternPartial, 'atoms-button'); - test.equals(p.template, ''); - test.equals(p.lineage.length, 0); - test.equals(p.lineageIndex.length, 0); - test.equals(p.lineageR.length, 0); - test.equals(p.lineageRIndex.length, 0); - test.end(); -}); + test.equal(p.relPath, path.join('atoms', 'button', 'button.mustache')); + test.equal(p.name, 'atoms-button'); + test.equal(p.subdir, path.join('atoms', 'button')); + test.equal(p.fileName, 'button'); + test.equal(p.fileExtension, '.mustache'); + test.equal(p.jsonFileData.d, 123); + test.equal(p.patternBaseName, 'button'); + test.equal(p.patternName, 'Button'); + test.equal( + p.getPatternLink(pl), + path.join('atoms-button', 'atoms-button.rendered.html') + ); + test.equal(p.patternGroup, 'atoms'); + test.equal(p.flatPatternPath, 'atoms'); + test.equal(p.patternPartial, 'atoms-button'); + test.equal(p.template, ''); + test.equal(p.lineage.length, 0); + test.equal(p.lineageIndex.length, 0); + test.equal(p.lineageR.length, 0); + test.equal(p.lineageRIndex.length, 0); + test.end(); + } +); tap.test( 'test Pattern with no numbers in pattern group works as expected', - function(test) { + function (test) { var p = new Pattern('atoms/colors.mustache', { d: 123 }); - test.equals(p.relPath, 'atoms' + path.sep + 'colors.mustache'); - test.equals(p.name, 'atoms-colors'); - test.equals(p.subdir, 'atoms'); - test.equals(p.fileName, 'colors'); - test.equals( + test.equal(p.relPath, 'atoms' + path.sep + 'colors.mustache'); + test.equal(p.name, 'atoms-colors'); + test.equal(p.subdir, 'atoms'); + test.equal(p.fileName, 'colors'); + test.equal( p.getPatternLink(pl), 'atoms-colors' + path.sep + 'atoms-colors.rendered.html' ); - test.equals(p.patternGroup, 'atoms'); - test.equals(p.flatPatternPath, 'atoms'); - test.equals(p.patternPartial, 'atoms-colors'); + test.equal(p.patternGroup, 'atoms'); + test.equal(p.flatPatternPath, 'atoms'); + test.equal(p.patternPartial, 'atoms-colors'); test.end(); } ); -tap.test('test Pattern capitalizes patternDisplayName correctly', function( - test -) { - var p = new Pattern('atoms/global/colors-alt.mustache', { d: 123 }); - test.equals(p.patternBaseName, 'colors-alt'); - test.equals(p.patternName, 'Colors Alt'); - test.end(); -}); +tap.test( + 'test Pattern capitalizes patternDisplayName correctly', + function (test) { + var p = new Pattern('atoms/global/colors-alt.mustache', { d: 123 }); + test.equal(p.patternBaseName, 'colors-alt'); + test.equal(p.patternName, 'Colors Alt'); + test.end(); + } +); -tap.test('test Pattern get dir level no separated pattern directory', function( - test -) { - var p = new Pattern('atoms/global/colors-alt.mustache', { d: 123 }); - console.log(p); - test.equals(p.getDirLevel(0, { patternHasOwnDir: false }), 'atoms'); - test.equals(p.getDirLevel(1, { patternHasOwnDir: false }), 'global'); - test.equals(p.getDirLevel(2, { patternHasOwnDir: false }), ''); // There is no third level - var p = new Pattern('atoms/colors-alt.mustache', { d: 123 }); - test.equals(p.getDirLevel(0, { patternHasOwnDir: false }), 'atoms'); - test.equals(p.getDirLevel(1, { patternHasOwnDir: false }), ''); // There is no second level - test.equals(p.getDirLevel(2, { patternHasOwnDir: false }), ''); // There is no third level - var p = new Pattern('colors-alt.mustache', { d: 123 }); - test.equals(p.getDirLevel(0, { patternHasOwnDir: false }), 'root'); // No first level means root - test.equals(p.getDirLevel(1, { patternHasOwnDir: false }), ''); // There is no second level - test.equals(p.getDirLevel(2, { patternHasOwnDir: false }), ''); // There is no third leveL - test.end(); -}); +tap.test( + 'test Pattern get dir level no separated pattern directory', + function (test) { + var p = new Pattern('atoms/global/colors-alt.mustache', { d: 123 }); + console.log(p); + test.equal(p.getDirLevel(0, { patternHasOwnDir: false }), 'atoms'); + test.equal(p.getDirLevel(1, { patternHasOwnDir: false }), 'global'); + test.equal(p.getDirLevel(2, { patternHasOwnDir: false }), ''); // There is no third level + var p = new Pattern('atoms/colors-alt.mustache', { d: 123 }); + test.equal(p.getDirLevel(0, { patternHasOwnDir: false }), 'atoms'); + test.equal(p.getDirLevel(1, { patternHasOwnDir: false }), ''); // There is no second level + test.equal(p.getDirLevel(2, { patternHasOwnDir: false }), ''); // There is no third level + var p = new Pattern('colors-alt.mustache', { d: 123 }); + test.equal(p.getDirLevel(0, { patternHasOwnDir: false }), 'root'); // No first level means root + test.equal(p.getDirLevel(1, { patternHasOwnDir: false }), ''); // There is no second level + test.equal(p.getDirLevel(2, { patternHasOwnDir: false }), ''); // There is no third leveL + test.end(); + } +); tap.test( 'test Pattern get dir level with separated pattern directory', - function(test) { + function (test) { var p = new Pattern('atoms/global/colors-alt/colors-alt.mustache', { d: 123, }); - test.equals(p.getDirLevel(0, { patternHasOwnDir: true }), 'atoms'); - test.equals(p.getDirLevel(1, { patternHasOwnDir: true }), 'global'); - test.equals(p.getDirLevel(2, { patternHasOwnDir: true }), ''); // There is no third level + test.equal(p.getDirLevel(0, { patternHasOwnDir: true }), 'atoms'); + test.equal(p.getDirLevel(1, { patternHasOwnDir: true }), 'global'); + test.equal(p.getDirLevel(2, { patternHasOwnDir: true }), ''); // There is no third level var p = new Pattern('atoms/colors-alt/colors-alt.mustache', { d: 123, }); - test.equals(p.getDirLevel(0, { patternHasOwnDir: true }), 'atoms'); - test.equals(p.getDirLevel(1, { patternHasOwnDir: true }), ''); // There is no second level - test.equals(p.getDirLevel(2, { patternHasOwnDir: true }), ''); // There is no third level + test.equal(p.getDirLevel(0, { patternHasOwnDir: true }), 'atoms'); + test.equal(p.getDirLevel(1, { patternHasOwnDir: true }), ''); // There is no second level + test.equal(p.getDirLevel(2, { patternHasOwnDir: true }), ''); // There is no third level var p = new Pattern('colors-alt/colors-alt.mustache', { d: 123 }); - test.equals(p.getDirLevel(0, { patternHasOwnDir: true }), 'root'); // No first level means root - test.equals(p.getDirLevel(1, { patternHasOwnDir: true }), ''); // There is no second level - test.equals(p.getDirLevel(2, { patternHasOwnDir: true }), ''); // There is no third leveL + test.equal(p.getDirLevel(0, { patternHasOwnDir: true }), 'root'); // No first level means root + test.equal(p.getDirLevel(1, { patternHasOwnDir: true }), ''); // There is no second level + test.equal(p.getDirLevel(2, { patternHasOwnDir: true }), ''); // There is no third leveL var p = new Pattern('atoms/global/colors-alt/colors-alt~variant.mustache', { d: 123, }); - test.equals(p.name, 'atoms-global-colors-alt-variant'); - test.equals(p.flatPatternPath, 'atoms-global'); - test.equals(p.patternBaseName, 'colors-alt-variant'); + test.equal(p.name, 'atoms-global-colors-alt-variant'); + test.equal(p.flatPatternPath, 'atoms-global'); + test.equal(p.patternBaseName, 'colors-alt-variant'); test.end(); } ); -tap.test('test Patterns that are nested deeper without own directory', function( - test -) { - var p = new Pattern('atoms/global/random-folder/colors-alt.mustache', { - d: 123, - }); - test.equals(p.name, 'atoms-global-colors-alt'); - test.equals(p.flatPatternPath, 'atoms-global'); - - var p = new Pattern( - 'atoms/global/random-folder/another-folder/colors-alt.mustache', - { +tap.test( + 'test Patterns that are nested deeper without own directory', + function (test) { + var p = new Pattern('atoms/global/random-folder/colors-alt.mustache', { d: 123, - } - ); - test.equals(p.name, 'atoms-global-colors-alt'); - test.equals(p.flatPatternPath, 'atoms-global'); + }); + test.equal(p.name, 'atoms-global-colors-alt'); + test.equal(p.flatPatternPath, 'atoms-global'); - var p = new Pattern( - 'atoms/global/random-folder/another-folder/some-folder/colors-alt.mustache', - { d: 123 } - ); - test.equals(p.name, 'atoms-global-colors-alt'); - test.equals(p.flatPatternPath, 'atoms-global'); + var p = new Pattern( + 'atoms/global/random-folder/another-folder/colors-alt.mustache', + { + d: 123, + } + ); + test.equal(p.name, 'atoms-global-colors-alt'); + test.equal(p.flatPatternPath, 'atoms-global'); - var p = new Pattern( - 'atoms/global/random-folder/another-folder/colors-alt/colors-alt.mustache', - { d: 123 } - ); - test.equals(p.name, 'atoms-global-colors-alt'); - test.equals(p.flatPatternPath, 'atoms-global'); + var p = new Pattern( + 'atoms/global/random-folder/another-folder/some-folder/colors-alt.mustache', + { d: 123 } + ); + test.equal(p.name, 'atoms-global-colors-alt'); + test.equal(p.flatPatternPath, 'atoms-global'); - var p = new Pattern( - 'atoms/global/random-folder/another-folder/some-folder/colors-alt~variant.mustache', - { d: 123 } - ); - test.equals(p.name, 'atoms-global-colors-alt-variant'); - test.equals(p.flatPatternPath, 'atoms-global'); - test.equals(p.patternBaseName, 'colors-alt-variant'); - test.end(); -}); + var p = new Pattern( + 'atoms/global/random-folder/another-folder/colors-alt/colors-alt.mustache', + { d: 123 } + ); + test.equal(p.name, 'atoms-global-colors-alt'); + test.equal(p.flatPatternPath, 'atoms-global'); -tap.test('The forms of Pattern.getPatternLink() work as expected', function( - test -) { - var p = new Pattern('atoms/global/colors.hbs'); - test.equals( - p.getPatternLink(pl), - 'atoms-global-colors' + path.sep + 'atoms-global-colors.rendered.html' - ); - test.equals( - p.getPatternLink(pl, 'rendered'), - 'atoms-global-colors' + path.sep + 'atoms-global-colors.rendered.html' - ); - test.equals( - p.getPatternLink(pl, 'rawTemplate'), - 'atoms-global-colors' + path.sep + 'atoms-global-colors.hbs' - ); - test.equals( - p.getPatternLink(pl, 'markupOnly'), - 'atoms-global-colors' + path.sep + 'atoms-global-colors.markup-only.html' - ); - test.equals( - p.getPatternLink(pl, 'custom', '.custom-extension'), - 'atoms-global-colors' + path.sep + 'atoms-global-colors.custom-extension' - ); - test.end(); -}); + var p = new Pattern( + 'atoms/global/random-folder/another-folder/some-folder/colors-alt~variant.mustache', + { d: 123 } + ); + test.equal(p.name, 'atoms-global-colors-alt-variant'); + test.equal(p.flatPatternPath, 'atoms-global'); + test.equal(p.patternBaseName, 'colors-alt-variant'); + test.end(); + } +); + +tap.test( + 'The forms of Pattern.getPatternLink() work as expected', + function (test) { + var p = new Pattern('atoms/global/colors.hbs'); + test.equal( + p.getPatternLink(pl), + 'atoms-global-colors' + path.sep + 'atoms-global-colors.rendered.html' + ); + test.equal( + p.getPatternLink(pl, 'rendered'), + 'atoms-global-colors' + path.sep + 'atoms-global-colors.rendered.html' + ); + test.equal( + p.getPatternLink(pl, 'rawTemplate'), + 'atoms-global-colors' + path.sep + 'atoms-global-colors.hbs' + ); + test.equal( + p.getPatternLink(pl, 'markupOnly'), + 'atoms-global-colors' + path.sep + 'atoms-global-colors.markup-only.html' + ); + test.equal( + p.getPatternLink(pl, 'custom', '.custom-extension'), + 'atoms-global-colors' + path.sep + 'atoms-global-colors.custom-extension' + ); + test.end(); + } +); diff --git a/packages/core/test/parameter_hunter_tests.js b/packages/core/test/parameter_hunter_tests.js index fad796212..b19314d10 100644 --- a/packages/core/test/parameter_hunter_tests.js +++ b/packages/core/test/parameter_hunter_tests.js @@ -16,7 +16,7 @@ engineLoader.loadAllEngines(config); const testPatternsPath = path.resolve(__dirname, 'files', '_patterns'); -tap.test('parameter hunter finds and extends templates', function(test) { +tap.test('parameter hunter finds and extends templates', function (test) { //arrange const pl = util.fakePatternLab(testPatternsPath); @@ -36,7 +36,7 @@ tap.test('parameter hunter finds and extends templates', function(test) { .find_parameters(testPattern, pl) .then(() => { //assert - test.equals( + test.equal( util.sanitized(testPattern.extendedTemplate), util.sanitized( '

{{foo}}

A life is like a garden. Perfect moments can be had, but not preserved, except in memory.

' @@ -51,7 +51,7 @@ tap.test('parameter hunter finds and extends templates', function(test) { tap.test( 'parameter hunter finds and extends templates with verbose partials', - function(test) { + function (test) { //arrange const pl = util.fakePatternLab(testPatternsPath); @@ -71,7 +71,7 @@ tap.test( .find_parameters(testPattern, pl) .then(() => { //assert - test.equals( + test.equal( util.sanitized(testPattern.extendedTemplate), util.sanitized( '

{{foo}}

A life is like a garden. Perfect moments can be had, but not preserved, except in memory.

' @@ -89,7 +89,7 @@ tap.test( //test other quoting options. tap.test( 'parameter hunter parses parameters with unquoted keys and unquoted values', - function(test) { + function (test) { //arrange const pl = util.fakePatternLab(testPatternsPath); @@ -111,7 +111,7 @@ tap.test( //act parameter_hunter.find_parameters(testPattern, pl).then(() => { //assert - test.equals( + test.equal( util.sanitized(testPattern.extendedTemplate), util.sanitized('

{{foo}}

true

') ); @@ -123,7 +123,7 @@ tap.test( tap.test( 'parameter hunter parses parameters with unquoted keys and double-quoted values', - function(test) { + function (test) { //arrange const pl = util.fakePatternLab(testPatternsPath); @@ -145,7 +145,7 @@ tap.test( //act parameter_hunter.find_parameters(testPattern, pl).then(() => { //assert - test.equals( + test.equal( util.sanitized(testPattern.extendedTemplate), util.sanitized('

{{foo}}

true

') ); @@ -157,7 +157,7 @@ tap.test( tap.test( 'parameter hunter parses parameters with single-quoted keys and unquoted values', - function(test) { + function (test) { //arrange const pl = util.fakePatternLab(testPatternsPath); @@ -179,7 +179,7 @@ tap.test( //act parameter_hunter.find_parameters(testPattern, pl).then(() => { //assert - test.equals( + test.equal( util.sanitized(testPattern.extendedTemplate), util.sanitized('

{{foo}}

true

') ); @@ -191,7 +191,7 @@ tap.test( tap.test( 'parameter hunter parses parameters with single-quoted keys and single-quoted values wrapping internal escaped single-quotes', - function(test) { + function (test) { //arrange const pl = util.fakePatternLab(testPatternsPath); @@ -214,7 +214,7 @@ tap.test( //act parameter_hunter.find_parameters(testPattern, pl).then(() => { //assert - test.equals( + test.equal( util.sanitized(testPattern.extendedTemplate), util.sanitized(`

{{foo}}

true not,'true'

`) ); @@ -226,7 +226,7 @@ tap.test( tap.test( 'parameter hunter parses parameters with single-quoted keys and double-quoted values wrapping internal single-quotes', - function(test) { + function (test) { //arrange const pl = util.fakePatternLab(testPatternsPath); @@ -249,7 +249,7 @@ tap.test( //act parameter_hunter.find_parameters(testPattern, pl).then(() => { //assert - test.equals( + test.equal( util.sanitized(testPattern.extendedTemplate), util.sanitized(`

{{foo}}

true not:'true'

`) ); @@ -261,7 +261,7 @@ tap.test( tap.test( 'parameter hunter parses parameters with double-unquoted keys and unquoted values', - function(test) { + function (test) { //arrange const pl = util.fakePatternLab(testPatternsPath); @@ -283,7 +283,7 @@ tap.test( //act parameter_hunter.find_parameters(testPattern, pl).then(() => { //assert - test.equals( + test.equal( util.sanitized(testPattern.extendedTemplate), util.sanitized('

{{foo}}

true

') ); @@ -295,7 +295,7 @@ tap.test( tap.test( 'parameter hunter parses parameters with double-quoted keys and single-quoted values wrapping internal double-quotes', - function(test) { + function (test) { //arrange const pl = util.fakePatternLab(testPatternsPath); @@ -318,7 +318,7 @@ tap.test( //act parameter_hunter.find_parameters(testPattern, pl).then(() => { //assert - test.equals( + test.equal( util.sanitized(testPattern.extendedTemplate), util.sanitized('

{{foo}}

true not{"true"

') ); @@ -330,7 +330,7 @@ tap.test( tap.test( 'parameter hunter parses parameters with double-quoted keys and double-quoted values wrapping internal escaped double-quotes', - function(test) { + function (test) { //arrange const pl = util.fakePatternLab(testPatternsPath); @@ -353,7 +353,7 @@ tap.test( //act parameter_hunter.find_parameters(testPattern, pl).then(() => { //assert - test.equals( + test.equal( util.sanitized(testPattern.extendedTemplate), util.sanitized('

{{foo}}

true not}"true"

') ); @@ -365,7 +365,7 @@ tap.test( tap.test( 'parameter hunter parses parameters with combination of quoting schemes for keys and values', - function(test) { + function (test) { //arrange const pl = util.fakePatternLab(testPatternsPath); @@ -388,7 +388,7 @@ tap.test( //act parameter_hunter.find_parameters(testPattern, pl).then(() => { //assert - test.equals( + test.equal( util.sanitized(testPattern.extendedTemplate), util.sanitized('

false

true

') ); @@ -421,13 +421,13 @@ tap.test( // //act // parameter_hunter.find_parameters(testPattern, pl).then(() => { // //assert -// test.equals(util.sanitized(testPattern.extendedTemplate), util.sanitized('

Hello ) World

')); +// test.equal(util.sanitized(testPattern.extendedTemplate), util.sanitized('

Hello ) World

')); // test.end(); // }); // }); // }); -tap.test('parameter hunter skips malformed parameters', function(test) { +tap.test('parameter hunter skips malformed parameters', function (test) { const pl = util.fakePatternLab(testPatternsPath); var commentPath = path.join('test', 'comment.mustache'); @@ -452,7 +452,7 @@ tap.test('parameter hunter skips malformed parameters', function(test) { console.log( '\nPattern Lab should catch JSON.parse() errors and output useful debugging information...' ); - test.equals( + test.equal( util.sanitized(testPattern.extendedTemplate), util.sanitized('

{{foo}}

{{description}}

') ); diff --git a/packages/core/test/parseAllLinks_tests.js b/packages/core/test/parseAllLinks_tests.js index 43dd0e030..7077bf454 100644 --- a/packages/core/test/parseAllLinks_tests.js +++ b/packages/core/test/parseAllLinks_tests.js @@ -17,7 +17,7 @@ const patterns_dir = './test/files/_patterns'; tap.test( 'parseDataLinks - replaces found link.* data for their expanded links', - function(test) { + function (test) { //arrange const patternlab = util.fakePatternLab(patterns_dir); patternlab.graph = PatternGraph.empty(); @@ -56,51 +56,51 @@ tap.test( patternlab.data.someone2 = { url: 'link.facebook-someone2' }; let pattern = patternlab.patterns.find( - p => p.patternPartial === 'test-nav' + (p) => p.patternPartial === 'test-nav' ); //assert before - test.equals( + test.equal( pattern.jsonFileData.brad.url, 'link.twitter-brad', 'brad pattern data should be found' ); - test.equals( + test.equal( pattern.jsonFileData.dave.url, 'link.twitter-dave', 'dave pattern data should be found' ); - test.equals( + test.equal( pattern.jsonFileData.brian.url, 'link.twitter-brian', 'brian pattern data should be found' ); - test.equals( + test.equal( pattern.jsonFileData.someone.url, 'link.twitter-someone', 'brian pattern data should be found' ); - test.equals( + test.equal( pattern.jsonFileData.someone2.url, 'link.facebook-someone2', 'brian pattern data should be found' ); - test.equals( + test.equal( pattern.jsonFileData['viewall-twitter'].url, 'link.viewall-twitter-all', 'view all twitter link should be found' ); - test.equals( + test.equal( pattern.jsonFileData['viewall-twitter-people'].url, 'link.viewall-twitter-people', 'view all twitter people link should be found' ); - test.equals( + test.equal( pattern.jsonFileData['viewall-facebook'].url, 'link.viewall-facebook-all', 'view all facebook link should be found' ); - test.equals( + test.equal( pattern.jsonFileData['viewall-facebook-people'].url, 'link.viewall-facebook-people', 'view all facebook people link should be found' @@ -110,73 +110,73 @@ tap.test( parseAllLinks(patternlab); //assert after - test.equals( + test.equal( pattern.jsonFileData.brad.url, '/patterns/twitter-brad/twitter-brad.rendered.html', 'brad pattern data should be replaced' ); - test.equals( + test.equal( pattern.jsonFileData.dave.url, '/patterns/twitter-dave/twitter-dave.rendered.html', 'dave pattern data should be replaced' ); - test.equals( + test.equal( pattern.jsonFileData.brian.url, '/patterns/twitter-brian/twitter-brian.rendered.html', 'brian pattern data should be replaced' ); - test.equals( + test.equal( pattern.jsonFileData.someone.url, '/patterns/twitter-people-someone/twitter-people-someone.rendered.html', 'twitter people someone pattern data should be replaced' ); - test.equals( + test.equal( pattern.jsonFileData.someone2.url, '/patterns/facebook-people-someone2/facebook-people-someone2.rendered.html', 'facebook people someone2 pattern data should be replaced with prefix pattern' ); - test.equals( + test.equal( pattern.jsonFileData['viewall-twitter'].url, '/patterns/twitter/index.html', 'view all twitter link should be replaced' ); - test.equals( + test.equal( pattern.jsonFileData['viewall-twitter-people'].url, '/patterns/twitter-people/index.html', 'view all twitter people link should be replaced' ); - test.equals( + test.equal( pattern.jsonFileData['viewall-facebook'].url, '/patterns/facebook/index.html', 'view all facebook link should be replaced' ); - test.equals( + test.equal( pattern.jsonFileData['viewall-facebook-people'].url, '/patterns/facebook-people/index.html', 'view all facebook people link should be replaced' ); - test.equals( + test.equal( patternlab.data.brad.url, '/patterns/twitter-brad/twitter-brad.rendered.html', 'global brad data should be replaced' ); - test.equals( + test.equal( patternlab.data.dave.url, '/patterns/twitter-dave/twitter-dave.rendered.html', 'global dave data should be replaced' ); - test.equals( + test.equal( patternlab.data.brian.url, '/patterns/twitter-brian/twitter-brian.rendered.html', 'global brian data should be replaced' ); - test.equals( + test.equal( patternlab.data.someone.url, '/patterns/twitter-people-someone/twitter-people-someone.rendered.html', 'twitter people someone pattern data should be replaced' ); - test.equals( + test.equal( patternlab.data.someone2.url, '/patterns/facebook-people-someone2/facebook-people-someone2.rendered.html', 'facebook people someone2 pattern data should be replaced with prefix pattern' diff --git a/packages/core/test/pattern_engines_tests.js b/packages/core/test/pattern_engines_tests.js index 300b5b7e7..9036984b2 100644 --- a/packages/core/test/pattern_engines_tests.js +++ b/packages/core/test/pattern_engines_tests.js @@ -27,20 +27,20 @@ var engineNames = Object.keys(patternEngines); tap.test( 'getEngineNameForPattern returns "mustache" from test pattern', - function(test) { + function (test) { var engineName = patternEngines.getEngineNameForPattern( mustacheTestPattern ); - test.equals(engineName, 'mustache'); + test.equal(engineName, 'mustache'); test.end(); } ); tap.test( 'getEngineNameForPattern returns "mustache" for a plain string template as a backwards compatibility measure', - function(test) { + function (test) { test.plan(1); - test.equals( + test.equal( patternEngines.getEngineNameForPattern('plain text string'), 'mustache' ); @@ -50,10 +50,10 @@ tap.test( tap.test( 'getEngineNameForPattern returns "mustache" for an artificial empty template', - function(test) { + function (test) { test.plan(1); var emptyPattern = Pattern.createEmpty(); - test.equals( + test.equal( patternEngines.getEngineNameForPattern(emptyPattern), 'mustache' ); @@ -63,25 +63,25 @@ tap.test( tap.test( 'getEngineForPattern returns a reference to the mustache engine from test pattern', - function(test) { + function (test) { var engine = patternEngines.getEngineForPattern(mustacheTestPattern); - test.equals(engine, patternEngines.mustache); + test.equal(engine, patternEngines.mustache); test.end(); } ); tap.test( 'getEngineForPattern returns a reference to the mustache engine from test pseudo-pattern', - function(test) { + function (test) { var engine = patternEngines.getEngineForPattern(mustacheTestPseudoPattern); - test.equals(engine, patternEngines.mustache); + test.equal(engine, patternEngines.mustache); test.end(); } ); tap.test( 'isPseudoPatternJSON correctly identifies pseudo-pattern JSON filenames', - function(test) { + function (test) { // each test case var filenames = { 'homepage~emergency.json': true, @@ -96,7 +96,7 @@ tap.test( test.plan(Object.keys(filenames).length); // loop over each test case and test it - Object.keys(filenames).forEach(function(filename) { + Object.keys(filenames).forEach(function (filename) { var expectedResult = filenames[filename], actualResult = patternEngines.isPseudoPatternJSON(filename), testMessage = @@ -114,7 +114,7 @@ tap.test( tap.test( 'isPatternFile correctly identifies pattern files and rejects non-pattern files', - function(test) { + function (test) { // each test case var filenames = { 'comment-thread.mustache': true, @@ -129,7 +129,7 @@ tap.test( test.plan(Object.keys(filenames).length); // loop over each test case and test it - Object.keys(filenames).forEach(function(filename) { + Object.keys(filenames).forEach(function (filename) { var expectedResult = filenames[filename], actualResult = patternEngines.isPatternFile(filename), testMessage = @@ -160,10 +160,10 @@ function testProps(object, propTests, test) { } var isOneOfTheseTypes = possibleTypes - .map(function(type) { + .map(function (type) { return typeof object[propName] === type; }) - .reduce(function(isPrevType, isCurrentType) { + .reduce(function (isPrevType, isCurrentType) { return isPrevType || isCurrentType; }); @@ -183,7 +183,7 @@ function testProps(object, propTests, test) { } // go over each property test and run it - Object.keys(propTests).forEach(function(propName) { + Object.keys(propTests).forEach(function (propName) { var propType = propTests[propName]; testProp(propName, propType); }); @@ -191,7 +191,7 @@ function testProps(object, propTests, test) { tap.test( 'patternEngines object contains at least the default mustache engine', - function(test) { + function (test) { test.plan(1); test.ok(patternEngines.hasOwnProperty('mustache')); test.end(); @@ -200,7 +200,7 @@ tap.test( tap.test( 'patternEngines object reports that it supports the .mustache extension', - function(test) { + function (test) { test.plan(1); test.ok(patternEngines.isFileExtensionSupported('.mustache')); test.end(); @@ -208,10 +208,10 @@ tap.test( ); // make one big test group for each pattern engine -engineNames.forEach(function(engineName) { +engineNames.forEach(function (engineName) { tap.test( 'engine ' + engineName + ' contains expected properties and methods', - function(test) { + function (test) { var propertyTests = { engine: ['object', 'function'], engineName: 'string', @@ -229,7 +229,7 @@ engineNames.forEach(function(engineName) { tap.test( 'patternEngines getSupportedFileExtensions flattens known engine extensions into a single array', - function(test) { + function (test) { //arrange patternEngines.fooEngine = { engineFileExtension: ['.foo1', '.foo2'], diff --git a/packages/core/test/pattern_graph_tests.js b/packages/core/test/pattern_graph_tests.js index 366f6c006..4bbff233a 100644 --- a/packages/core/test/pattern_graph_tests.js +++ b/packages/core/test/pattern_graph_tests.js @@ -22,21 +22,21 @@ var patternlab = { }, }; -var mockGraph = function() { +var mockGraph = function () { return PatternGraph.empty(); }; -tap.test('checkVersion - Current version returns true', test => { +tap.test('checkVersion - Current version returns true', (test) => { test.same(PatternGraph.checkVersion({ version: VERSION }), true); test.end(); }); -tap.test('checkVersion - Older version returns false', test => { +tap.test('checkVersion - Older version returns false', (test) => { test.same(PatternGraph.checkVersion({ version: VERSION - 1 }), false); test.end(); }); -tap.test('Loading an empty graph works', test => { +tap.test('Loading an empty graph works', (test) => { var g = PatternGraph.loadFromFile( path.resolve(__dirname, 'public'), 'does not exist' @@ -45,7 +45,7 @@ tap.test('Loading an empty graph works', test => { test.end(); }); -tap.test('PatternGraph.fromJson() - Loading a graph from JSON', test => { +tap.test('PatternGraph.fromJson() - Loading a graph from JSON', (test) => { var graph = PatternGraph.loadFromFile( path.resolve(__dirname, 'public'), 'testDependencyGraph.json' @@ -58,9 +58,9 @@ tap.test('PatternGraph.fromJson() - Loading a graph from JSON', test => { tap.test( 'PatternGraph.fromJson() - Loading a graph from JSON using an older version throws error', - test => { + (test) => { test.throws( - function() { + function () { PatternGraph.fromJson({ version: 0 }); }, {}, @@ -71,7 +71,7 @@ tap.test( } ); -tap.test('toJson() - Storing a graph to JSON correctly', test => { +tap.test('toJson() - Storing a graph to JSON correctly', (test) => { var graph = mockGraph(); graph.timestamp = 1337; var atomFoo = Pattern.create('atom-foo', null, { @@ -101,7 +101,7 @@ tap.test('toJson() - Storing a graph to JSON correctly', test => { tap.test( 'Storing and loading a graph from JSON return the identical graph', - test => { + (test) => { var oldGraph = mockGraph(); oldGraph.timestamp = 1337; var atomFoo = Pattern.create('atom-foo', null, { @@ -128,7 +128,7 @@ tap.test( } ); -tap.test('clone()', test => { +tap.test('clone()', (test) => { var oldGraph = mockGraph(); oldGraph.timestamp = 1337; var atomFoo = Pattern.create('atom-foo', null, { @@ -154,7 +154,7 @@ tap.test('clone()', test => { test.end(); }); -tap.test('Adding a node', test => { +tap.test('Adding a node', (test) => { var g = mockGraph(); var pattern = Pattern.create('atom-foo', null, { compileState: CompileState.CLEAN, @@ -170,7 +170,7 @@ tap.test('Adding a node', test => { test.end(); }); -tap.test('Adding a node twice', test => { +tap.test('Adding a node twice', (test) => { var g = mockGraph(); var pattern = Pattern.create('atom-foo', null, { compileState: CompileState.CLEAN, @@ -182,7 +182,7 @@ tap.test('Adding a node twice', test => { test.end(); }); -tap.test('Adding two nodes', test => { +tap.test('Adding two nodes', (test) => { var g = mockGraph(); var atomFoo = Pattern.create('atom-foo', { compileState: CompileState.CLEAN, @@ -197,7 +197,7 @@ tap.test('Adding two nodes', test => { test.end(); }); -tap.test('Adding two nodes with only different subpattern types', test => { +tap.test('Adding two nodes with only different subpattern types', (test) => { var g = mockGraph(); var atomFoo = Pattern.create('atoms/foo/baz.html', { compileState: CompileState.CLEAN, @@ -212,7 +212,7 @@ tap.test('Adding two nodes with only different subpattern types', test => { test.end(); }); -tap.test('Linking two nodes', test => { +tap.test('Linking two nodes', (test) => { var g = mockGraph(); var atomFoo = Pattern.create('atom-foo', null, { compileState: CompileState.CLEAN, @@ -231,7 +231,7 @@ tap.test('Linking two nodes', test => { test.end(); }); -tap.test('remove() - Removing a node', test => { +tap.test('remove() - Removing a node', (test) => { var g = mockGraph(); var atomFoo = Pattern.create('atom-foo', null, { compileState: CompileState.CLEAN, @@ -256,7 +256,7 @@ tap.test('remove() - Removing a node', test => { test.end(); }); -tap.test('filter() - Removing nodes via filter', test => { +tap.test('filter() - Removing nodes via filter', (test) => { var g = mockGraph(); var atomFoo = Pattern.create('atom-foo', null, { compileState: CompileState.CLEAN, @@ -267,7 +267,7 @@ tap.test('filter() - Removing nodes via filter', test => { g.add(atomFoo); g.add(moleculeFoo); test.same(g.nodes(), ['atom-foo', 'molecule-foo']); - g.filter(n => n != 'molecule-foo'); + g.filter((n) => n != 'molecule-foo'); test.same( g.graph.nodes(), ['atom-foo'], @@ -283,7 +283,7 @@ tap.test('filter() - Removing nodes via filter', test => { // Prevents nodes from escaping the scope, at the same time have some default graph for lineage to // test on -(function() { +(function () { var atomFoo = Pattern.create('atom/xy/foo', null, { compileState: CompileState.CLEAN, }); @@ -324,26 +324,32 @@ tap.test('filter() - Removing nodes via filter', test => { g.link(moleculeFoo, atomFoo); g.link(moleculeBar, atomFoo); - tap.test('lineage() - Calculate the lineage of a node', test => { - test.same(posixPath(g.lineage(organismFoo).map(p => p.relPath)), [ + tap.test('lineage() - Calculate the lineage of a node', (test) => { + test.same(posixPath(g.lineage(organismFoo).map((p) => p.relPath)), [ 'molecule/xy/foo', ]); - test.same(posixPath(g.lineage(organismBar).map(p => p.relPath)), [ + test.same(posixPath(g.lineage(organismBar).map((p) => p.relPath)), [ 'molecule/xy/foo', 'molecule/xy/bar', ]); - test.same(posixPath(g.lineage(moleculeFoo).map(p => p.relPath)), [ + test.same(posixPath(g.lineage(moleculeFoo).map((p) => p.relPath)), [ 'atom/xy/foo', ]); - test.same(posixPath(g.lineage(moleculeBar).map(p => p.relPath)), [ + test.same(posixPath(g.lineage(moleculeBar).map((p) => p.relPath)), [ 'atom/xy/foo', ]); - test.same(g.lineage(atomFoo).map(p => p.relPath), []); - test.same(g.lineage(atomIsolated).map(p => p.relPath), []); + test.same( + g.lineage(atomFoo).map((p) => p.relPath), + [] + ); + test.same( + g.lineage(atomIsolated).map((p) => p.relPath), + [] + ); test.end(); }); - tap.test('lineageIndex() - Calculate the lineage of a node', test => { + tap.test('lineageIndex() - Calculate the lineage of a node', (test) => { test.same(g.lineageIndex(organismFoo), ['molecule-foo']); test.same(g.lineageIndex(organismBar), ['molecule-foo', 'molecule-bar']); test.same(g.lineageIndex(moleculeFoo), ['atom-foo']); @@ -353,36 +359,48 @@ tap.test('filter() - Removing nodes via filter', test => { test.end(); }); - tap.test('lineageR() - Calculate the reverse lineage of a node', test => { - test.same(g.lineageR(organismFoo).map(p => p.relPath), []); - test.same(g.lineageR(organismBar).map(p => p.relPath), []); - test.same(posixPath(g.lineageR(moleculeFoo).map(p => p.relPath)), [ + tap.test('lineageR() - Calculate the reverse lineage of a node', (test) => { + test.same( + g.lineageR(organismFoo).map((p) => p.relPath), + [] + ); + test.same( + g.lineageR(organismBar).map((p) => p.relPath), + [] + ); + test.same(posixPath(g.lineageR(moleculeFoo).map((p) => p.relPath)), [ 'organism/xy/foo', 'organism/xy/bar', ]); - test.same(posixPath(g.lineageR(moleculeBar).map(p => p.relPath)), [ + test.same(posixPath(g.lineageR(moleculeBar).map((p) => p.relPath)), [ 'organism/xy/bar', ]); - test.same(posixPath(g.lineageR(atomFoo).map(p => p.relPath)), [ + test.same(posixPath(g.lineageR(atomFoo).map((p) => p.relPath)), [ 'molecule/xy/foo', 'molecule/xy/bar', ]); - test.same(g.lineageR(atomIsolated).map(p => p.relPath), []); + test.same( + g.lineageR(atomIsolated).map((p) => p.relPath), + [] + ); test.end(); }); - tap.test('lineageRIndex() - Calculate the lineage index of a node', test => { - test.same(g.lineageRIndex(organismFoo), []); - test.same(g.lineageRIndex(organismBar), []); - test.same(g.lineageRIndex(moleculeFoo), ['organism-foo', 'organism-bar']); - test.same(g.lineageRIndex(moleculeBar), ['organism-bar']); - test.same(g.lineageRIndex(atomFoo), ['molecule-foo', 'molecule-bar']); - test.same(g.lineageRIndex(atomIsolated), []); - test.end(); - }); + tap.test( + 'lineageRIndex() - Calculate the lineage index of a node', + (test) => { + test.same(g.lineageRIndex(organismFoo), []); + test.same(g.lineageRIndex(organismBar), []); + test.same(g.lineageRIndex(moleculeFoo), ['organism-foo', 'organism-bar']); + test.same(g.lineageRIndex(moleculeBar), ['organism-bar']); + test.same(g.lineageRIndex(atomFoo), ['molecule-foo', 'molecule-bar']); + test.same(g.lineageRIndex(atomIsolated), []); + test.end(); + } + ); })(); -(function() { +(function () { function TestGraph() { function csAt(args, idx) { return { compileState: args[idx] || CompileState.CLEAN }; @@ -443,17 +461,17 @@ tap.test('filter() - Removing nodes via filter', test => { tap.test( 'compileOrder() - A clean graph results in no nodes to recompile', - test => { + (test) => { var g = new TestGraph(); var co = g.graph.compileOrder(); - test.equals(0, co.length); + test.equal(0, co.length); test.end(); } ); tap.test( 'compileOrder() - Recompile isolated atoms does not do anything else', - test => { + (test) => { var g = new TestGraph( // atomFoo CompileState.CLEAN, @@ -463,7 +481,7 @@ tap.test('filter() - Removing nodes via filter', test => { var co = g.graph.compileOrder(); test.same([g.atomIsolated], co, 'Only recompile atomIsolated'); - co.forEach(p => + co.forEach((p) => test.same( p.compileState, CompileState.NEEDS_REBUILD, @@ -477,18 +495,18 @@ tap.test('filter() - Removing nodes via filter', test => { tap.test( 'compileOrder() - Changing a linked atom bubbles back to the organisms', - test => { + (test) => { // Almost every pattern - except atomIsolated - has a transitive dependency on atomFoo var g = new TestGraph(CompileState.NEEDS_REBUILD); var co = g.graph.compileOrder(); - test.equals(5, co.length); + test.equal(5, co.length); test.same( [g.atomFoo, g.moleculeFoo, g.organismFoo, g.moleculeBar, g.organismBar], co, 'Recompile everything except atomIsolated' ); - co.forEach(p => + co.forEach((p) => test.same( p.compileState, CompileState.NEEDS_REBUILD, @@ -502,7 +520,7 @@ tap.test('filter() - Removing nodes via filter', test => { tap.test( 'compileOrder() - Changing a molecule leaves atoms untouched', - test => { + (test) => { // Bubble up from molecules to organisms, leaving atoms unchanged as they were not modified var g = new TestGraph(null, null, CompileState.NEEDS_REBUILD); var co = g.graph.compileOrder(); @@ -512,7 +530,7 @@ tap.test('filter() - Removing nodes via filter', test => { co, 'Recompile moleculeFoo and transitive dependencies' ); - co.forEach(p => + co.forEach((p) => test.same( p.compileState, CompileState.NEEDS_REBUILD, @@ -525,7 +543,7 @@ tap.test('filter() - Removing nodes via filter', test => { tap.test( 'compileOrder() - Changing an organism leaves atoms and molecules untouched', - test => { + (test) => { // Almost every pattern - except atomIsolated - has a transitive dependency on atomFoo var g = new TestGraph( // atoms @@ -549,7 +567,7 @@ tap.test('filter() - Removing nodes via filter', test => { } ); - tap.test('compileOrder() - Recompile everything', test => { + tap.test('compileOrder() - Recompile everything', (test) => { // Almost every pattern - except atomIsolated - has a transitive dependency on atomFoo // Also recompile atomIsolated var g = new TestGraph( @@ -570,7 +588,7 @@ tap.test('filter() - Removing nodes via filter', test => { compileOrder, 'Recompile everything except atomIsolated' ); - compileOrder.forEach(p => + compileOrder.forEach((p) => test.same( p.compileState, CompileState.NEEDS_REBUILD, diff --git a/packages/core/test/pattern_registry_tests.js b/packages/core/test/pattern_registry_tests.js index bf2e71914..72eef2c4f 100644 --- a/packages/core/test/pattern_registry_tests.js +++ b/packages/core/test/pattern_registry_tests.js @@ -7,7 +7,7 @@ var tap = require('tap'); // #540 Copied from pattern_assembler_tests tap.test( 'get_pattern_by_key - returns the fuzzy result when no others found', - function(test) { + function (test) { var pattern_registry = new PatternRegistry(); var pattern = { @@ -21,13 +21,13 @@ tap.test( //act var result = pattern_registry.getPartial('character-han'); //assert - test.equals(result, pattern); + test.equal(result, pattern); test.end(); } ); // #540 Copied from pattern_assembler_tests -tap.test('remove - remove an existing pattern', function(test) { +tap.test('remove - remove an existing pattern', function (test) { var pattern_registry = new PatternRegistry(); var pattern = { @@ -45,7 +45,7 @@ tap.test('remove - remove an existing pattern', function(test) { }); // #540 Copied from pattern_assembler_tests -tap.test('getPartial - returns the exact key if found', function(test) { +tap.test('getPartial - returns the exact key if found', function (test) { //arrange var pattern_registry = new PatternRegistry(); let patterns = [ @@ -62,11 +62,11 @@ tap.test('getPartial - returns the exact key if found', function(test) { fileName: 'molecules-primary-nav', }, ]; - patterns.forEach(p => pattern_registry.put(p)); + patterns.forEach((p) => pattern_registry.put(p)); //act var result = pattern_registry.getPartial('molecules-primary-nav'); //assert - test.equals(result, patterns[1]); + test.equal(result, patterns[1]); test.end(); }); diff --git a/packages/core/test/patternlab_tests.js b/packages/core/test/patternlab_tests.js index 741fbca15..b2971bec6 100644 --- a/packages/core/test/patternlab_tests.js +++ b/packages/core/test/patternlab_tests.js @@ -9,16 +9,16 @@ var plEngineModule = rewire('../src/lib/patternlab'); //set up a global mocks - we don't want to be writing/rendering any files right now const fsMock = { - outputFileSync: function(path, content) { + outputFileSync: function (path, content) { /* INTENTIONAL NOOP */ }, - readJSONSync: function(path, encoding) { + readJSONSync: function (path, encoding) { return fs.readJSONSync(path, encoding); }, - emptyDir: function(path) { + emptyDir: function (path) { return fs.emptyDir(path); }, - readFileSync: function(path, encoding) { + readFileSync: function (path, encoding) { return fs.readFileSync(path, encoding); }, }; @@ -30,27 +30,28 @@ plEngineModule.__set__({ tap.test( 'buildPatternData - should merge all JSON files in the data folder except listitems', - function(test) { + function (test) { const data_dir = `${__dirname}/files/_data/`; var pl = new plEngineModule(config); var dataResult = pl.buildPatternData(data_dir, fs); - test.equals(dataResult.data, 'test'); - test.equals(dataResult.foo, 'bar'); - test.equals(dataResult.test_list_item, undefined); + test.equal(dataResult.data, 'test'); + test.equal(dataResult.foo, 'bar'); + test.equal(dataResult.test_list_item, undefined); test.end(); } ); -tap.test('buildPatternData - can load json, yaml, and yml files', function( - test -) { - const data_dir = `${__dirname}/files/_data/`; - - var pl = new plEngineModule(config); - var dataResult = pl.buildPatternData(data_dir, fs); - test.equals(dataResult.from_yml, 'from_yml'); - test.equals(dataResult.from_yaml, 'from_yaml'); - test.equals(dataResult.from_json, 'from_json'); - test.end(); -}); +tap.test( + 'buildPatternData - can load json, yaml, and yml files', + function (test) { + const data_dir = `${__dirname}/files/_data/`; + + var pl = new plEngineModule(config); + var dataResult = pl.buildPatternData(data_dir, fs); + test.equal(dataResult.from_yml, 'from_yml'); + test.equal(dataResult.from_yaml, 'from_yaml'); + test.equal(dataResult.from_json, 'from_json'); + test.end(); + } +); diff --git a/packages/core/test/processRecursive_tests.js b/packages/core/test/processRecursive_tests.js index 9f4388f61..96de00066 100644 --- a/packages/core/test/processRecursive_tests.js +++ b/packages/core/test/processRecursive_tests.js @@ -16,7 +16,7 @@ engineLoader.loadAllEngines(config); const patterns_dir = `${__dirname}/files/_patterns`; -tap.test('processRecursive recursively includes partials', function(test) { +tap.test('processRecursive recursively includes partials', function (test) { //assert const patternlab = util.fakePatternLab(patterns_dir); @@ -36,7 +36,7 @@ tap.test('processRecursive recursively includes partials', function(test) { .then(() => { //assert const expectedValue = 'bar'; - test.equals( + test.equal( util.sanitized(fooPattern.extendedTemplate), util.sanitized(expectedValue) ); @@ -49,7 +49,7 @@ tap.test('processRecursive recursively includes partials', function(test) { tap.test( 'processRecursive - correctly replaces all stylemodifiers when multiple duplicate patterns with different stylemodifiers found', - function(test) { + function (test) { //arrange const patternlab = util.fakePatternLab(patterns_dir); @@ -70,7 +70,7 @@ tap.test( //assert const expectedValue = '
{{message}} {{message}} {{message}} {{message}}
'; - test.equals( + test.equal( util.sanitized(groupPattern.extendedTemplate), util.sanitized(expectedValue) ); @@ -84,7 +84,7 @@ tap.test( tap.only( 'processRecursive - correctly replaces multiple stylemodifier classes on same partial', - function(test) { + function (test) { //arrange const patternlab = util.fakePatternLab(patterns_dir); @@ -105,7 +105,7 @@ tap.only( //assert const expectedValue = '
{{message}} {{message}} bar
'; - test.equals( + test.equal( util.sanitized(groupPattern.extendedTemplate), util.sanitized(expectedValue) ); @@ -119,7 +119,7 @@ tap.only( tap.test( 'processRecursive - correctly ignores a partial without a style modifier when the same partial later has a style modifier', - function(test) { + function (test) { //arrange const patternlab = util.fakePatternLab(patterns_dir); @@ -140,7 +140,7 @@ tap.test( //assert. here we expect {{styleModifier}} to be in the first group, since it was not replaced by anything. rendering with data will then remove this (correctly) const expectedValue = '
{{message}} {{message}} {{message}} {{message}}
'; - test.equals( + test.equal( util.sanitized(mixedPattern.extendedTemplate), util.sanitized(expectedValue) ); @@ -154,7 +154,7 @@ tap.test( tap.test( 'processRecursive - correctly ignores bookended partials without a style modifier when the same partial has a style modifier between', - function(test) { + function (test) { //arrange const patternlab = util.fakePatternLab(patterns_dir); @@ -175,7 +175,7 @@ tap.test( //assert. here we expect {{styleModifier}} to be in the first and last group, since it was not replaced by anything. rendering with data will then remove this (correctly) const expectedValue = '
{{message}} {{message}} {{message}} {{message}}
'; - test.equals( + test.equal( util.sanitized(bookendPattern.extendedTemplate), util.sanitized(expectedValue) ); @@ -189,7 +189,7 @@ tap.test( tap.test( 'processRecursive - correctly ignores a partial without a style modifier when the same partial later has a style modifier and pattern parameters', - function(test) { + function (test) { //arrange const patternlab = util.fakePatternLab(patterns_dir); @@ -210,7 +210,7 @@ tap.test( //assert. here we expect {{styleModifier}} to be in the first span, since it was not replaced by anything. rendering with data will then remove this (correctly) const expectedValue = '
{{message}} 2 3 4
'; - test.equals( + test.equal( util.sanitized(mixedPattern.extendedTemplate), util.sanitized(expectedValue) ); @@ -224,7 +224,7 @@ tap.test( tap.test( 'processRecursive - correctly ignores bookended partials without a style modifier when the same partial has a style modifier and pattern parameters between', - function(test) { + function (test) { //arrange const patternlab = util.fakePatternLab(patterns_dir); @@ -245,7 +245,7 @@ tap.test( //assert. here we expect {{styleModifier}} to be in the first and last span, since it was not replaced by anything. rendering with data will then remove this (correctly) const expectedValue = '
{{message}} 2 3 {{message}}
'; - test.equals( + test.equal( util.sanitized(bookendPattern.extendedTemplate), util.sanitized(expectedValue) ); @@ -259,7 +259,7 @@ tap.test( tap.test( 'processRecursive - does not pollute previous patterns when a later one is found with a styleModifier', - function(test) { + function (test) { //arrange const patternlab = util.fakePatternLab(patterns_dir); @@ -284,21 +284,21 @@ tap.test( ' {{message}} '; //this is the "atom" - it should remain unchanged - test.equals( + test.equal( util.sanitized(atomPattern.template), util.sanitized(expectedCleanValue) ); - test.equals( + test.equal( util.sanitized(atomPattern.extendedTemplate), util.sanitized(expectedCleanValue) ); // this is the style modifier pattern, which should resolve correctly - test.equals( + test.equal( util.sanitized(anotherPattern.template), '{{> test-styled-atom:test_1 }}' ); - test.equals( + test.equal( util.sanitized(anotherPattern.extendedTemplate), util.sanitized(expectedSetValue) ); @@ -311,7 +311,7 @@ tap.test( ); tap - .test('processRecursive - ensure deep-nesting works', function(test) { + .test('processRecursive - ensure deep-nesting works', function (test) { //arrange const patternlab = util.fakePatternLab(patterns_dir); @@ -339,31 +339,28 @@ tap //act return test.test( 'processRecursive - ensure deep-nesting works2', - function(tt) { + function (tt) { //assert const expectedCleanValue = 'bar'; const expectedSetValue = 'bar'; //this is the "atom" - it should remain unchanged - tt.equals(util.sanitized(atomPattern.template), expectedCleanValue); - tt.equals( + tt.equal(util.sanitized(atomPattern.template), expectedCleanValue); + tt.equal( util.sanitized(atomPattern.extendedTemplate), expectedCleanValue ); //this is the "template pattern" - it should have an updated extendedTemplate but an unchanged template - tt.equals( - util.sanitized(templatePattern.template), - '{{> test-bar }}' - ); - tt.equals( + tt.equal(util.sanitized(templatePattern.template), '{{> test-bar }}'); + tt.equal( util.sanitized(templatePattern.extendedTemplate), expectedSetValue ); //this is the "pages pattern" - it should have an updated extendedTemplate equal to the template pattern but an unchanged template - tt.equals(util.sanitized(pagesPattern.template), '{{> test-foo }}'); - tt.equals( + tt.equal(util.sanitized(pagesPattern.template), '{{> test-foo }}'); + tt.equal( util.sanitized(pagesPattern.extendedTemplate), expectedSetValue ); @@ -375,7 +372,7 @@ tap }) .catch(tap.threw); -tap.test('hidden patterns can be called by their nice names', function(test) { +tap.test('hidden patterns can be called by their nice names', function (test) { //arrange const patternlab = util.fakePatternLab(patterns_dir); @@ -393,9 +390,9 @@ tap.test('hidden patterns can be called by their nice names', function(test) { //act processRecursive(hiddenPatternPath, patternlab).then(() => { processRecursive(testPatternPath, patternlab).then(() => { - testPattern.render().then(results => { + testPattern.render().then((results) => { //assert - test.equals( + test.equal( util.sanitized(results), util.sanitized( "Hello there! Here's the hidden atom: [This is the hidden atom]" @@ -409,35 +406,36 @@ tap.test('hidden patterns can be called by their nice names', function(test) { }); }); -tap.test('parses pattern title correctly when frontmatter present', function( - test -) { - //arrange - var pl = util.fakePatternLab(patterns_dir); +tap.test( + 'parses pattern title correctly when frontmatter present', + function (test) { + //arrange + var pl = util.fakePatternLab(patterns_dir); - var testPatternPath = path.join('test', 'bar.mustache'); - var testPattern = loadPattern(testPatternPath, pl); + var testPatternPath = path.join('test', 'bar.mustache'); + var testPattern = loadPattern(testPatternPath, pl); - //act - Promise.all([ - processIterative(testPattern, pl), - processRecursive(testPatternPath, pl), - ]) - .then(results => { - //assert - test.equals( - results[0].patternName, - 'An Atom Walks Into a Bar', - 'patternName not overridden' - ); - test.end(); - }) - .catch(test.threw); -}); + //act + Promise.all([ + processIterative(testPattern, pl), + processRecursive(testPatternPath, pl), + ]) + .then((results) => { + //assert + test.equal( + results[0].patternName, + 'An Atom Walks Into a Bar', + 'patternName not overridden' + ); + test.end(); + }) + .catch(test.threw); + } +); tap.test( 'parses pattern extra frontmatter correctly when frontmatter present', - function(test) { + function (test) { //arrange var pl = util.fakePatternLab(patterns_dir); @@ -449,9 +447,9 @@ tap.test( processIterative(testPattern, pl), processRecursive(testPatternPath, pl), ]) - .then(results => { + .then((results) => { //assert - test.equals(results[0].allMarkdown.joke, 'bad', 'extra key not added'); + test.equal(results[0].allMarkdown.joke, 'bad', 'extra key not added'); test.end(); }) .catch(test.threw); diff --git a/packages/core/test/pseudopattern_hunter_tests.js b/packages/core/test/pseudopattern_hunter_tests.js index c1372db4f..f37b60363 100644 --- a/packages/core/test/pseudopattern_hunter_tests.js +++ b/packages/core/test/pseudopattern_hunter_tests.js @@ -42,7 +42,7 @@ function stubPatternlab() { return pl; } -tap.test('pseudpattern found and added as a pattern', function(test) { +tap.test('pseudpattern found and added as a pattern', function (test) { //arrange var pl = stubPatternlab(); @@ -53,20 +53,20 @@ tap.test('pseudpattern found and added as a pattern', function(test) { var patternCountBefore = pl.patterns.length; return pph.find_pseudopatterns(atomPattern, pl).then(() => { //assert - test.equals(patternCountBefore + 1, pl.patterns.length); - test.equals(pl.patterns[1].patternPartial, 'test-styled-atom-alt'); - test.equals( + test.equal(patternCountBefore + 1, pl.patterns.length); + test.equal(pl.patterns[1].patternPartial, 'test-styled-atom-alt'); + test.equal( JSON.stringify(pl.patterns[1].jsonFileData), JSON.stringify({ message: 'alternateMessage' }) ); - test.equals( + test.equal( pl.patterns[1].patternLink, 'test-styled-atom-alt' + path.sep + 'test-styled-atom-alt.html' ); }); }); -tap.test('pseudpattern does not pollute base pattern data', function(test) { +tap.test('pseudpattern does not pollute base pattern data', function (test) { //arrange var pl = stubPatternlab(); @@ -76,8 +76,8 @@ tap.test('pseudpattern does not pollute base pattern data', function(test) { var patternCountBefore = pl.patterns.length; return pph.find_pseudopatterns(atomPattern, pl).then(() => { //assert - test.equals(pl.patterns[0].patternPartial, 'test-styled-atom'); - test.equals( + test.equal(pl.patterns[0].patternPartial, 'test-styled-atom'); + test.equal( JSON.stringify(pl.patterns[0].jsonFileData), JSON.stringify({ message: 'baseMessage' }) ); @@ -86,7 +86,7 @@ tap.test('pseudpattern does not pollute base pattern data', function(test) { tap.test( 'pseudpattern variant includes stylePartials and parameteredPartials', - function(test) { + function (test) { //arrange var pl = stubPatternlab(); @@ -122,9 +122,9 @@ tap.test( //act return pph.find_pseudopatterns(pseudoPattern, pl).then(() => { //assert - test.equals(pl.patterns[2].patternPartial, 'test-pseudomodifier-test'); - test.equals(pl.patterns[2].stylePartials, pseudoPattern.stylePartials); - test.equals( + test.equal(pl.patterns[2].patternPartial, 'test-pseudomodifier-test'); + test.equal(pl.patterns[2].stylePartials, pseudoPattern.stylePartials); + test.equal( pl.patterns[2].parameteredPartials, pseudoPattern.parameteredPartials ); @@ -132,7 +132,7 @@ tap.test( } ); -tap.test('pseudo pattern variant data should merge arrays', function(test) { +tap.test('pseudo pattern variant data should merge arrays', function (test) { const pl = stubPatternlab(); pl.config.patternMergeVariantArrays = true; @@ -141,8 +141,8 @@ tap.test('pseudo pattern variant data should merge arrays', function(test) { addPattern(pattern, pl); return pph.find_pseudopatterns(pattern, pl).then(() => { - test.equals(pl.patterns[1].patternPartial, 'test-variant-test-merge'); - test.equals( + test.equal(pl.patterns[1].patternPartial, 'test-variant-test-merge'); + test.equal( JSON.stringify(pl.patterns[1].jsonFileData), JSON.stringify({ a: 2, @@ -155,7 +155,7 @@ tap.test('pseudo pattern variant data should merge arrays', function(test) { tap.test( 'pseudo pattern variant data should merge arrays if config "patternMergeVariantArrays" is not available as default behavior', - function(test) { + function (test) { const pl = stubPatternlab(); const pattern = loadPattern('test/variant-test.mustache', pl); @@ -163,8 +163,8 @@ tap.test( addPattern(pattern, pl); return pph.find_pseudopatterns(pattern, pl).then(() => { - test.equals(pl.patterns[1].patternPartial, 'test-variant-test-merge'); - test.equals( + test.equal(pl.patterns[1].patternPartial, 'test-variant-test-merge'); + test.equal( JSON.stringify(pl.patterns[1].jsonFileData), JSON.stringify({ a: 2, @@ -176,7 +176,7 @@ tap.test( } ); -tap.test('pseudo pattern variant data should override arrays', function(test) { +tap.test('pseudo pattern variant data should override arrays', function (test) { const pl = stubPatternlab(); pl.config.patternMergeVariantArrays = false; @@ -185,8 +185,8 @@ tap.test('pseudo pattern variant data should override arrays', function(test) { addPattern(pattern, pl); return pph.find_pseudopatterns(pattern, pl).then(() => { - test.equals(pl.patterns[1].patternPartial, 'test-variant-test-merge'); - test.equals( + test.equal(pl.patterns[1].patternPartial, 'test-variant-test-merge'); + test.equal( JSON.stringify(pl.patterns[1].jsonFileData), JSON.stringify({ a: 2, diff --git a/packages/core/test/replaceParameter_tests.js b/packages/core/test/replaceParameter_tests.js index 41fde31c1..c3dfc129f 100644 --- a/packages/core/test/replaceParameter_tests.js +++ b/packages/core/test/replaceParameter_tests.js @@ -6,44 +6,44 @@ const tap = require('tap'); const replaceParameter = require('../src/lib/replaceParameter'); -tap.test('replaces simple value', function(test) { +tap.test('replaces simple value', function (test) { const result = replaceParameter('{{key}}', 'key', 'value'); - test.equals(result, 'value'); + test.equal(result, 'value'); test.end(); }); -tap.test('replaces simple boolean true value', function(test) { +tap.test('replaces simple boolean true value', function (test) { const result = replaceParameter('{{key}}', 'key', true); - test.equals(result, 'true'); + test.equal(result, 'true'); test.end(); }); -tap.test('replaces simple boolean false value', function(test) { +tap.test('replaces simple boolean false value', function (test) { const result = replaceParameter('{{key}}', 'key', false); - test.equals(result, 'false'); + test.equal(result, 'false'); test.end(); }); -tap.test('replaces raw value', function(test) { +tap.test('replaces raw value', function (test) { const result = replaceParameter('{{{key}}}', 'key', 'value'); - test.equals(result, 'value'); + test.equal(result, 'value'); test.end(); }); -tap.test('replaces boolean true section', function(test) { +tap.test('replaces boolean true section', function (test) { const result = replaceParameter('1{{#key}}value{{/key}}2', 'key', true); - test.equals(result, '1value2'); + test.equal(result, '1value2'); test.end(); }); -tap.only('replaces boolean true section with spaces', function(test) { +tap.only('replaces boolean true section with spaces', function (test) { const result = replaceParameter('1{{ #key }}value{{ /key }}2', 'key', true); - test.equals(result, '1value2'); + test.equal(result, '1value2'); test.end(); }); -tap.test('replaces boolean section false', function(test) { +tap.test('replaces boolean section false', function (test) { const result = replaceParameter('1{{#key}}value{{/key}}2', 'key', false); - test.equals(result, '12'); + test.equal(result, '12'); test.end(); }); diff --git a/packages/core/test/style_modifier_hunter_tests.js b/packages/core/test/style_modifier_hunter_tests.js index bdbc1e994..93c76f92e 100644 --- a/packages/core/test/style_modifier_hunter_tests.js +++ b/packages/core/test/style_modifier_hunter_tests.js @@ -6,7 +6,7 @@ var smh = require('../src/lib/style_modifier_hunter'); tap.test( 'uses the partial stylemodifer to modify the patterns extendedTemplate', - function(test) { + function (test) { //arrange var pl = {}; pl.partials = {}; @@ -27,12 +27,12 @@ tap.test( ); //assert - test.equals(pattern.extendedTemplate, '
'); + test.equal(pattern.extendedTemplate, '
'); test.end(); } ); -tap.test('replaces style modifiers with spaces in the syntax', function(test) { +tap.test('replaces style modifiers with spaces in the syntax', function (test) { //arrange var pl = {}; pl.partials = {}; @@ -53,11 +53,11 @@ tap.test('replaces style modifiers with spaces in the syntax', function(test) { ); //assert - test.equals(pattern.extendedTemplate, '
'); + test.equal(pattern.extendedTemplate, '
'); test.end(); }); -tap.test('replaces multiple style modifiers', function(test) { +tap.test('replaces multiple style modifiers', function (test) { //arrange var pl = {}; pl.partials = {}; @@ -78,13 +78,13 @@ tap.test('replaces multiple style modifiers', function(test) { ); //assert - test.equals(pattern.extendedTemplate, '
'); + test.equal(pattern.extendedTemplate, '
'); test.end(); }); tap.test( 'does not alter pattern extendedTemplate if styleModifier not found in partial', - function(test) { + function (test) { //arrange var pl = {}; pl.partials = {}; @@ -101,7 +101,7 @@ tap.test( style_modifier_hunter.consume_style_modifier(pattern, '{{> partial}}', pl); //assert - test.equals( + test.equal( pattern.extendedTemplate, '
' ); diff --git a/packages/core/test/ui_builder_tests.js b/packages/core/test/ui_builder_tests.js index f5e63f4e8..010bba9d4 100644 --- a/packages/core/test/ui_builder_tests.js +++ b/packages/core/test/ui_builder_tests.js @@ -15,14 +15,14 @@ engineLoader.loadAllEngines(config); //set up a global mocks - we don't want to be writing/rendering any files right now var fsMock = { - outputFileSync: function(path, data, cb) {}, - outputFile: function(path, data, cb) {}, + outputFileSync: function (path, data, cb) {}, + outputFile: function (path, data, cb) {}, }; -var renderMock = function(template, data, partials) { +var renderMock = function (template, data, partials) { return Promise.resolve(''); }; -var buildFooterMock = function(patternlab, patternPartial) { +var buildFooterMock = function (patternlab, patternPartial) { return Promise.resolve(''); }; @@ -69,7 +69,7 @@ function createFakePatternLab(customProps) { tap.test( 'isPatternExcluded - returns true when pattern filename starts with underscore', - function(test) { + function (test) { //arrange var patternlab = createFakePatternLab({}); var pattern = new Pattern('test/ignored-pattern.mustache'); @@ -79,14 +79,14 @@ tap.test( var result = ui.isPatternExcluded(pattern, patternlab, uikit); //assert - test.equals(result, true); + test.equal(result, true); test.end(); } ); tap.test( 'isPatternExcluded - returns true when pattern is defaultPattern', - function(test) { + function (test) { //arrange var patternlab = createFakePatternLab({}); var pattern = new Pattern('test/foo.mustache'); @@ -96,14 +96,14 @@ tap.test( var result = ui.isPatternExcluded(pattern, patternlab, uikit); //assert - test.equals(result, true); + test.equal(result, true); test.end(); } ); tap.test( 'isPatternExcluded - returns true when pattern within underscored directory - top level', - function(test) { + function (test) { //arrange var patternlab = createFakePatternLab({}); var pattern = Pattern.createEmpty({ @@ -127,14 +127,14 @@ tap.test( var result = ui.isPatternExcluded(pattern, patternlab, uikit); //assert - test.equals(result, true); + test.equal(result, true); test.end(); } ); tap.test( 'isPatternExcluded - returns true when pattern within underscored directory - subgroup level', - function(test) { + function (test) { //arrange var patternlab = createFakePatternLab({}); var pattern = Pattern.createEmpty({ @@ -153,14 +153,14 @@ tap.test( var result = ui.isPatternExcluded(pattern, patternlab, uikit); //assert - test.equals(result, true); + test.equal(result, true); test.end(); } ); tap.test( 'isPatternExcluded - returns true when pattern state found withing uikit exclusions', - function(test) { + function (test) { //arrange var patternlab = createFakePatternLab({}); var pattern = Pattern.createEmpty({ @@ -178,12 +178,12 @@ tap.test( }); //assert - test.equals(result, true); + test.equal(result, true); test.end(); } ); -tap.test('groupPatterns - creates pattern groups correctly', function(test) { +tap.test('groupPatterns - creates pattern groups correctly', function (test) { //arrange var patternlab = createFakePatternLab({ patterns: [], @@ -207,27 +207,27 @@ tap.test('groupPatterns - creates pattern groups correctly', function(test) { //act var result = ui.groupPatterns(patternlab, uikit); - test.equals( + test.equal( result.patternGroups.patternGroup1.patternSubgroup1.blue.patternPartial, 'patternGroup1-blue' ); - test.equals( + test.equal( result.patternGroups.patternGroup1.patternSubgroup1.red.patternPartial, 'patternGroup1-red' ); - test.equals( + test.equal( result.patternGroups.patternGroup1.patternSubgroup1.yellow.patternPartial, 'patternGroup1-yellow' ); - test.equals( + test.equal( result.patternGroups.patternGroup1.patternSubgroup2.black.patternPartial, 'patternGroup1-black' ); - test.equals( + test.equal( result.patternGroups.patternGroup1.patternSubgroup2.grey.patternPartial, 'patternGroup1-grey' ); - test.equals( + test.equal( result.patternGroups.patternGroup1.patternSubgroup2.white.patternPartial, 'patternGroup1-white' ); @@ -241,17 +241,17 @@ tap.test('groupPatterns - creates pattern groups correctly', function(test) { //"patternGroup1", "root" (because it's a top-level flat pattern) and at last "test" // Flat patterns - test.equals( + test.equal( patternlab.patternGroups[1].patternItems[0].patternPartial, 'root-foobar', 'flat pattern foobar on root' ); - test.equals( + test.equal( patternlab.patternGroups[2].patternItems[0].patternPartial, 'test-bar', 'first pattern item should be test-bar' ); - test.equals( + test.equal( patternlab.patternGroups[2].patternItems[1].patternPartial, 'test-foo', 'second pattern item should be test-foo' @@ -262,51 +262,52 @@ tap.test('groupPatterns - creates pattern groups correctly', function(test) { test.end(); }); -tap.test('groupPatterns - orders patterns when provided from md', function( - test -) { - //arrange - var patternlab = createFakePatternLab({ - patterns: [], - patternGroups: {}, - subgroupPatterns: {}, - }); +tap.test( + 'groupPatterns - orders patterns when provided from md', + function (test) { + //arrange + var patternlab = createFakePatternLab({ + patterns: [], + patternGroups: {}, + subgroupPatterns: {}, + }); - // Should be sorted by order and secondly by name - patternlab.patterns.push( - new Pattern('patternGroup1/patternSubgroup1/yellow.mustache'), - new Pattern('patternGroup1/patternSubgroup1/red.mustache'), - new Pattern('patternGroup1/patternSubgroup1/blue.mustache') - ); - ui.resetUIBuilderState(patternlab); + // Should be sorted by order and secondly by name + patternlab.patterns.push( + new Pattern('patternGroup1/patternSubgroup1/yellow.mustache'), + new Pattern('patternGroup1/patternSubgroup1/red.mustache'), + new Pattern('patternGroup1/patternSubgroup1/blue.mustache') + ); + ui.resetUIBuilderState(patternlab); - // Set order of red to 1 to sort it after the others - patternlab.patterns[1].order = 1; + // Set order of red to 1 to sort it after the others + patternlab.patterns[1].order = 1; - //act - ui.groupPatterns(patternlab, uikit); - - let patternGroup = _.find(patternlab.patternGroups, [ - 'patternGroup', - 'patternGroup1', - ]); - let patternSubgroup = _.find(patternGroup.patternGroupItems, [ - 'patternSubgroup', - 'patternSubgroup1', - ]); - var items = patternSubgroup.patternSubgroupItems; - - // Viewall should come last since it shows all patterns that are above - test.equals(items[0].patternPartial, 'patternGroup1-blue'); - test.equals(items[1].patternPartial, 'patternGroup1-yellow'); - test.equals(items[2].patternPartial, 'patternGroup1-red'); + //act + ui.groupPatterns(patternlab, uikit); - test.end(); -}); + let patternGroup = _.find(patternlab.patternGroups, [ + 'patternGroup', + 'patternGroup1', + ]); + let patternSubgroup = _.find(patternGroup.patternGroupItems, [ + 'patternSubgroup', + 'patternSubgroup1', + ]); + var items = patternSubgroup.patternSubgroupItems; + + // Viewall should come last since it shows all patterns that are above + test.equal(items[0].patternPartial, 'patternGroup1-blue'); + test.equal(items[1].patternPartial, 'patternGroup1-yellow'); + test.equal(items[2].patternPartial, 'patternGroup1-red'); + + test.end(); + } +); tap.test( 'groupPatterns - retains pattern order from name when order provided from md is malformed', - function(test) { + function (test) { //arrange var patternlab = createFakePatternLab({ patterns: [], @@ -337,9 +338,9 @@ tap.test( var items = patternSubgroup.patternSubgroupItems; // Viewall should come last since it shows all patterns that are above - test.equals(items[0].patternPartial, 'patternGroup1-blue'); - test.equals(items[1].patternPartial, 'patternGroup1-red'); - test.equals(items[2].patternPartial, 'patternGroup1-yellow'); + test.equal(items[0].patternPartial, 'patternGroup1-blue'); + test.equal(items[1].patternPartial, 'patternGroup1-red'); + test.equal(items[2].patternPartial, 'patternGroup1-yellow'); test.end(); } @@ -347,7 +348,7 @@ tap.test( tap.test( 'groupPatterns - sorts viewall subgroup pattern to the beginning', - function(test) { + function (test) { //arrange var patternlab = createFakePatternLab({ patterns: [], @@ -380,13 +381,13 @@ tap.test( var items = patternSubgroup.patternSubgroupItems; // Viewall should come last since it shows all patterns that are above - test.equals( + test.equal( items[3].patternPartial, 'viewall-patternGroup1-patternSubgroup1' ); - test.equals(items[0].patternPartial, 'patternGroup1-blue'); - test.equals(items[1].patternPartial, 'patternGroup1-yellow'); - test.equals(items[2].patternPartial, 'patternGroup1-red'); + test.equal(items[0].patternPartial, 'patternGroup1-blue'); + test.equal(items[1].patternPartial, 'patternGroup1-yellow'); + test.equal(items[2].patternPartial, 'patternGroup1-red'); test.end(); } @@ -394,7 +395,7 @@ tap.test( tap.test( 'groupPatterns - creates documentation patterns for each type and subgroup if not exists', - function(test) { + function (test) { //arrange var patternlab = createFakePatternLab({ patterns: [], @@ -418,13 +419,13 @@ tap.test( var result = ui.groupPatterns(patternlab, uikit); //assert - test.equals( + test.equal( result.patternGroups.patternGroup1.patternSubgroup1[ 'viewall-patternGroup1-patternSubgroup1' ].patternPartial, 'viewall-patternGroup1-patternSubgroup1' ); - test.equals( + test.equal( result.patternGroups.patternGroup1.patternSubgroup2[ 'viewall-patternGroup1-patternSubgroup2' ].patternPartial, @@ -437,7 +438,7 @@ tap.test( tap.test( 'groupPatterns - adds each pattern to the patternPaths object', - function(test) { + function (test) { //arrange var patternlab = createFakePatternLab({ patterns: [], @@ -461,29 +462,29 @@ tap.test( var result = ui.groupPatterns(patternlab, uikit); //assert - test.equals(patternlab.patternPaths['test']['foo'], 'test-foo'); - test.equals(patternlab.patternPaths['test']['bar'], 'test-bar'); - test.equals( + test.equal(patternlab.patternPaths['test']['foo'], 'test-foo'); + test.equal(patternlab.patternPaths['test']['bar'], 'test-bar'); + test.equal( patternlab.patternPaths['patternGroup1']['blue'], 'patternGroup1-patternSubgroup1-blue' ); - test.equals( + test.equal( patternlab.patternPaths['patternGroup1']['red'], 'patternGroup1-patternSubgroup1-red' ); - test.equals( + test.equal( patternlab.patternPaths['patternGroup1']['yellow'], 'patternGroup1-patternSubgroup1-yellow' ); - test.equals( + test.equal( patternlab.patternPaths['patternGroup1']['black'], 'patternGroup1-patternSubgroup2-black' ); - test.equals( + test.equal( patternlab.patternPaths['patternGroup1']['grey'], 'patternGroup1-patternSubgroup2-grey' ); - test.equals( + test.equal( patternlab.patternPaths['patternGroup1']['white'], 'patternGroup1-patternSubgroup2-white' ); @@ -494,7 +495,7 @@ tap.test( tap.test( 'groupPatterns - adds each pattern to the view all paths object', - function(test) { + function (test) { //arrange var patternlab = createFakePatternLab({ patterns: [], @@ -518,13 +519,13 @@ tap.test( var result = ui.groupPatterns(patternlab, uikit); //assert - test.equals('todo', 'todo'); + test.equal('todo', 'todo'); test.end(); } ); -tap.test('resetUIBuilderState - reset global objects', function(test) { +tap.test('resetUIBuilderState - reset global objects', function (test) { //arrange var patternlab = createFakePatternLab({ patternPaths: { foo: 1 }, @@ -536,16 +537,16 @@ tap.test('resetUIBuilderState - reset global objects', function(test) { ui.resetUIBuilderState(patternlab); //assert - test.equals(patternlab.patternPaths.foo, undefined); - test.equals(patternlab.viewAllPaths.bar, undefined); - test.equals(patternlab.patternGroups.length, 0); + test.equal(patternlab.patternPaths.foo, undefined); + test.equal(patternlab.viewAllPaths.bar, undefined); + test.equal(patternlab.patternGroups.length, 0); test.end(); }); tap.test( 'buildViewAllPages - adds viewall page for each type and subgroup NOT! for flat patterns', - function(test) { + function (test) { //arrange const mainPageHeadHtml = ''; const patternlab = createFakePatternLab({ @@ -577,7 +578,7 @@ tap.test( patternlab, styleguidePatterns, uikit - ).then(allPatterns => { + ).then((allPatterns) => { // assert // this was a nuanced one. buildViewAllPages() had return false; statements // within _.forOwn(...) loops, causing premature termination of the entire loop @@ -604,7 +605,7 @@ tap.test( * --- grey * --- white */ - test.equals(uniquePatterns.length, 9, '3 viewall pages should be added'); + test.equal(uniquePatterns.length, 9, '3 viewall pages should be added'); test.end(); }); @@ -613,7 +614,7 @@ tap.test( tap.test( 'buildViewAllPages - adds viewall page for each type and subgroup FOR! flat patterns', - function(test) { + function (test) { //arrange const mainPageHeadHtml = ''; const patternlab = createFakePatternLab({ @@ -647,7 +648,7 @@ tap.test( patternlab, styleguidePatterns, uikit - ).then(allPatterns => { + ).then((allPatterns) => { // assert // this was a nuanced one. buildViewAllPages() had return false; statements // within _.forOwn(...) loops, causing premature termination of the entire loop @@ -677,7 +678,7 @@ tap.test( * --- grey * --- white */ - test.equals(uniquePatterns.length, 11, '4 viewall pages should be added'); + test.equal(uniquePatterns.length, 11, '4 viewall pages should be added'); test.end(); }); diff --git a/packages/core/test/uikitExcludePattern_tests.js b/packages/core/test/uikitExcludePattern_tests.js index fbde9d5e8..f19301d12 100644 --- a/packages/core/test/uikitExcludePattern_tests.js +++ b/packages/core/test/uikitExcludePattern_tests.js @@ -6,7 +6,7 @@ const uikitExcludePattern = require('../src/lib/uikitExcludePattern'); tap.test( 'uikitExcludePattern - returns false when uikit has no excluded states', - test => { + (test) => { //arrange const uikit = { excludedPatternStates: [] }; const pattern = { patternState: 'complete' }; @@ -22,7 +22,7 @@ tap.test( tap.test( 'uikitExcludePattern - returns false pattern does not have same state as uikit exclusions', - test => { + (test) => { //arrange const uikit = { excludedPatternStates: ['complete'] }; const pattern = { patternState: 'inprogress' }; @@ -38,7 +38,7 @@ tap.test( tap.test( 'uikitExcludePattern - returns true when uikit has same state as pattern', - test => { + (test) => { //arrange const uikit = { excludedPatternStates: ['inreview', 'complete'] }; const pattern = { patternState: 'complete' }; @@ -54,7 +54,7 @@ tap.test( tap.test( 'uikitExcludePattern - returns false when uikit has no excluded tags', - test => { + (test) => { //arrange const uikit = { excludedTags: [] }; const pattern = { tags: 'foo-tag' }; @@ -70,7 +70,7 @@ tap.test( tap.test( 'uikitExcludePattern - returns false pattern does not have same tags as uikit exclusions', - test => { + (test) => { //arrange const uikit = { excludedTags: ['bat-tag'] }; const pattern = { tags: 'foo-tag' }; @@ -86,7 +86,7 @@ tap.test( tap.test( 'uikitExcludePattern - returns true when uikit has same tags as pattern', - test => { + (test) => { //arrange const uikit = { excludedTags: ['bar-tag', 'foo-tag'] }; const pattern = { tags: 'foo-tag' }; diff --git a/packages/core/test/util/test_utils.js b/packages/core/test/util/test_utils.js index e76a9506b..0558f500a 100644 --- a/packages/core/test/util/test_utils.js +++ b/packages/core/test/util/test_utils.js @@ -33,7 +33,7 @@ module.exports = { * Strip out control characters from output if needed so make comparisons easier * @param output - the template to strip */ - sanitized: outputTemplate => { + sanitized: (outputTemplate) => { return outputTemplate .replace(/\n/g, ' ') .replace(/\r/g, ' ') @@ -45,7 +45,7 @@ module.exports = { * normalize a string (probably a path) to posix - style * @param s - the string or array of strings to normalize path separators to posix - style */ - posixPath: s => { + posixPath: (s) => { if (Array.isArray(s)) { var paths = []; for (let i = 0; i < s.length; i++) { diff --git a/packages/core/test/watchAssets_tests.js b/packages/core/test/watchAssets_tests.js index d72cd0715..ab96f3b0b 100644 --- a/packages/core/test/watchAssets_tests.js +++ b/packages/core/test/watchAssets_tests.js @@ -12,7 +12,7 @@ const patterns_dir = './test/files/_patterns'; tap.test( 'watchAssets - adds assetWatcher to patternlab.watchers for given key ', - test => { + (test) => { const pl = util.fakePatternLab(patterns_dir, { watchers: [] }); const key = 'images'; @@ -25,15 +25,15 @@ tap.test( true ); - test.equals(_.keys(pl.watchers)[0], 'images'); + test.equal(_.keys(pl.watchers)[0], 'images'); test.end(); } ); -tap.test('watchAssets - complete path copied', test => { - const copyFileMock = function(p, des) { - test.equals(des, path.resolve('/proj/public/images/sample/waterfall.jpg')); +tap.test('watchAssets - complete path copied', (test) => { + const copyFileMock = function (p, des) { + test.equal(des, path.resolve('/proj/public/images/sample/waterfall.jpg')); }; //set our mocks in place of usual require() diff --git a/packages/core/test/watchPatternLabFiles_tests.js b/packages/core/test/watchPatternLabFiles_tests.js index f61b873e6..0dcc7fbc1 100644 --- a/packages/core/test/watchPatternLabFiles_tests.js +++ b/packages/core/test/watchPatternLabFiles_tests.js @@ -12,7 +12,7 @@ const patterns_dir = './test/files/_patterns'; tap.test( 'watchPatternLabFiles - adds watcher to patternlab.watchers for given patternWatchPath', - test => { + (test) => { const pl = util.fakePatternLab(patterns_dir, { watchers: [], engines: {}, @@ -37,7 +37,7 @@ tap.test( // should have two for _data and _meta // should have five for '.json', '.yml', '.yaml', '.md' and '.mustache' - test.equals(Object.keys(pl.watchers).length, 7); + test.equal(Object.keys(pl.watchers).length, 7); test.end(); } diff --git a/packages/development-edition-engine-handlebars/helpers/test.js b/packages/development-edition-engine-handlebars/helpers/test.js index 8b32ed799..6ddbc2bba 100644 --- a/packages/development-edition-engine-handlebars/helpers/test.js +++ b/packages/development-edition-engine-handlebars/helpers/test.js @@ -1,5 +1,5 @@ -module.exports = function(Handlebars) { - Handlebars.registerHelper('test', function() { +module.exports = function (Handlebars) { + Handlebars.registerHelper('test', function () { return 'This is a test helper'; }); }; diff --git a/packages/development-edition-engine-react/gulpfile.js b/packages/development-edition-engine-react/gulpfile.js index 152cb5fd7..3f3658f89 100644 --- a/packages/development-edition-engine-react/gulpfile.js +++ b/packages/development-edition-engine-react/gulpfile.js @@ -33,33 +33,33 @@ function serve() { }); } -gulp.task('patternlab:version', function() { +gulp.task('patternlab:version', function () { patternlab.version(); }); -gulp.task('patternlab:help', function() { +gulp.task('patternlab:help', function () { patternlab.help(); }); -gulp.task('patternlab:patternsonly', function() { +gulp.task('patternlab:patternsonly', function () { patternlab.patternsonly(config.cleanPublic); }); -gulp.task('patternlab:liststarterkits', function() { +gulp.task('patternlab:liststarterkits', function () { patternlab.liststarterkits(); }); -gulp.task('patternlab:loadstarterkit', function() { +gulp.task('patternlab:loadstarterkit', function () { patternlab.loadstarterkit(argv.kit, argv.clean); }); -gulp.task('patternlab:build', function() { +gulp.task('patternlab:build', function () { build().then(() => { // do something else when this promise resolves }); }); -gulp.task('patternlab:serve', function() { +gulp.task('patternlab:serve', function () { serve().then(() => { // do something else when this promise resolves }); diff --git a/packages/development-edition-engine-react/source/_meta/_head.html b/packages/development-edition-engine-react/source/_meta/_head.html index b1f5c1ce0..56d9a2432 100644 --- a/packages/development-edition-engine-react/source/_meta/_head.html +++ b/packages/development-edition-engine-react/source/_meta/_head.html @@ -2,15 +2,22 @@ {{ title }} - + - - + + {{{ patternLabHead }}} - diff --git a/packages/docs/.eleventy.js b/packages/docs/.eleventy.js index 9e8b8feaa..876122731 100644 --- a/packages/docs/.eleventy.js +++ b/packages/docs/.eleventy.js @@ -15,7 +15,7 @@ const parseTransform = require('./src/transforms/parse-transform.js'); // Import data files const site = require('./src/_data/site.json'); -module.exports = function(config) { +module.exports = function (config) { // Filters config.addFilter('dateFilter', dateFilter); config.addFilter('markdownFilter', markdownFilter); @@ -38,28 +38,28 @@ module.exports = function(config) { const now = new Date(); // Custom collections - const livePosts = post => post.date <= now && !post.data.draft; - config.addCollection('posts', collection => { + const livePosts = (post) => post.date <= now && !post.data.draft; + config.addCollection('posts', (collection) => { return [ - ...collection.getFilteredByGlob('./src/posts/*.md').filter(livePosts) + ...collection.getFilteredByGlob('./src/posts/*.md').filter(livePosts), ].reverse(); }); - config.addCollection('demos', collection => { + config.addCollection('demos', (collection) => { return [...collection.getFilteredByGlob('./src/demos/*.md')].reverse(); }); - config.addCollection('postFeed', collection => { + config.addCollection('postFeed', (collection) => { return [...collection.getFilteredByGlob('./src/posts/*.md').filter(livePosts)] .reverse() .slice(0, site.maxPostsPerPage); }); - config.addCollection('docs', collection => { + config.addCollection('docs', (collection) => { return [...collection.getFilteredByGlob('./src/docs/*.md')].reverse(); }); - config.addCollection('docsOrdered', collection => { + config.addCollection('docsOrdered', (collection) => { const docs = collection.getFilteredByGlob('src/docs/*.md').sort((a, b) => { return Number(a.data.order) - Number(b.data.order); }); @@ -74,7 +74,7 @@ module.exports = function(config) { // 404 config.setBrowserSyncConfig({ callbacks: { - ready: function(err, browserSync) { + ready: function (err, browserSync) { const content_404 = fs.readFileSync('dist/404.html'); browserSync.addMiddleware('*', (req, res) => { @@ -82,15 +82,15 @@ module.exports = function(config) { res.write(content_404); res.end(); }); - } - } + }, + }, }); return { dir: { input: 'src', - output: 'dist' + output: 'dist', }, - passthroughFileCopy: true + passthroughFileCopy: true, }; }; diff --git a/packages/docs/rollup.config.js b/packages/docs/rollup.config.js index 7f62e07f4..38dd88349 100644 --- a/packages/docs/rollup.config.js +++ b/packages/docs/rollup.config.js @@ -4,16 +4,11 @@ const nodeResolve = require('rollup-plugin-node-resolve'); const json = require('rollup-plugin-json'); export default { - input: 'src/admin/util', - output: { - file: 'dist/admin/util.js', - format: 'iife', - name: 'previewUtil', - }, - plugins: [ - builtins(), - nodeResolve(), - commonjs(), - json(), - ] + input: 'src/admin/util', + output: { + file: 'dist/admin/util.js', + format: 'iife', + name: 'previewUtil', + }, + plugins: [builtins(), nodeResolve(), commonjs(), json()], }; diff --git a/packages/docs/src/_data/global.js b/packages/docs/src/_data/global.js index 683a0a332..3b6371b17 100644 --- a/packages/docs/src/_data/global.js +++ b/packages/docs/src/_data/global.js @@ -1,9 +1,9 @@ module.exports = { - random() { - const segment = () => { - return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1); - }; - return `${segment()}-${segment()}-${segment()}`; - }, - now: Date.now() + random() { + const segment = () => { + return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1); + }; + return `${segment()}-${segment()}-${segment()}`; + }, + now: Date.now(), }; diff --git a/packages/docs/src/_data/helpers.js b/packages/docs/src/_data/helpers.js index 9ae9b7883..97543eaaa 100644 --- a/packages/docs/src/_data/helpers.js +++ b/packages/docs/src/_data/helpers.js @@ -1,10 +1,10 @@ module.exports = { - getNextHeadingLevel(currentLevel) { - return parseInt(currentLevel, 10) + 1; - }, - getReadingTime(text) { - const wordsPerMinute = 200; - const numberOfWords = text.split(/\s/g).length; - return Math.ceil(numberOfWords / wordsPerMinute); - } + getNextHeadingLevel(currentLevel) { + return parseInt(currentLevel, 10) + 1; + }, + getReadingTime(text) { + const wordsPerMinute = 200; + const numberOfWords = text.split(/\s/g).length; + return Math.ceil(numberOfWords / wordsPerMinute); + }, }; diff --git a/packages/docs/src/_data/styleguide.js b/packages/docs/src/_data/styleguide.js index 4969bec39..de64437d5 100644 --- a/packages/docs/src/_data/styleguide.js +++ b/packages/docs/src/_data/styleguide.js @@ -1,28 +1,28 @@ const tokens = require('./tokens.json'); module.exports = { - colors() { - let response = []; + colors() { + let response = []; - Object.keys(tokens.colors).forEach(key => { - response.push({ - value: tokens.colors[key], - key - }); - }); + Object.keys(tokens.colors).forEach((key) => { + response.push({ + value: tokens.colors[key], + key, + }); + }); - return response; - }, - sizes() { - let response = []; + return response; + }, + sizes() { + let response = []; - Object.keys(tokens['size-scale']).forEach(key => { - response.push({ - value: tokens['size-scale'][key], - key - }); - }); + Object.keys(tokens['size-scale']).forEach((key) => { + response.push({ + value: tokens['size-scale'][key], + key, + }); + }); - return response; - } + return response; + }, }; diff --git a/packages/docs/src/admin/previews.js b/packages/docs/src/admin/previews.js index 82dcd1f2c..9fa3d7589 100644 --- a/packages/docs/src/admin/previews.js +++ b/packages/docs/src/admin/previews.js @@ -7,82 +7,82 @@ env.addFilter('markdownFilter', markdownFilter); env.addFilter('dateFilter', dateFilter); const Preview = ({entry, path, context}) => { - const data = context(entry.get('data').toJS()); - const html = env.render(path, {...data, helpers}); - return
; + const data = context(entry.get('data').toJS()); + const html = env.render(path, {...data, helpers}); + return
; }; const Home = ({entry}) => ( - ({ - title, - content: markdownFilter(body), - postsHeading, - archiveButtonText, - collections: { - postFeed: [ - { - url: 'javascript:void(0)', - date: new Date(), - data: { - title: 'Sample Post' - } - } - ] - } - })} - /> + ({ + title, + content: markdownFilter(body), + postsHeading, + archiveButtonText, + collections: { + postFeed: [ + { + url: 'javascript:void(0)', + date: new Date(), + data: { + title: 'Sample Post', + }, + }, + ], + }, + })} + /> ); const Post = ({entry}) => ( - ({ - title, - date, - content: markdownFilter(body || '') - })} - /> + ({ + title, + date, + content: markdownFilter(body || ''), + })} + /> ); const Page = ({entry}) => ( - ({ - title, - content: markdownFilter(body || '') - })} - /> + ({ + title, + content: markdownFilter(body || ''), + })} + /> ); const SiteData = ({entry}) => ( - ({ - site: { - name, - shortDesc, - showThemeCredit - } - })} - /> + ({ + site: { + name, + shortDesc, + showThemeCredit, + }, + })} + /> ); const Nav = ({entry}) => ( - ({ - navigation: { - items - } - })} - /> + ({ + navigation: { + items, + }, + })} + /> ); CMS.registerPreviewTemplate('home', Home); diff --git a/packages/docs/src/admin/util.js b/packages/docs/src/admin/util.js index 302b159cf..53db2e8ec 100644 --- a/packages/docs/src/admin/util.js +++ b/packages/docs/src/admin/util.js @@ -3,9 +3,4 @@ import dateFilter from '../filters/date-filter'; import markdownFilter from '../filters/markdown-filter'; import w3DateFilter from '../filters/w3-date-filter'; -export { - helpers, - dateFilter, - markdownFilter, - w3DateFilter, -}; +export {helpers, dateFilter, markdownFilter, w3DateFilter}; diff --git a/packages/docs/src/filters/date-filter.js b/packages/docs/src/filters/date-filter.js index 5206da52f..2b4904744 100644 --- a/packages/docs/src/filters/date-filter.js +++ b/packages/docs/src/filters/date-filter.js @@ -1,15 +1,28 @@ // Stolen from https://stackoverflow.com/a/31615643 -const appendSuffix = n => { - var s = ['th', 'st', 'nd', 'rd'], - v = n % 100; - return n + (s[(v - 20) % 10] || s[v] || s[0]); +const appendSuffix = (n) => { + var s = ['th', 'st', 'nd', 'rd'], + v = n % 100; + return n + (s[(v - 20) % 10] || s[v] || s[0]); }; module.exports = function dateFilter(value) { - const dateObject = new Date(value); + const dateObject = new Date(value); - const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; - const dayWithSuffix = appendSuffix(dateObject.getDate()); + const months = [ + 'January', + 'February', + 'March', + 'April', + 'May', + 'June', + 'July', + 'August', + 'September', + 'October', + 'November', + 'December', + ]; + const dayWithSuffix = appendSuffix(dateObject.getDate()); - return `${dayWithSuffix} ${months[dateObject.getMonth()]} ${dateObject.getFullYear()}`; + return `${dayWithSuffix} ${months[dateObject.getMonth()]} ${dateObject.getFullYear()}`; }; diff --git a/packages/docs/src/filters/markdown-filter.js b/packages/docs/src/filters/markdown-filter.js index 530c2f571..e2298ce25 100644 --- a/packages/docs/src/filters/markdown-filter.js +++ b/packages/docs/src/filters/markdown-filter.js @@ -1,9 +1,9 @@ const markdownIt = require('markdown-it')({ - html: true, - breaks: true, - linkify: true + html: true, + breaks: true, + linkify: true, }); module.exports = function markdown(value) { - return markdownIt.render(value); + return markdownIt.render(value); }; diff --git a/packages/docs/src/filters/w3-date-filter.js b/packages/docs/src/filters/w3-date-filter.js index d31538da4..39c0f7ca8 100644 --- a/packages/docs/src/filters/w3-date-filter.js +++ b/packages/docs/src/filters/w3-date-filter.js @@ -1,5 +1,5 @@ module.exports = function w3cDate(value) { - const dateObject = new Date(value); + const dateObject = new Date(value); - return dateObject.toISOString(); + return dateObject.toISOString(); }; diff --git a/packages/docs/src/js/components/theme-toggle.js b/packages/docs/src/js/components/theme-toggle.js index 7e93571a2..63d6fb387 100644 --- a/packages/docs/src/js/components/theme-toggle.js +++ b/packages/docs/src/js/components/theme-toggle.js @@ -2,97 +2,97 @@ const html = String.raw; class ThemeToggle extends HTMLElement { - constructor() { - super(); - - this.STORAGE_KEY = 'user-color-scheme'; - this.COLOR_MODE_KEY = '--color-mode'; - } - - connectedCallback() { - this.render(); - } - - getCSSCustomProp(propKey) { - let response = getComputedStyle(document.documentElement).getPropertyValue(propKey); - - // Tidy up the string if there’s something to work with - if (response.length) { - response = response.replace(/\'|"/g, '').trim(); - } - - // Return the string response by default - return response; - } - - applySetting(passedSetting) { - let currentSetting = passedSetting || localStorage.getItem(this.STORAGE_KEY); - - if (currentSetting) { - document.documentElement.setAttribute('data-user-color-scheme', currentSetting); - this.setButtonLabelAndStatus(currentSetting); - } else { - this.setButtonLabelAndStatus(this.getCSSCustomProp(this.COLOR_MODE_KEY)); - } - } - - toggleSetting() { - let currentSetting = localStorage.getItem(this.STORAGE_KEY); - - switch (currentSetting) { - case null: - currentSetting = - this.getCSSCustomProp(this.COLOR_MODE_KEY) === 'dark' ? 'light' : 'dark'; - break; - case 'light': - currentSetting = 'dark'; - break; - case 'dark': - currentSetting = 'light'; - break; - } - - localStorage.setItem(this.STORAGE_KEY, currentSetting); - - return currentSetting; - } - - setButtonLabelAndStatus(currentSetting) { - this.modeToggleButton.innerText = `${ - currentSetting === 'dark' ? 'Light' : 'Dark' - } theme`; - this.modeStatusElement.innerText = `Color mode is now "${currentSetting}"`; - } - - render() { - this.innerHTML = html` -
-
- -
- `; - - this.afterRender(); - } - - afterRender() { - this.modeToggleButton = document.querySelector('.js-mode-toggle'); - this.modeStatusElement = document.querySelector('.js-mode-status'); - - this.modeToggleButton.addEventListener('click', evt => { - evt.preventDefault(); - - this.applySetting(this.toggleSetting()); - }); - - this.applySetting(); - } + constructor() { + super(); + + this.STORAGE_KEY = 'user-color-scheme'; + this.COLOR_MODE_KEY = '--color-mode'; + } + + connectedCallback() { + this.render(); + } + + getCSSCustomProp(propKey) { + let response = getComputedStyle(document.documentElement).getPropertyValue(propKey); + + // Tidy up the string if there’s something to work with + if (response.length) { + response = response.replace(/\'|"/g, '').trim(); + } + + // Return the string response by default + return response; + } + + applySetting(passedSetting) { + let currentSetting = passedSetting || localStorage.getItem(this.STORAGE_KEY); + + if (currentSetting) { + document.documentElement.setAttribute('data-user-color-scheme', currentSetting); + this.setButtonLabelAndStatus(currentSetting); + } else { + this.setButtonLabelAndStatus(this.getCSSCustomProp(this.COLOR_MODE_KEY)); + } + } + + toggleSetting() { + let currentSetting = localStorage.getItem(this.STORAGE_KEY); + + switch (currentSetting) { + case null: + currentSetting = + this.getCSSCustomProp(this.COLOR_MODE_KEY) === 'dark' ? 'light' : 'dark'; + break; + case 'light': + currentSetting = 'dark'; + break; + case 'dark': + currentSetting = 'light'; + break; + } + + localStorage.setItem(this.STORAGE_KEY, currentSetting); + + return currentSetting; + } + + setButtonLabelAndStatus(currentSetting) { + this.modeToggleButton.innerText = `${ + currentSetting === 'dark' ? 'Light' : 'Dark' + } theme`; + this.modeStatusElement.innerText = `Color mode is now "${currentSetting}"`; + } + + render() { + this.innerHTML = html` +
+
+ +
+ `; + + this.afterRender(); + } + + afterRender() { + this.modeToggleButton = document.querySelector('.js-mode-toggle'); + this.modeStatusElement = document.querySelector('.js-mode-status'); + + this.modeToggleButton.addEventListener('click', (evt) => { + evt.preventDefault(); + + this.applySetting(this.toggleSetting()); + }); + + this.applySetting(); + } } if ('customElements' in window) { - customElements.define('theme-toggle', ThemeToggle); + customElements.define('theme-toggle', ThemeToggle); } export default ThemeToggle; diff --git a/packages/docs/src/js/primary-nav.js b/packages/docs/src/js/primary-nav.js index 867ca265a..3cf7d54a8 100644 --- a/packages/docs/src/js/primary-nav.js +++ b/packages/docs/src/js/primary-nav.js @@ -8,14 +8,14 @@ * 3) If the nav dropdown trigger parent already has active class, remove it. * 4) If the nav dropdown trigger parent does not have an active class, add it. */ -(function() { +(function () { var navDropdownListItem = document.querySelector('.js-nav-dropdown'); var navLink = document.querySelectorAll('.js-nav-dropdown-trigger'); /* 1 */ for (i = 0; i < navLink.length; i++) { /* 1 */ - navLink[i].addEventListener('click', function(event) { + navLink[i].addEventListener('click', function (event) { /* 2 */ event.preventDefault(); var navLinkParent = this.parentNode; /* 2 */ @@ -64,7 +64,7 @@ for (i = 0; i < navToggle.length; i++) { /* 1 */ - navToggle[i].addEventListener('click', function(event) { + navToggle[i].addEventListener('click', function (event) { /* 2 */ event.preventDefault(); var navToggleElement = this; diff --git a/packages/docs/src/transforms/html-min-transform.js b/packages/docs/src/transforms/html-min-transform.js index 7d0c8f99b..5c5c71c23 100644 --- a/packages/docs/src/transforms/html-min-transform.js +++ b/packages/docs/src/transforms/html-min-transform.js @@ -1,14 +1,14 @@ const htmlmin = require('html-minifier'); module.exports = function htmlMinTransform(value, outputPath) { - if (outputPath.indexOf('.html') > -1) { - let minified = htmlmin.minify(value, { - useShortDoctype: true, - removeComments: true, - collapseWhitespace: true, - minifyCSS: true - }); - return minified; - } - return value; + if (outputPath.indexOf('.html') > -1) { + let minified = htmlmin.minify(value, { + useShortDoctype: true, + removeComments: true, + collapseWhitespace: true, + minifyCSS: true, + }); + return minified; + } + return value; }; diff --git a/packages/docs/src/transforms/parse-transform.js b/packages/docs/src/transforms/parse-transform.js index 541f04cf7..3451075cd 100644 --- a/packages/docs/src/transforms/parse-transform.js +++ b/packages/docs/src/transforms/parse-transform.js @@ -3,77 +3,76 @@ const {JSDOM} = jsdom; const minify = require('../utils/minify.js'); const slugify = require('slugify'); -module.exports = function(value, outputPath) { - if (outputPath.endsWith('.html')) { - const DOM = new JSDOM(value, { - resources: 'usable' - }); - - const document = DOM.window.document; - const articleImages = [...document.querySelectorAll('main article img')]; - const articleHeadings = [ - ...document.querySelectorAll('main article h2, main article h3') - ]; - const articleEmbeds = [...document.querySelectorAll('main article iframe')]; - - if (articleImages.length) { - articleImages.forEach(image => { - image.setAttribute('loading', 'lazy'); - - // If an image has a title it means that the user added a caption - // so replace the image with a figure containing that image and a caption - if (image.hasAttribute('title')) { - const figure = document.createElement('figure'); - const figCaption = document.createElement('figcaption'); - - figCaption.innerHTML = image.getAttribute('title'); - - image.removeAttribute('title'); - - figure.appendChild(image.cloneNode(true)); - figure.appendChild(figCaption); - - image.replaceWith(figure); - } - - }); - } - - if (articleHeadings.length) { - // Loop each heading and add a little anchor and an ID to each one - articleHeadings.forEach(heading => { - const headingSlug = slugify(heading.textContent.toLowerCase()); - const anchor = document.createElement('a'); - - anchor.setAttribute('href', `#heading-${headingSlug}`); - anchor.classList.add('heading-permalink'); - anchor.innerHTML = minify(` +module.exports = function (value, outputPath) { + if (outputPath.endsWith('.html')) { + const DOM = new JSDOM(value, { + resources: 'usable', + }); + + const document = DOM.window.document; + const articleImages = [...document.querySelectorAll('main article img')]; + const articleHeadings = [ + ...document.querySelectorAll('main article h2, main article h3'), + ]; + const articleEmbeds = [...document.querySelectorAll('main article iframe')]; + + if (articleImages.length) { + articleImages.forEach((image) => { + image.setAttribute('loading', 'lazy'); + + // If an image has a title it means that the user added a caption + // so replace the image with a figure containing that image and a caption + if (image.hasAttribute('title')) { + const figure = document.createElement('figure'); + const figCaption = document.createElement('figcaption'); + + figCaption.innerHTML = image.getAttribute('title'); + + image.removeAttribute('title'); + + figure.appendChild(image.cloneNode(true)); + figure.appendChild(figCaption); + + image.replaceWith(figure); + } + }); + } + + if (articleHeadings.length) { + // Loop each heading and add a little anchor and an ID to each one + articleHeadings.forEach((heading) => { + const headingSlug = slugify(heading.textContent.toLowerCase()); + const anchor = document.createElement('a'); + + anchor.setAttribute('href', `#heading-${headingSlug}`); + anchor.classList.add('heading-permalink'); + anchor.innerHTML = minify(` permalink `); - heading.setAttribute('id', `heading-${headingSlug}`); - heading.appendChild(anchor); - }); - } + heading.setAttribute('id', `heading-${headingSlug}`); + heading.appendChild(anchor); + }); + } - // Look for videos are wrap them in a container element - if (articleEmbeds.length) { - articleEmbeds.forEach(embed => { - if (embed.hasAttribute('allowfullscreen')) { - const player = document.createElement('div'); + // Look for videos are wrap them in a container element + if (articleEmbeds.length) { + articleEmbeds.forEach((embed) => { + if (embed.hasAttribute('allowfullscreen')) { + const player = document.createElement('div'); - player.classList.add('video-player'); + player.classList.add('video-player'); - player.appendChild(embed.cloneNode(true)); + player.appendChild(embed.cloneNode(true)); - embed.replaceWith(player); - } - }); - } + embed.replaceWith(player); + } + }); + } - return '\r\n' + document.documentElement.outerHTML; - } - return value; + return '\r\n' + document.documentElement.outerHTML; + } + return value; }; diff --git a/packages/docs/src/utils/minify.js b/packages/docs/src/utils/minify.js index dd80e240c..19248c5d8 100644 --- a/packages/docs/src/utils/minify.js +++ b/packages/docs/src/utils/minify.js @@ -1,3 +1,3 @@ module.exports = function minify(input) { - return input.replace(/\s{2,}/g, '').replace(/\'/g, '"'); + return input.replace(/\s{2,}/g, '').replace(/\'/g, '"'); }; diff --git a/packages/edition-node-gulp/gulpfile.js b/packages/edition-node-gulp/gulpfile.js index 4ef683b09..fd039bad7 100644 --- a/packages/edition-node-gulp/gulpfile.js +++ b/packages/edition-node-gulp/gulpfile.js @@ -34,29 +34,29 @@ function serve() { }); } -gulp.task('patternlab:version', function() { +gulp.task('patternlab:version', function () { console.log(patternlab.version()); }); -gulp.task('patternlab:patternsonly', function() { +gulp.task('patternlab:patternsonly', function () { patternlab.patternsonly(config.cleanPublic); }); -gulp.task('patternlab:liststarterkits', function() { +gulp.task('patternlab:liststarterkits', function () { patternlab.liststarterkits(); }); -gulp.task('patternlab:loadstarterkit', function() { +gulp.task('patternlab:loadstarterkit', function () { patternlab.loadstarterkit(argv.kit, argv.clean); }); -gulp.task('patternlab:build', function() { +gulp.task('patternlab:build', function () { build().then(() => { // do something else when this promise resolves }); }); -gulp.task('patternlab:serve', function() { +gulp.task('patternlab:serve', function () { serve().then(() => { // do something else when this promise resolves }); diff --git a/packages/edition-node-gulp/source/css/pattern-scaffolding.css b/packages/edition-node-gulp/source/css/pattern-scaffolding.css index 2a69457ed..b09172fc8 100644 --- a/packages/edition-node-gulp/source/css/pattern-scaffolding.css +++ b/packages/edition-node-gulp/source/css/pattern-scaffolding.css @@ -5,7 +5,7 @@ */ #sg-patterns { -webkit-box-sizing: border-box !important; - box-sizing: border-box !important; + box-sizing: border-box !important; max-width: 100%; padding: 0 0.5em; } @@ -24,15 +24,15 @@ display: -ms-flexbox; display: flex; -ms-flex-wrap: wrap; - flex-wrap: wrap; + flex-wrap: wrap; list-style: none !important; padding: 0 !important; margin: 0 !important; } .sg-colors li { -webkit-box-flex: 1; - -ms-flex: auto; - flex: auto; + -ms-flex: auto; + flex: auto; padding: 0.3em; margin: 0 0.5em 0.5em 0; min-width: 5em; diff --git a/packages/edition-node-gulp/source/css/style.css b/packages/edition-node-gulp/source/css/style.css index 588a45915..04f745349 100644 --- a/packages/edition-node-gulp/source/css/style.css +++ b/packages/edition-node-gulp/source/css/style.css @@ -1,3 +1,3 @@ /* * YOUR STYLES HERE - */ \ No newline at end of file + */ diff --git a/packages/edition-node/helpers/test.js b/packages/edition-node/helpers/test.js index 8b32ed799..6ddbc2bba 100644 --- a/packages/edition-node/helpers/test.js +++ b/packages/edition-node/helpers/test.js @@ -1,5 +1,5 @@ -module.exports = function(Handlebars) { - Handlebars.registerHelper('test', function() { +module.exports = function (Handlebars) { + Handlebars.registerHelper('test', function () { return 'This is a test helper'; }); }; diff --git a/packages/engine-handlebars/lib/engine_handlebars.js b/packages/engine-handlebars/lib/engine_handlebars.js index f89788ac1..f3a3461c8 100644 --- a/packages/engine-handlebars/lib/engine_handlebars.js +++ b/packages/engine-handlebars/lib/engine_handlebars.js @@ -41,8 +41,8 @@ function escapeAtPartialBlock(partialString) { } function loadHelpers(helpers) { - helpers.forEach(globPattern => { - glob.sync(globPattern).forEach(filePath => { + helpers.forEach((globPattern) => { + glob.sync(globPattern).forEach((filePath) => { require(path.join(process.cwd(), filePath))(Handlebars); }); }); @@ -68,7 +68,7 @@ const engine_handlebars = { return Promise.resolve(compiled(data)); }, - registerPartial: function(pattern) { + registerPartial: function (pattern) { // register exact partial name Handlebars.registerPartial(pattern.patternPartial, pattern.template); @@ -80,7 +80,7 @@ const engine_handlebars = { const matches = pattern.template.match(findPartialsRE); return matches; }, - findPartialsWithStyleModifiers: function() { + findPartialsWithStyleModifiers: function () { // TODO: make the call to this from oPattern objects conditional on their // being implemented here. return []; @@ -88,24 +88,24 @@ const engine_handlebars = { // returns any patterns that match {{> value(foo:"bar") }} or {{> // value:mod(foo:"bar") }} within the pattern - findPartialsWithPatternParameters: function() { + findPartialsWithPatternParameters: function () { // TODO: make the call to this from oPattern objects conditional on their // being implemented here. return []; }, - findListItems: function(pattern) { + findListItems: function (pattern) { const matches = pattern.template.match(findListItemsRE); return matches; }, // given a pattern, and a partial string, tease out the "pattern key" and // return it. - findPartial: function(partialString) { + findPartial: function (partialString) { const partial = partialString.replace(findPartialsRE, '$1'); return partial; }, - spawnFile: function(config, fileName) { + spawnFile: function (config, fileName) { const paths = config.paths; const metaFilePath = path.resolve(paths.source.meta, fileName); try { @@ -127,7 +127,7 @@ const engine_handlebars = { * @param {object} config - the global config object from core, since we won't * assume it's already present */ - spawnMeta: function(config) { + spawnMeta: function (config) { this.spawnFile(config, '_head.hbs'); this.spawnFile(config, '_foot.hbs'); }, @@ -138,7 +138,7 @@ const engine_handlebars = { * * @param {object} config - the global config object from core */ - usePatternLabConfig: function(config) { + usePatternLabConfig: function (config) { let helpers; try { diff --git a/packages/engine-liquid/lib/engine_liquid.js b/packages/engine-liquid/lib/engine_liquid.js index 6f00a0e53..b5e5dd56b 100644 --- a/packages/engine-liquid/lib/engine_liquid.js +++ b/packages/engine-liquid/lib/engine_liquid.js @@ -11,11 +11,11 @@ const fs = require('fs-extra'); const path = require('path'); -const isDirectory = source => fs.lstatSync(source).isDirectory(); -const getDirectories = source => +const isDirectory = (source) => fs.lstatSync(source).isDirectory(); +const getDirectories = (source) => fs .readdirSync(source) - .map(name => path.join(source, name)) + .map((name) => path.join(source, name)) .filter(isDirectory); const { lstatSync, readdirSync } = require('fs'); @@ -53,10 +53,10 @@ module.exports = { renderPattern: function renderPattern(pattern, data, partials) { return engine .parseAndRender(pattern.template, data) - .then(function(html) { + .then(function (html) { return html; }) - .catch(function(ex) { + .catch(function (ex) { console.log(40, ex); }); }, @@ -86,7 +86,7 @@ module.exports = { var matches = this.patternMatcher(pattern, this.findPartialsRE); return matches; }, - findPartialsWithStyleModifiers: function(pattern) { + findPartialsWithStyleModifiers: function (pattern) { var matches = this.patternMatcher( pattern, this.findPartialsWithStyleModifiersRE @@ -96,28 +96,28 @@ module.exports = { // returns any patterns that match {{> value(foo:"bar") }} or {{> // value:mod(foo:"bar") }} within the pattern - findPartialsWithPatternParameters: function(pattern) { + findPartialsWithPatternParameters: function (pattern) { var matches = this.patternMatcher( pattern, this.findPartialsWithPatternParametersRE ); return matches; }, - findListItems: function(pattern) { + findListItems: function (pattern) { var matches = this.patternMatcher(pattern, this.findListItemsRE); return matches; }, // given a pattern, and a partial string, tease out the "pattern key" and // return it. - findPartial_new: function(partialString) { + findPartial_new: function (partialString) { var partial = partialString.replace(this.findPartialRE, '$1'); return partial; }, // GTP: the old implementation works better. We might not need // this.findPartialRE anymore if it works in all cases! - findPartial: function(partialString) { + findPartial: function (partialString) { //strip out the template cruft var foundPatternPartial = partialString .replace('{{> ', '') @@ -145,7 +145,7 @@ module.exports = { * * @param {object} config - the global config object from core */ - usePatternLabConfig: function(config) { + usePatternLabConfig: function (config) { patternLabConfig = config; let patternsPath = patternLabConfig.paths.source.patterns; @@ -163,7 +163,7 @@ module.exports = { }); }, - spawnFile: function(config, fileName) { + spawnFile: function (config, fileName) { const paths = config.paths; const metaFilePath = path.resolve(paths.source.meta, fileName); @@ -187,7 +187,7 @@ module.exports = { * @param {object} config - the global config object from core, since we won't * assume it's already present */ - spawnMeta: function(config) { + spawnMeta: function (config) { this.spawnFile(config, '_head.liquid'); this.spawnFile(config, '_foot.liquid'); }, diff --git a/packages/engine-mustache/lib/engine_mustache.js b/packages/engine-mustache/lib/engine_mustache.js index fb65ec398..e39359490 100644 --- a/packages/engine-mustache/lib/engine_mustache.js +++ b/packages/engine-mustache/lib/engine_mustache.js @@ -81,7 +81,7 @@ const engine_mustache = { return matches; }, - spawnFile: function(config, fileName) { + spawnFile: function (config, fileName) { const paths = config.paths; const metaFilePath = path.resolve(paths.source.meta, fileName); try { @@ -103,7 +103,7 @@ const engine_mustache = { * @param {object} config - the global config object from core, since we won't * assume it's already present */ - spawnMeta: function(config) { + spawnMeta: function (config) { this.spawnFile(config, '_head.mustache'); this.spawnFile(config, '_foot.mustache'); }, @@ -112,31 +112,31 @@ const engine_mustache = { findPartials: function findPartials(pattern) { return this.patternMatcher(pattern, this.findPartialsRE); }, - findPartialsWithStyleModifiers: function(pattern) { + findPartialsWithStyleModifiers: function (pattern) { return this.patternMatcher(pattern, this.findPartialsWithStyleModifiersRE); }, // returns any patterns that match {{> value(foo:"bar") }} or {{> // value:mod(foo:"bar") }} within the pattern - findPartialsWithPatternParameters: function(pattern) { + findPartialsWithPatternParameters: function (pattern) { return this.patternMatcher( pattern, this.findPartialsWithPatternParametersRE ); }, - findListItems: function(pattern) { + findListItems: function (pattern) { return this.patternMatcher(pattern, this.findListItemsRE); }, // given a pattern, and a partial string, tease out the "pattern key" and // return it. - findPartial_new: function(partialString) { + findPartial_new: function (partialString) { return partialString.replace(this.findPartialRE, '$1'); }, // GTP: the old implementation works better. We might not need // this.findPartialRE anymore if it works in all cases! - findPartial: function(partialString) { + findPartial: function (partialString) { //strip out the template cruft let foundPatternPartial = partialString .replace('{{> ', '') @@ -164,7 +164,7 @@ const engine_mustache = { * * @param {object} config - the global config object from core */ - usePatternLabConfig: function(config) { + usePatternLabConfig: function (config) { patternLabConfig = config; }, }; diff --git a/packages/engine-nunjucks/lib/engine_nunjucks.js b/packages/engine-nunjucks/lib/engine_nunjucks.js index cfa6db15d..c4dffb0d8 100644 --- a/packages/engine-nunjucks/lib/engine_nunjucks.js +++ b/packages/engine-nunjucks/lib/engine_nunjucks.js @@ -59,7 +59,7 @@ const engine_nunjucks = { }, // given a pattern, and a partial string, tease out the "pattern key" and return it. - findPartial: function(partialString) { + findPartial: function (partialString) { try { let partial = partialString.match(this.findPartialKeyRE)[1]; partial = partial.replace(/["']/g, ''); @@ -72,7 +72,7 @@ const engine_nunjucks = { }, // keep track of partials and their paths so we can replace the name with the path - registerPartial: function(pattern) { + registerPartial: function (pattern) { // only register each partial once. Otherwise we'll eat up a ton of memory. if (partialRegistry.indexOf(pattern.patternPartial) === -1) { partialRegistry[pattern.patternPartial] = pattern.relPath.replace( @@ -83,22 +83,22 @@ const engine_nunjucks = { }, // still requires the mustache syntax because of the way PL handles lists - findListItems: function(pattern) { + findListItems: function (pattern) { const matches = pattern.template.match(this.findListItemsRE); return matches; }, // handled by nunjucks. This is here to keep PL from erroring - findPartialsWithStyleModifiers: function() { + findPartialsWithStyleModifiers: function () { return null; }, // handled by nunjucks. This is here to keep PL from erroring - findPartialsWithPatternParameters: function() { + findPartialsWithPatternParameters: function () { return null; }, - spawnFile: function(config, fileName) { + spawnFile: function (config, fileName) { const paths = config.paths; const metaFilePath = path.resolve(paths.source.meta, fileName); try { @@ -120,7 +120,7 @@ const engine_nunjucks = { * @param {object} config - the global config object from core, since we won't * assume it's already present */ - spawnMeta: function(config) { + spawnMeta: function (config) { this.spawnFile(config, '_head.njk'); this.spawnFile(config, '_foot.njk'); }, @@ -131,12 +131,12 @@ const engine_nunjucks = { * * @param {object} config - the global config object from core */ - usePatternLabConfig: function(config) { + usePatternLabConfig: function (config) { // Create Pattern Loader // Since Pattern Lab includes are not path based we need a custom loader for Nunjucks. function PatternLoader() {} - PatternLoader.prototype.getSource = function(name) { + PatternLoader.prototype.getSource = function (name) { const fullPath = path.resolve( config.paths.source.patterns, partialRegistry[name] @@ -169,7 +169,7 @@ const engine_nunjucks = { } if (extensions) { - extensions.forEach(extensionPath => { + extensions.forEach((extensionPath) => { // Load any user Defined configurations const nunjucksConfigPath = path.join(process.cwd(), extensionPath); diff --git a/packages/engine-react/lib/engine_react.js b/packages/engine-react/lib/engine_react.js index b0f01cdd2..3c33f1eca 100644 --- a/packages/engine-react/lib/engine_react.js +++ b/packages/engine-react/lib/engine_react.js @@ -64,7 +64,7 @@ function babelTransform(pattern) { // eval() module code in this little scope that injects our // custom wrap of require(); - (require => { + ((require) => { /* eslint-disable no-eval */ transpiledModule = eval(transpiledModule.code); })(customRequire); @@ -110,7 +110,7 @@ var engine_react = { htmlOutput: staticMarkup, }); - return Promise.resolve(renderedHTML).catch(e => { + return Promise.resolve(renderedHTML).catch((e) => { var errorMessage = `Error rendering React pattern "${ pattern.patternName }" (${pattern.relPath}): [${e.toString()}]`; @@ -161,7 +161,7 @@ var engine_react = { } // Remove unregistered imports from the matches - matches.map(m => { + matches.map((m) => { const key = self.findPartial(m); if (!registeredComponents.byPatternPartial[key]) { const i = matches.indexOf(m); @@ -224,7 +224,7 @@ var engine_react = { * * @param {object} config - the global config object from core */ - usePatternLabConfig: function(config) { + usePatternLabConfig: function (config) { patternLabConfig = config; try { diff --git a/packages/engine-twig-php/lib/engine_twig_php.js b/packages/engine-twig-php/lib/engine_twig_php.js index 5282e0f14..73dc9c560 100644 --- a/packages/engine-twig-php/lib/engine_twig_php.js +++ b/packages/engine-twig-php/lib/engine_twig_php.js @@ -37,7 +37,7 @@ const engine_twig_php = { * * @param {object} config - the global config object from core */ - usePatternLabConfig: function(config) { + usePatternLabConfig: function (config) { patternLabConfig = config; if (!config.engines.twig) { @@ -92,7 +92,7 @@ const engine_twig_php = { twigRenderer .render(patternPath, data) - .then(results => { + .then((results) => { if (results.ok) { resolve(results.html + details); } else { @@ -108,7 +108,7 @@ const engine_twig_php = { } } }) - .catch(error => { + .catch((error) => { reject(error); }); }); @@ -123,7 +123,7 @@ const engine_twig_php = { */ spawnMeta(config) { const { paths } = config; - ['_head.twig', '_foot.twig'].forEach(fileName => { + ['_head.twig', '_foot.twig'].forEach((fileName) => { const metaFilePath = path.resolve(paths.source.meta, fileName); try { fs.statSync(metaFilePath); @@ -155,11 +155,11 @@ const engine_twig_php = { // {% // include '@molecules/teaser-card/teaser-card.twig' // %} - findPartials: function(pattern) { + findPartials: function (pattern) { const matches = pattern.template.match(this.findPartialsRE); const filteredMatches = matches && - matches.filter(match => { + matches.filter((match) => { // Filter out programmatically created includes. // i.e. {% include '@namespace/icons/assets/' ~ name ~ '.svg' %} return match.indexOf('~') === -1; @@ -185,14 +185,14 @@ const engine_twig_php = { // Given a pattern, and a partial string, tease out the "pattern key" and // return it. - findPartial: function(partialString) { + findPartial: function (partialString) { try { let partial = partialString.match(this.findPartialKeyRE)[0]; partial = partial.replace(/"/g, ''); partial = partial.replace(/'/g, ''); // Check if namespaces is not empty. - const selectedNamespace = this.namespaces.filter(namespace => { + const selectedNamespace = this.namespaces.filter((namespace) => { // Check to see if this partial contains within the namespace id. return partial.indexOf(`@${namespace.id}`) !== -1; }); diff --git a/packages/engine-underscore/_meta/_head.html b/packages/engine-underscore/_meta/_head.html index b1f5c1ce0..56d9a2432 100644 --- a/packages/engine-underscore/_meta/_head.html +++ b/packages/engine-underscore/_meta/_head.html @@ -2,15 +2,22 @@ {{ title }} - + - - + + {{{ patternLabHead }}} - diff --git a/packages/engine-underscore/lib/engine_underscore.js b/packages/engine-underscore/lib/engine_underscore.js index f6019d913..a562a02a9 100644 --- a/packages/engine-underscore/lib/engine_underscore.js +++ b/packages/engine-underscore/lib/engine_underscore.js @@ -21,10 +21,10 @@ const fs = require('fs-extra'); const path = require('path'); -var _ = require('underscore'); +const _ = require('underscore'); -var partialRegistry = {}; -var errorStyling = ` +const partialRegistry = {}; +const errorStyling = `