diff --git a/packages/core/src/part.mjs b/packages/core/src/part.mjs index b40511ea380..7abf5e56598 100644 --- a/packages/core/src/part.mjs +++ b/packages/core/src/part.mjs @@ -175,7 +175,7 @@ Part.prototype.shorthand = function () { shorthand.measurements = new Proxy(this.context.settings.measurements, { get: function (measurements, name) { if (typeof measurements[name] === 'undefined') - self.context.store.log.warning( + self.context.store.log.warn( `${self.name} tried to access \`measurements.${name}\` but it is \`undefined\`` ) return Reflect.get(...arguments) @@ -185,9 +185,7 @@ Part.prototype.shorthand = function () { shorthand.options = new Proxy(this.context.settings.options, { get: function (options, name) { if (typeof options[name] === 'undefined') - self.context.store.log.warning( - `Tried to access \`options.${name}\` but it is \`undefined\`` - ) + self.context.store.log.warn(`Tried to access \`options.${name}\` but it is \`undefined\``) return Reflect.get(...arguments) }, set: (options, name, value) => (self.context.settings.options[name] = value), @@ -195,7 +193,7 @@ Part.prototype.shorthand = function () { shorthand.absoluteOptions = new Proxy(this.context.settings.absoluteOptions, { get: function (absoluteOptions, name) { if (typeof absoluteOptions[name] === 'undefined') - self.context.store.log.warning( + self.context.store.log.warn( `Tried to access \`absoluteOptions.${name}\` but it is \`undefined\`` ) return Reflect.get(...arguments) @@ -361,7 +359,7 @@ Part.prototype.__macroClosure = function (props) { const macro = utils.__macroName(key) if (typeof self[macro] === 'function') self[macro](args, props) else if ('context' in self) - self.context.store.log.warning('Unknown macro `' + key + '` used in ' + self.name) + self.context.store.log.warn('Unknown macro `' + key + '` used in ' + self.name) } return method @@ -377,7 +375,7 @@ Part.prototype.__unitsClosure = function () { const self = this const method = function (value) { if (typeof value !== 'number') - self.context.store.log.warning( + self.context.store.log.warn( `Calling \`units(value)\` but \`value\` is not a number (\`${typeof value}\`)` ) return utils.units(value, self.context.settings.units) diff --git a/packages/core/src/path.mjs b/packages/core/src/path.mjs index 32d9bd1d873..32e8d6eab4a 100644 --- a/packages/core/src/path.mjs +++ b/packages/core/src/path.mjs @@ -47,9 +47,9 @@ export function Path() { */ Path.prototype._curve = function (cp2, to) { if (to instanceof Point !== true) - this.log.warning('Called `Path._curve(cp2, to)` but `to` is not a `Point` object') + this.log.warn('Called `Path._curve(cp2, to)` but `to` is not a `Point` object') if (cp2 instanceof Point !== true) - this.log.warning('Called `Path._curve(cp2, to)` but `cp2` is not a `Point` object') + this.log.warn('Called `Path._curve(cp2, to)` but `cp2` is not a `Point` object') let cp1 = this.ops.slice(-1).pop().to this.ops.push({ type: 'curve', cp1, cp2, to }) @@ -150,11 +150,11 @@ Path.prototype.asRenderProps = function () { */ Path.prototype.attr = function (name, value, overwrite = false) { if (!name) - this.log.warning( + this.log.warn( 'Called `Path.attr(name, value, overwrite=false)` but `name` is undefined or false' ) if (typeof value === 'undefined') - this.log.warning('Called `Path.attr(name, value, overwrite=false)` but `value` is undefined') + this.log.warn('Called `Path.attr(name, value, overwrite=false)` but `value` is undefined') if (overwrite) this.log.debug( `Overwriting \`Path.attribute.${name}\` with ${value} (was: ${this.attributes.get(name)})` @@ -276,11 +276,11 @@ Path.prototype.close = function () { */ Path.prototype.curve = function (cp1, cp2, to) { if (to instanceof Point !== true) - this.log.warning('Called `Path.curve(cp1, cp2, to)` but `to` is not a `Point` object') + this.log.warn('Called `Path.curve(cp1, cp2, to)` but `to` is not a `Point` object') if (cp1 instanceof Point !== true) - this.log.warning('Called `Path.curve(cp1, cp2, to)` but `cp1` is not a `Point` object') + this.log.warn('Called `Path.curve(cp1, cp2, to)` but `cp1` is not a `Point` object') if (cp2 instanceof Point !== true) - this.log.warning('Called `Path.curve(cp1, cp2, to)` but `cp2` is not a `Point` object') + this.log.warn('Called `Path.curve(cp1, cp2, to)` but `cp2` is not a `Point` object') this.ops.push({ type: 'curve', cp1, cp2, to }) return this @@ -295,9 +295,9 @@ Path.prototype.curve = function (cp1, cp2, to) { */ Path.prototype.curve_ = function (cp1, to) { if (to instanceof Point !== true) - this.log.warning('Called `Path.curve_(cp1, to)` but `to` is not a `Point` object') + this.log.warn('Called `Path.curve_(cp1, to)` but `to` is not a `Point` object') if (cp1 instanceof Point !== true) - this.log.warning('Called `Path.curve_(cp1, to)` but `cp1` is not a `Point` object') + this.log.warn('Called `Path.curve_(cp1, to)` but `cp1` is not a `Point` object') let cp2 = to.copy() this.ops.push({ type: 'curve', cp1, cp2, to }) @@ -405,10 +405,9 @@ Path.prototype.hide = function () { * @return {object} this - The Path instance */ Path.prototype.insop = function (noopId, path) { - if (!noopId) - this.log.warning('Called `Path.insop(noopId, path)` but `noopId` is undefined or false') + if (!noopId) this.log.warn('Called `Path.insop(noopId, path)` but `noopId` is undefined or false') if (path instanceof Path !== true) - this.log.warning('Called `Path.insop(noopId, path) but `path` is not a `Path` object') + this.log.warn('Called `Path.insop(noopId, path) but `path` is not a `Path` object') let newPath = this.clone() for (let i in newPath.ops) { if (newPath.ops[i].type === 'noop' && newPath.ops[i].id === noopId) { @@ -561,7 +560,7 @@ Path.prototype.length = function () { */ Path.prototype.line = function (to) { if (to instanceof Point !== true) - this.log.warning('Called `Path.line(to)` but `to` is not a `Point` object') + this.log.warn('Called `Path.line(to)` but `to` is not a `Point` object') this.ops.push({ type: 'line', to }) return this @@ -575,7 +574,7 @@ Path.prototype.line = function (to) { */ Path.prototype.move = function (to) { if (to instanceof Point !== true) - this.log.warning('Called `Path.move(to)` but `to` is not a `Point` object') + this.log.warn('Called `Path.move(to)` but `to` is not a `Point` object') this.ops.push({ type: 'move', to }) return this @@ -761,9 +760,9 @@ Path.prototype.shiftFractionAlong = function (fraction, stepsPerMm = 10) { */ Path.prototype.smurve = function (cp2, to) { if (to instanceof Point !== true) - this.log.warning('Called `Path.smurve(cp2, to)` but `to` is not a `Point` object') + this.log.warn('Called `Path.smurve(cp2, to)` but `to` is not a `Point` object') if (cp2 instanceof Point !== true) - this.log.warning('Called `Path.smurve(cp2, to)` but `cp2` is not a `Point` object') + this.log.warn('Called `Path.smurve(cp2, to)` but `cp2` is not a `Point` object') // Retrieve cp1 from previous operation const prevOp = this.ops.slice(-1).pop() const cp1 = prevOp.cp2.rotate(180, prevOp.to) @@ -779,7 +778,7 @@ Path.prototype.smurve = function (cp2, to) { */ Path.prototype.smurve_ = function (to) { if (to instanceof Point !== true) - this.log.warning('Called `Path.smurve_(to)` but `to` is not a `Point` object') + this.log.warn('Called `Path.smurve_(to)` but `to` is not a `Point` object') // Retrieve cp1 from previous operation const prevOp = this.ops.slice(-1).pop() const cp1 = prevOp.cp2.rotate(180, prevOp.to) @@ -898,10 +897,8 @@ Path.prototype.start = function () { * @return {Path} this - This Path instance */ Path.prototype.translate = function (x, y) { - if (typeof x !== 'number') - this.log.warning('Called `Path.translate(x, y)` but `x` is not a number') - if (typeof y !== 'number') - this.log.warning('Called `Path.translate(x, y)` but `y` is not a number') + if (typeof x !== 'number') this.log.warn('Called `Path.translate(x, y)` but `x` is not a number') + if (typeof y !== 'number') this.log.warn('Called `Path.translate(x, y)` but `y` is not a number') let clone = this.clone() for (let op of clone.ops) { if (op.type !== 'close') { @@ -1126,11 +1123,11 @@ export function pathsProxy(paths, log) { set: (paths, name, value) => { // Constructor checks if (value instanceof Path !== true) - log.warning(`\`paths.${name}\` was set with a value that is not a \`Path\` object`) + log.warn(`\`paths.${name}\` was set with a value that is not a \`Path\` object`) try { value.name = name } catch (err) { - log.warning(`Could not set \`name\` property on \`paths.${name}\``) + log.warn(`Could not set \`name\` property on \`paths.${name}\``) } return (paths[name] = value) }, diff --git a/packages/core/src/pattern/pattern-plugins.mjs b/packages/core/src/pattern/pattern-plugins.mjs index a8006abf0ec..1f010625792 100644 --- a/packages/core/src/pattern/pattern-plugins.mjs +++ b/packages/core/src/pattern/pattern-plugins.mjs @@ -142,7 +142,7 @@ PatternPlugins.prototype.__loadPluginMacros = function (plugin) { PatternPlugins.prototype.__loadPluginStoreMethods = function (plugin) { if (Array.isArray(plugin.store)) { for (const method of plugin.store) this.__storeMethods.add(method) - } else this.store.log.warning(`Plugin store methods should be an Array`) + } else this.store.log.warn(`Plugin store methods should be an Array`) // console.log('store', plugin, this.__storeMethods) return this diff --git a/packages/core/src/pattern/pattern-renderer.mjs b/packages/core/src/pattern/pattern-renderer.mjs index b2dfe9e8cde..4c02b27c8ec 100644 --- a/packages/core/src/pattern/pattern-renderer.mjs +++ b/packages/core/src/pattern/pattern-renderer.mjs @@ -89,7 +89,7 @@ PatternRenderer.prototype.__pack = function () { const { settings, setStores, activeSet } = this.pattern for (const set in settings) { if (setStores[set].logs.error.length > 0) { - setStores[set].log.warning(`One or more errors occured. Not packing pattern parts`) + setStores[set].log.warn(`One or more errors occured. Not packing pattern parts`) return this } } diff --git a/packages/core/src/point.mjs b/packages/core/src/point.mjs index 0d179ad4963..4994ef4ebf1 100644 --- a/packages/core/src/point.mjs +++ b/packages/core/src/point.mjs @@ -144,7 +144,7 @@ Point.prototype.flipX = function (that = false) { this.__check() if (that) { if (that instanceof Point !== true) - this.log.warning('Called `Point.rotate(deg,that)` but `that` is not a `Point` object') + this.log.warn('Called `Point.rotate(deg,that)` but `that` is not a `Point` object') that.__check() } if (that === false || that.x === 0) return new Point(this.x * -1, this.y).__withLog(this.log) @@ -161,7 +161,7 @@ Point.prototype.flipY = function (that = false) { this.__check() if (that) { if (that instanceof Point !== true) - this.log.warning('Called `Point.flipY(that)` but `that` is not a `Point` object') + this.log.warn('Called `Point.flipY(that)` but `that` is not a `Point` object') that.__check() } if (that === false || that.y === 0) return new Point(this.x, this.y * -1).__withLog(this.log) @@ -177,9 +177,9 @@ Point.prototype.flipY = function (that = false) { */ Point.prototype.rotate = function (deg, that) { if (typeof deg !== 'number') - this.log.warning('Called `Point.rotate(deg,that)` but `deg` is not a number') + this.log.warn('Called `Point.rotate(deg,that)` but `deg` is not a number') if (that instanceof Point !== true) - this.log.warning('Called `Point.rotate(deg,that)` but `that` is not a `Point` object') + this.log.warn('Called `Point.rotate(deg,that)` but `that` is not a `Point` object') const radius = this.__check().dist(that.__check()) const angle = this.angle(that) const x = that.x + radius * Math.cos(deg2rad(angle + deg)) * -1 @@ -241,11 +241,11 @@ Point.prototype.shift = function (deg, dist) { */ Point.prototype.shiftFractionTowards = function (that, fraction) { if (that instanceof Point !== true) - this.log.warning( + this.log.warn( 'Called `Point.shiftFractionTowards(that, fraction)` but `that` is not a `Point` object' ) if (typeof fraction !== 'number') - this.log.warning('Called `Point.shiftFractionTowards` but `fraction` is not a number') + this.log.warn('Called `Point.shiftFractionTowards` but `fraction` is not a number') return this.__check().shiftTowards(that.__check(), this.dist(that) * fraction) } @@ -260,9 +260,7 @@ Point.prototype.shiftFractionTowards = function (that, fraction) { Point.prototype.shiftOutwards = function (that, distance) { distance = __asNumber(distance, 'distance', 'Point.shiftOutwards', this.log) if (that instanceof Point !== true) - this.log.warning( - 'Called `Point.shiftOutwards(that, distance)` but `that` is not a `Point` object' - ) + this.log.warn('Called `Point.shiftOutwards(that, distance)` but `that` is not a `Point` object') this.__check() that.__check() @@ -279,9 +277,7 @@ Point.prototype.shiftOutwards = function (that, distance) { Point.prototype.shiftTowards = function (that, dist) { dist = __asNumber(dist, 'dist', 'Point.shiftTowards', this.log) if (that instanceof Point !== true) - this.log.warning( - 'Called `Point.shiftTowards(that, distance)` but `that` is not a `Point` object' - ) + this.log.warn('Called `Point.shiftTowards(that, distance)` but `that` is not a `Point` object') return this.__check().shift(this.angle(that.__check()), dist) } @@ -294,7 +290,7 @@ Point.prototype.shiftTowards = function (that, dist) { */ Point.prototype.sitsOn = function (that) { if (that instanceof Point !== true) - this.log.warning('Called `Point.sitsOn(that)` but `that` is not a `Point` object') + this.log.warn('Called `Point.sitsOn(that)` but `that` is not a `Point` object') if (this.__check().x === that.__check().x && this.y === that.y) return true else return false } @@ -307,7 +303,7 @@ Point.prototype.sitsOn = function (that) { */ Point.prototype.sitsRoughlyOn = function (that) { if (that instanceof Point !== true) - this.log.warning('Called `Point.sitsRoughlyOn(that)` but `that` is not a `Point` object') + this.log.warn('Called `Point.sitsRoughlyOn(that)` but `that` is not a `Point` object') if ( Math.round(this.__check().x) === Math.round(that.__check().x) && Math.round(this.y) === Math.round(that.y) @@ -335,10 +331,8 @@ Point.prototype.slope = function (that) { */ Point.prototype.translate = function (x, y) { this.__check() - if (typeof x !== 'number') - this.log.warning('Called `Point.translate(x,y)` but `x` is not a number') - if (typeof y !== 'number') - this.log.warning('Called `Point.translate(x,y)` but `y` is not a number') + if (typeof x !== 'number') this.log.warn('Called `Point.translate(x,y)` but `x` is not a number') + if (typeof y !== 'number') this.log.warn('Called `Point.translate(x,y)` but `y` is not a number') const p = this.copy() p.x += x p.y += y @@ -370,8 +364,8 @@ Point.prototype.asRenderProps = function () { * @return {object} this - The Point instance */ Point.prototype.__check = function () { - if (typeof this.x !== 'number') this.log.warning('X value of `Point` is not a number') - if (typeof this.y !== 'number') this.log.warning('Y value of `Point` is not a number') + if (typeof this.x !== 'number') this.log.warn('X value of `Point` is not a number') + if (typeof this.y !== 'number') this.log.warn('Y value of `Point` is not a number') return this } @@ -409,15 +403,15 @@ export function pointsProxy(points, log) { set: (points, name, value) => { // Constructor checks if (value instanceof Point !== true) - log.warning(`\`points.${name}\` was set with a value that is not a \`Point\` object`) + log.warn(`\`points.${name}\` was set with a value that is not a \`Point\` object`) if (value.x == null || !__isCoord(value.x)) - log.warning(`\`points.${name}\` was set with a \`x\` parameter that is not a \`number\``) + log.warn(`\`points.${name}\` was set with a \`x\` parameter that is not a \`number\``) if (value.y == null || !__isCoord(value.y)) - log.warning(`\`points.${name}\` was set with a \`y\` parameter that is not a \`number\``) + log.warn(`\`points.${name}\` was set with a \`y\` parameter that is not a \`number\``) try { value.name = name } catch (err) { - log.warning(`Could not set \`name\` property on \`points.${name}\``) + log.warn(`Could not set \`name\` property on \`points.${name}\``) } return (points[name] = value) }, diff --git a/packages/core/src/snippet.mjs b/packages/core/src/snippet.mjs index 85e6a465eae..80b1389d4f6 100644 --- a/packages/core/src/snippet.mjs +++ b/packages/core/src/snippet.mjs @@ -125,19 +125,17 @@ export function snippetsProxy(snippets, log) { set: (snippets, name, value) => { // Constructor checks if (value instanceof Snippet !== true) - log.warning(`\`snippets.${name}\` was set with a value that is not a \`Snippet\` object`) + log.warn(`\`snippets.${name}\` was set with a value that is not a \`Snippet\` object`) if (typeof value.def !== 'string') - log.warning( - `\`snippets.${name}\` was set with a \`def\` parameter that is not a \`string\`` - ) + log.warn(`\`snippets.${name}\` was set with a \`def\` parameter that is not a \`string\``) if (value.anchor instanceof Point !== true) - log.warning( + log.warn( `\`snippets.${name}\` was set with an \`anchor\` parameter that is not a \`Point\`` ) try { value.name = name } catch (err) { - log.warning(`Could not set \`name\` property on \`snippets.${name}\``) + log.warn(`Could not set \`name\` property on \`snippets.${name}\``) } return (snippets[name] = value) }, diff --git a/packages/core/src/store.mjs b/packages/core/src/store.mjs index 1b8244a6ae2..561f6c2d52b 100644 --- a/packages/core/src/store.mjs +++ b/packages/core/src/store.mjs @@ -24,7 +24,9 @@ export function Store(methods = []) { const logs = { debug: [], info: [], + // FIXME: Remove after migration to 'warn' is complete warning: [], + warn: [], error: [], } this.log = { @@ -34,6 +36,10 @@ export function Store(methods = []) { info: function (...data) { logs.info.push(...data) }, + warn: function (...data) { + logs.warn.push(...data) + }, + // FIXME: Remove after migration to 'warn' is complete warning: function (...data) { logs.warning.push(...data) }, @@ -46,7 +52,7 @@ export function Store(methods = []) { for (const [path, method] of methods) { if (avoid.indexOf(path) !== -1) { - this.log.warning(`You cannot overwrite \`store.${path}()\``) + this.log.warn(`You cannot overwrite \`store.${path}()\``) } else set(this, path, method) } @@ -66,7 +72,7 @@ export function Store(methods = []) { Store.prototype.extend = function (methods) { for (const [path, method] of methods) { if (avoid.indexOf(path) !== -1) { - this.log.warning(`You cannot overwrite \`store.${path}()\``) + this.log.warn(`You cannot overwrite \`store.${path}()\``) } else { this.log.info(`Extending store with \`${path}\``) set(this, path, (...args) => method(this, ...args)) @@ -86,7 +92,7 @@ Store.prototype.extend = function (methods) { Store.prototype.get = function (path, dflt) { const val = get(this, path, dflt) if (typeof val === 'undefined') { - this.log.warning(`Store.get(key) on key \`${path}\`, which is undefined`) + this.log.warn(`Store.get(key) on key \`${path}\`, which is undefined`) } return val @@ -104,7 +110,7 @@ Store.prototype.push = function (path, ...values) { if (Array.isArray(arr)) { return this.set(path, [...arr, ...values]) } else { - this.log.warning(`Store.push(value) on key \`${path}\`, but key does not hold an array`) + this.log.warn(`Store.push(value) on key \`${path}\`, but key does not hold an array`) } return this @@ -119,7 +125,7 @@ Store.prototype.push = function (path, ...values) { */ Store.prototype.set = function (path, value) { if (typeof value === 'undefined') { - this.log.warning(`Store.set(value) on key \`${path}\`, but value is undefined`) + this.log.warn(`Store.set(value) on key \`${path}\`, but value is undefined`) } set(this, path, value) @@ -135,7 +141,7 @@ Store.prototype.set = function (path, value) { */ Store.prototype.setIfUnset = function (path, value) { if (typeof value === 'undefined') { - this.log.warning(`Store.setIfUnset(value) on key \`${path}\`, but value is undefined`) + this.log.warn(`Store.setIfUnset(value) on key \`${path}\`, but value is undefined`) } if (typeof get(this, path) === 'undefined') { return set(this, path, value) diff --git a/packages/core/src/utils.mjs b/packages/core/src/utils.mjs index 388a05fd9ac..2fcdab4bc5b 100644 --- a/packages/core/src/utils.mjs +++ b/packages/core/src/utils.mjs @@ -693,7 +693,7 @@ export function __addNonEnumProp(obj, name, value) { export function __asNumber(value, param, method, log) { if (typeof value === 'number') return value if (typeof value === 'string') { - log.warning( + log.warn( `Called \`${method}(${param})\` but \`${param}\` is not a number. Will attempt to cast to Number` ) try { diff --git a/packages/core/tests/part.test.mjs b/packages/core/tests/part.test.mjs index 19e645e119c..deeaf4c781e 100644 --- a/packages/core/tests/part.test.mjs +++ b/packages/core/tests/part.test.mjs @@ -124,14 +124,14 @@ describe('Part', () => { const design = new Design({ parts: [part] }) const pattern = new design() pattern.draft() - expect(pattern.setStores[0].logs.warning.length).to.equal(4) - expect(pattern.setStores[0].logs.warning[0]).to.equal( + expect(pattern.setStores[0].logs.warn.length).to.equal(4) + expect(pattern.setStores[0].logs.warn[0]).to.equal( '`points.a` was set with a value that is not a `Point` object' ) - expect(pattern.setStores[0].logs.warning[1]).to.equal( + expect(pattern.setStores[0].logs.warn[1]).to.equal( '`points.a` was set with a `x` parameter that is not a `number`' ) - expect(pattern.setStores[0].logs.warning[2]).to.equal( + expect(pattern.setStores[0].logs.warn[2]).to.equal( '`points.a` was set with a `y` parameter that is not a `number`' ) }) @@ -147,14 +147,14 @@ describe('Part', () => { const design = new Design({ parts: [part] }) const pattern = new design() pattern.draft() - expect(pattern.setStores[0].logs.warning.length).to.equal(4) - expect(pattern.setStores[0].logs.warning[0]).to.equal( + expect(pattern.setStores[0].logs.warn.length).to.equal(4) + expect(pattern.setStores[0].logs.warn[0]).to.equal( '`snippets.a` was set with a value that is not a `Snippet` object' ) - expect(pattern.setStores[0].logs.warning[1]).to.equal( + expect(pattern.setStores[0].logs.warn[1]).to.equal( '`snippets.a` was set with a `def` parameter that is not a `string`' ) - expect(pattern.setStores[0].logs.warning[2]).to.equal( + expect(pattern.setStores[0].logs.warn[2]).to.equal( '`snippets.a` was set with an `anchor` parameter that is not a `Point`' ) }) @@ -197,8 +197,8 @@ describe('Part', () => { // Let's also cover the branch where complete is false const pattern = new design({ complete: false }) pattern.draft() - expect(pattern.setStores[0].logs.warning.length).to.equal(1) - expect(pattern.setStores[0].logs.warning[0]).to.equal( + expect(pattern.setStores[0].logs.warn.length).to.equal(1) + expect(pattern.setStores[0].logs.warn[0]).to.equal( 'Calling `units(value)` but `value` is not a number (`string`)' ) }) @@ -311,8 +311,8 @@ describe('Part', () => { const design = new Design({ parts: [part] }) const pattern = new design() pattern.draft() - expect(pattern.setStores[0].logs.warning.length).to.equal(1) - expect(pattern.setStores[0].logs.warning[0]).to.equal( + expect(pattern.setStores[0].logs.warn.length).to.equal(1) + expect(pattern.setStores[0].logs.warn[0]).to.equal( 'Tried to access `options.test` but it is `undefined`' ) }) @@ -328,8 +328,8 @@ describe('Part', () => { const design = new Design({ parts: [part] }) const pattern = new design() pattern.draft() - expect(pattern.setStores[0].logs.warning.length).to.equal(1) - expect(pattern.setStores[0].logs.warning[0]).to.equal( + expect(pattern.setStores[0].logs.warn.length).to.equal(1) + expect(pattern.setStores[0].logs.warn[0]).to.equal( 'Tried to access `absoluteOptions.test` but it is `undefined`' ) }) diff --git a/packages/core/tests/path.test.mjs b/packages/core/tests/path.test.mjs index ffc438d5f74..a3b0bee5fc0 100644 --- a/packages/core/tests/path.test.mjs +++ b/packages/core/tests/path.test.mjs @@ -49,7 +49,7 @@ describe('Path', () => { points.to = new Point(90, 20) const messages = [] - const log = { warning: (msg) => messages.push(msg) } + const log = { warn: (msg) => messages.push(msg) } new Path() .__withLog(log) .move(points.from) @@ -62,7 +62,7 @@ describe('Path', () => { it('Should log a warning when passing a non-Point to smurve_()', () => { const messages = [] - const log = { warning: (msg) => messages.push(msg) } + const log = { warn: (msg) => messages.push(msg) } try { new Path().__withLog(log).smurve_('hi') } catch (e) { @@ -76,7 +76,7 @@ describe('Path', () => { it('Should log a warning when passing a non-Path to the paths proxy', () => { const messages = [] - const log = { warning: (msg) => messages.push(msg) } + const log = { warn: (msg) => messages.push(msg) } const pathsObj = {} const paths = pathsProxy(pathsObj, log) paths.set(pathsObj, 'test', 'Writing code can get very lonely sometimes') @@ -685,7 +685,7 @@ describe('Path', () => { it('Calling translate with non-numbers should generate a warning', () => { const log = [] const p = new Path() - p.log = { warning: (msg) => log.push(msg) } + p.log = { warn: (msg) => log.push(msg) } p.translate('a', 'b') expect(log.length).to.equal(2) expect(log[0]).to.equal('Called `Path.translate(x, y)` but `x` is not a number') @@ -756,7 +756,7 @@ describe('Path', () => { it('Should log a warning when moving to a non-point', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Path().__withLog(log) expect(invalid).to.equal(false) try { @@ -769,7 +769,7 @@ describe('Path', () => { it('Should log a warning when drawing a line to a non-point', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Path().__withLog(log) expect(invalid).to.equal(false) try { @@ -782,7 +782,7 @@ describe('Path', () => { it('Should log a warning when drawing a curve to a non-point', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Path().__withLog(log) const a = new Point(0, 0) const b = new Point(10, 10) @@ -797,7 +797,7 @@ describe('Path', () => { it('Should log a warning when drawing a curve with a Cp1 that is a non-point', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Path().__withLog(log) const a = new Point(0, 0) const b = new Point(10, 10) @@ -812,7 +812,7 @@ describe('Path', () => { it('Should log a warning when drawing a curve with a Cp1 that is a non-point', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Path().__withLog(log) const b = new Point(10, 10) expect(invalid).to.equal(false) @@ -826,7 +826,7 @@ describe('Path', () => { it('Should log a warning when drawing a curve with a Cp2 that is a non-point', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Path().__withLog(log) const b = new Point(10, 10) expect(invalid).to.equal(false) @@ -840,7 +840,7 @@ describe('Path', () => { it('Should log a warning when drawing a _curve with a To that is a non-point', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Path().__withLog(log) const b = new Point(10, 10) expect(invalid).to.equal(false) @@ -854,7 +854,7 @@ describe('Path', () => { it('Should log a warning when drawing a _curve with a Cp2 that is a non-point', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Path().__withLog(log) const b = new Point(10, 10) expect(invalid).to.equal(false) @@ -868,7 +868,7 @@ describe('Path', () => { it('Should log a warning when drawing a curve_ with a To that is a non-point', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Path().__withLog(log) const b = new Point(10, 10) expect(invalid).to.equal(false) @@ -882,7 +882,7 @@ describe('Path', () => { it('Should log a warning when drawing a curve_ with a Cp2 that is a non-point', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Path().__withLog(log) const b = new Point(10, 10) expect(invalid).to.equal(false) @@ -912,7 +912,7 @@ describe('Path', () => { it('Should log a warning when an insop operation used an falsy ID', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const a = new Point(0, 0) const b = new Point(10, 10) const p1 = new Path().move(a).line(b) @@ -923,7 +923,7 @@ describe('Path', () => { it('Should log a warning when an insop operation used an falsy ID', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const a = new Point(0, 0) const b = new Point(10, 10) new Path().move(a).line(b) @@ -938,21 +938,21 @@ describe('Path', () => { it('Should log a warning when setting an attribute without a name', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } new Path().__withLog(log).attr() expect(invalid).to.equal(true) }) it('Should log a warning when setting an attribute without a value', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } new Path().__withLog(log).attr('test') expect(invalid).to.equal(true) }) it('Should log an error when calling offset without a distance', () => { let invalid = true - const log = { warning: () => {}, error: () => (invalid = true) } + const log = { warn: () => {}, error: () => (invalid = true) } const pointLog = { error: () => {} } const pointA = new Point(0, 0).__withLog(pointLog) const pointB = new Point(0, 40).__withLog(pointLog) @@ -1019,7 +1019,7 @@ describe('Path', () => { it('Should log an error when splitting a path on a non-point', () => { let invalid = false const log = { error: () => (invalid = true) } - const pointLog = { warning: () => {} } + const pointLog = { warn: () => {} } try { new Path() .__withLog(log) diff --git a/packages/core/tests/pattern-draft.test.mjs b/packages/core/tests/pattern-draft.test.mjs index bceaa10221f..a2e93813678 100644 --- a/packages/core/tests/pattern-draft.test.mjs +++ b/packages/core/tests/pattern-draft.test.mjs @@ -222,8 +222,8 @@ describe('Pattern', () => { const pattern = new Pattern() pattern.events.error.push('error') pattern.pack() - expect(pattern.events.warning.length).to.equal(1) - expect(pattern.events.warning[0]).to.equal( + expect(pattern.events.warn.length).to.equal(1) + expect(pattern.events.warn[0]).to.equal( 'One or more errors occured. Not packing pattern parts' ) }) diff --git a/packages/core/tests/pattern-init.test.mjs b/packages/core/tests/pattern-init.test.mjs index 2c95635bde0..0493e914197 100644 --- a/packages/core/tests/pattern-init.test.mjs +++ b/packages/core/tests/pattern-init.test.mjs @@ -867,12 +867,12 @@ describe('Pattern', () => { expect(typeof partContext.store.log).to.equal('object') expect(typeof partContext.store.log.debug).to.equal('function') expect(typeof partContext.store.log.info).to.equal('function') - expect(typeof partContext.store.log.warning).to.equal('function') + expect(typeof partContext.store.log.warn).to.equal('function') expect(typeof partContext.store.log.error).to.equal('function') expect(typeof partContext.store.logs).to.equal('object') expect(Array.isArray(partContext.store.logs.debug)).to.equal(true) expect(Array.isArray(partContext.store.logs.info)).to.equal(true) - expect(Array.isArray(partContext.store.logs.warning)).to.equal(true) + expect(Array.isArray(partContext.store.logs.warn)).to.equal(true) expect(Array.isArray(partContext.store.logs.error)).to.equal(true) }) }) diff --git a/packages/core/tests/point.test.mjs b/packages/core/tests/point.test.mjs index a204d564f2b..fd5c858c872 100644 --- a/packages/core/tests/point.test.mjs +++ b/packages/core/tests/point.test.mjs @@ -239,8 +239,8 @@ describe('Point', () => { it('Should log a warning on invalid point coordinates', () => { const invalid = { x: false, y: false } - const logX = { warning: () => (invalid.x = true) } - const logY = { warning: () => (invalid.y = true) } + const logX = { warn: () => (invalid.x = true) } + const logY = { warn: () => (invalid.y = true) } const p1 = new Point('a', 10).__withLog(logX) const p2 = new Point(20, 'b').__withLog(logY) expect(invalid.x).to.equal(false) @@ -253,7 +253,7 @@ describe('Point', () => { it('Should log a warning if rotation is not a number', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Point(10, 10).__withLog(log) const p2 = new Point(20, 20).__withLog(log) expect(invalid).to.equal(false) @@ -263,7 +263,7 @@ describe('Point', () => { it('Should log a warning if rotating around what is not a point', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Point(10, 10).__withLog(log) expect(invalid).to.equal(false) try { @@ -276,7 +276,7 @@ describe('Point', () => { it("Should log a warning when flipX'ing around what is not a point", () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Point(10, 10).__withLog(log) expect(invalid).to.equal(false) try { @@ -289,7 +289,7 @@ describe('Point', () => { it("Should log a warning when flipY'ing around what is not a point", () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Point(10, 10).__withLog(log) expect(invalid).to.equal(false) try { @@ -302,7 +302,7 @@ describe('Point', () => { it('Should log a warning when shifting with a distance that is not a number', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Point(10, 10).__withLog(log) expect(invalid).to.equal(false) try { @@ -315,7 +315,7 @@ describe('Point', () => { it('Should log a warning when shifting with an angle that is not a number', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Point(10, 10).__withLog(log) expect(invalid).to.equal(false) try { @@ -328,7 +328,7 @@ describe('Point', () => { it('Should log a warning when shifting towards with a distance that is not a number', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Point(10, 10).__withLog(log) const p2 = new Point(20, 20).__withLog(log) expect(invalid).to.equal(false) @@ -342,7 +342,7 @@ describe('Point', () => { it('Should log a warning when shifting towards with a target that is not a point', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Point(10, 10).__withLog(log) expect(invalid).to.equal(false) try { @@ -355,7 +355,7 @@ describe('Point', () => { it('Should log a warning when shifting fraction towards with a distance that is not a number', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Point(10, 10).__withLog(log) const p2 = new Point(20, 20).__withLog(log) expect(invalid).to.equal(false) @@ -369,7 +369,7 @@ describe('Point', () => { it('Should log a warning when shifting a fraction towards with a target that is not a point', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Point(10, 10).__withLog(log) expect(invalid).to.equal(false) try { @@ -382,7 +382,7 @@ describe('Point', () => { it('Should log a warning when shifting outowards with a distance that is not a number', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Point(10, 10).__withLog(log) const p2 = new Point(20, 20).__withLog(log) expect(invalid).to.equal(false) @@ -396,7 +396,7 @@ describe('Point', () => { it('Should log a warning when shifting a outowards with a target that is not a point', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Point(10, 10).__withLog(log) expect(invalid).to.equal(false) try { @@ -409,7 +409,7 @@ describe('Point', () => { it('Should log a warning when translating with an X-delta that is not a number', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Point(10, 10).__withLog(log) expect(invalid).to.equal(false) try { @@ -422,7 +422,7 @@ describe('Point', () => { it('Should log a warning when translating with an Y-delta that is not a number', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Point(10, 10).__withLog(log) expect(invalid).to.equal(false) try { @@ -435,7 +435,7 @@ describe('Point', () => { it('Should log a warning when sitsOn receives a non-point', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Point(10, 10).__withLog(log) expect(invalid).to.equal(false) try { @@ -448,7 +448,7 @@ describe('Point', () => { it('Should log a warning when sitsRoughlyOn receives a non-point', () => { let invalid = false - const log = { warning: () => (invalid = true) } + const log = { warn: () => (invalid = true) } const p1 = new Point(10, 10).__withLog(log) expect(invalid).to.equal(false) try { diff --git a/packages/core/tests/store.test.mjs b/packages/core/tests/store.test.mjs index fb45fb932d4..cf7d37a516d 100644 --- a/packages/core/tests/store.test.mjs +++ b/packages/core/tests/store.test.mjs @@ -32,10 +32,8 @@ describe('Store', () => { it('Should emit a warning when retrieving a invalid key', () => { const store = new Store() store.get('nope') - expect(store.get('logs.warning').length).to.equal(1) - expect(store.get('logs.warning')[0]).to.equal( - 'Store.get(key) on key `nope`, which is undefined' - ) + expect(store.get('logs.warn').length).to.equal(1) + expect(store.get('logs.warn')[0]).to.equal('Store.get(key) on key `nope`, which is undefined') }) it('Should add methods to the store from a plugin', () => { @@ -44,9 +42,9 @@ describe('Store', () => { version: 1, store: [ [ - 'test.example.warning', + 'test.example.warn', function (store, msg) { - store.set('test.message.warning', msg) + store.set('test.message.warn', msg) }, ], [ @@ -61,7 +59,7 @@ describe('Store', () => { name: 'example.part', plugins: [plugin], draft: ({ store, part }) => { - store.test.example.warning('hello warning') + store.test.example.warn('hello warn') store.test.example.info('hello info') return part @@ -70,21 +68,21 @@ describe('Store', () => { const Test = new Design({ parts: [part] }) const pattern = new Test() pattern.draft() - expect(pattern.setStores[0].get('test.message.warning')).to.equal('hello warning') + expect(pattern.setStores[0].get('test.message.warn')).to.equal('hello warn') expect(pattern.setStores[0].get('test.message.info')).to.equal('hello info') }) it('Should log a warning when trying to extend a protected method via the constructor', () => { const store = new Store([['get', () => false]]) - expect(store.logs.warning.length).to.equal(1) - expect(store.logs.warning[0]).to.equal('You cannot overwrite `store.get()`') + expect(store.logs.warn.length).to.equal(1) + expect(store.logs.warn[0]).to.equal('You cannot overwrite `store.get()`') }) it('Should log a warning when trying to extend a protected method via the extend', () => { const store = new Store() store.extend([['get', () => false]]) - expect(store.logs.warning.length).to.equal(1) - expect(store.logs.warning[0]).to.equal('You cannot overwrite `store.get()`') + expect(store.logs.warn.length).to.equal(1) + expect(store.logs.warn[0]).to.equal('You cannot overwrite `store.get()`') }) it('Should extend the store with a new method via the constructor', () => { @@ -95,8 +93,8 @@ describe('Store', () => { it('Should log a warning when pushing to a non-array key', () => { const store = new Store() store.push('test', 1) - expect(store.logs.warning.length).to.equal(1) - expect(store.logs.warning[0]).to.equal( + expect(store.logs.warn.length).to.equal(1) + expect(store.logs.warn[0]).to.equal( 'Store.push(value) on key `test`, but key does not hold an array' ) }) @@ -104,15 +102,15 @@ describe('Store', () => { it('Should log a warning when setting an undefined value with set()', () => { const store = new Store() store.set('test') - expect(store.logs.warning.length).to.equal(1) - expect(store.logs.warning[0]).to.equal('Store.set(value) on key `test`, but value is undefined') + expect(store.logs.warn.length).to.equal(1) + expect(store.logs.warn[0]).to.equal('Store.set(value) on key `test`, but value is undefined') }) it('Should log a warning when setting an undefined value with setIfUnset()', () => { const store = new Store() store.setIfUnset('test') - expect(store.logs.warning.length).to.equal(1) - expect(store.logs.warning[0]).to.equal( + expect(store.logs.warn.length).to.equal(1) + expect(store.logs.warn[0]).to.equal( 'Store.setIfUnset(value) on key `test`, but value is undefined' ) })