From 5659f33aef3b07a2ad9ae56fd3d3ca363ec7a45a Mon Sep 17 00:00:00 2001 From: Justin Searls Date: Mon, 8 Oct 2018 14:20:51 -0400 Subject: [PATCH] standard --fix --- src/explain.js | 2 +- src/object.js | 2 +- src/replace/module/jest-module.js | 2 +- src/replace/module/require-actual.js | 2 +- src/share/create-promise.js | 2 +- src/store/calls.js | 4 +-- src/store/index.js | 2 +- src/store/stubbings.js | 2 +- src/value/call-log.js | 2 +- src/verify.js | 4 +-- src/verify/index.js | 2 +- src/when.js | 2 +- test/safe/args-match.test.js | 2 +- test/safe/callback.test.js | 10 +++---- test/safe/config.test.js | 6 ++--- test/safe/explain.test.js | 4 +-- test/safe/imitate.test.js | 6 ++--- test/safe/log.test.js | 4 +-- test/safe/matchers.test.js | 14 +++++----- test/safe/stringify-anything.test.js | 2 +- test/safe/typescript-typings.test.ts | 6 ++--- test/safe/verify.test.js | 2 +- test/safe/when.test.js | 26 +++++++++---------- test/unit/config.test.js | 6 ++--- test/unit/imitate/create-imitation.test.js | 4 +-- test/unit/imitate/index.test.js | 4 +-- .../overwrite-children/copy-props.test.js | 14 +++++----- .../imitate/overwrite-children/index.test.js | 10 +++---- test/unit/log.test.js | 8 +++--- test/unit/log/ensure-promise.test.js | 8 +++--- test/unit/satisfy/deliver-outcome.test.js | 4 +-- .../satisfy/find-last-stubbing-match.test.js | 2 +- test/unit/satisfy/invoke-callbacks.test.js | 4 +-- test/unit/share/create-promise.test.js | 2 +- test/unit/value/call-log.test.js | 6 ++--- test/unit/value/stubbing.test.js | 8 +++--- test/unit/verify/index.test.js | 10 +++---- ...-implied-callback-arg-if-necessary.test.js | 4 +-- test/unit/when/index.test.js | 2 +- 39 files changed, 103 insertions(+), 103 deletions(-) diff --git a/src/explain.js b/src/explain.js index 401f2d6d..309abf74 100644 --- a/src/explain.js +++ b/src/explain.js @@ -39,7 +39,7 @@ function stubbingDescription (stubs) { return stubs.length > 0 ? _.reduce(stubs, (desc, stub) => desc + `\n - when called with \`(${stringifyArgs(stub.args)})\`, then ${planFor(stub)} ${argsFor(stub)}.` - , '\n\nStubbings:') + , '\n\nStubbings:') : '' } diff --git a/src/object.js b/src/object.js index fc183ee1..63c0cd02 100644 --- a/src/object.js +++ b/src/object.js @@ -3,7 +3,7 @@ import log from './log' import tdFunction from './function' import imitate from './imitate' -const DEFAULT_OPTIONS = {excludeMethods: ['then']} +const DEFAULT_OPTIONS = { excludeMethods: ['then'] } export default function object (nameOrType, config) { return _.tap(fakeObject(nameOrType, config, arguments.length), (obj) => { diff --git a/src/replace/module/jest-module.js b/src/replace/module/jest-module.js index d43c4fa5..eaac93e8 100644 --- a/src/replace/module/jest-module.js +++ b/src/replace/module/jest-module.js @@ -8,7 +8,7 @@ export default function jestModule (path, stub) { if (!tdMock) { log.error('td.replace', 'It appears the test is being run by Jest, but the testdouble-jest module has not been initialized, so testdouble.js cannot replace modules. For setup instructions, visit: https://github.com/testdouble/testdouble-jest') } else if (arguments.length > 1) { - tdMock(path, () => stub, {virtual: !moduleExists(tdMock, path)}) + tdMock(path, () => stub, { virtual: !moduleExists(tdMock, path) }) return tdMock.requireMock(path) } else { tdMock(path) diff --git a/src/replace/module/require-actual.js b/src/replace/module/require-actual.js index 8ca92f76..674c3f3f 100644 --- a/src/replace/module/require-actual.js +++ b/src/replace/module/require-actual.js @@ -21,7 +21,7 @@ export default function requireActual (modulePath) { try { return require(require.resolve(modulePath, { paths: [ path.join(process.cwd(), 'node_modules') - ]})) + ] })) } catch (e) { moduleNameLoadError = e } diff --git a/src/share/create-promise.js b/src/share/create-promise.js index 97aba5d1..41c23869 100644 --- a/src/share/create-promise.js +++ b/src/share/create-promise.js @@ -9,6 +9,6 @@ export default function createPromise (stubbing, willResolve) { return new Promise((resolve, reject) => { callLater(() => willResolve ? resolve(value) : reject(value) - , [value], stubbing.options.defer, stubbing.options.delay) + , [value], stubbing.options.defer, stubbing.options.delay) }) } diff --git a/src/store/calls.js b/src/store/calls.js index 9248a094..d15f37c3 100644 --- a/src/store/calls.js +++ b/src/store/calls.js @@ -7,8 +7,8 @@ store.onReset(() => { callHistory = [] }) export default { log (testDouble, args, context) { - store.for(testDouble).calls.push({args, context}) - return callHistory.push({testDouble, args, context}) + store.for(testDouble).calls.push({ args, context }) + return callHistory.push({ testDouble, args, context }) }, pop () { diff --git a/src/store/index.js b/src/store/index.js index cc5fc517..2818520d 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -15,7 +15,7 @@ export default { }, for (testDouble, createIfNew = true) { - const entry = _.find(globalStore, {testDouble}) + const entry = _.find(globalStore, { testDouble }) if (entry) { return entry } else if (createIfNew) { diff --git a/src/store/stubbings.js b/src/store/stubbings.js index 0727c607..14da1244 100644 --- a/src/store/stubbings.js +++ b/src/store/stubbings.js @@ -82,7 +82,7 @@ var createPromise = (stubbing, value, willResolve) => { return new Promise((resolve, reject) => { callCallback(stubbing, () => willResolve ? resolve(value) : reject(value) - , [value]) + , [value]) }) } diff --git a/src/value/call-log.js b/src/value/call-log.js index 71a413e4..230037da 100644 --- a/src/value/call-log.js +++ b/src/value/call-log.js @@ -19,7 +19,7 @@ export default class CallLog { } log (double, call) { - this.callHistory.push({double, call}) + this.callHistory.push({ double, call }) if (this.calls.has(double)) { this.calls.get(double).push(call) } else { diff --git a/src/verify.js b/src/verify.js index d31e1e17..f55aa43a 100644 --- a/src/verify.js +++ b/src/verify.js @@ -71,7 +71,7 @@ var invocationSummary = (testDouble, args, config) => { } else { return _.reduce(calls, (desc, call) => desc + `\n - called with \`(${stringifyArgs(call.args)})\`.` - , '\n\n All calls of the test double, in order were:') + , '\n\n All calls of the test double, in order were:') } } @@ -84,7 +84,7 @@ var matchedInvocationSummary = (testDouble, args, config) => { } else { return _.reduce(_.groupBy(calls, 'args'), (desc, callsMatchingArgs, args) => desc + `\n - called ${pluralize(callsMatchingArgs.length, 'time')} with \`(${stringifyArgs(callsMatchingArgs[0].args)})\`.` - , `\n\n ${pluralize(calls.length, 'call')} that satisfied this verification:`) + , `\n\n ${pluralize(calls.length, 'call')} that satisfied this verification:`) } } diff --git a/src/verify/index.js b/src/verify/index.js index 8828167d..e44fc625 100644 --- a/src/verify/index.js +++ b/src/verify/index.js @@ -5,7 +5,7 @@ import warnIfAlsoStubbed from './warn-if-also-stubbed' import fail from './fail' export default function verify (__userInvokesDemonstrationHere__, config) { - const {double, call} = popDemonstration() + const { double, call } = popDemonstration() if (didCallOccur(double, call, config)) { notifySatisfiedMatchers(double, call, config) warnIfAlsoStubbed(double, call, config) diff --git a/src/when.js b/src/when.js index b149dd97..1c69a67b 100644 --- a/src/when.js +++ b/src/when.js @@ -34,7 +34,7 @@ export default function when (__userDoesRehearsalInvocationHere__, config = {}) function addStubbing (stubbedValues, config, plan) { const last = calls.pop() ensureRehearsalOccurred(last) - _.assign(config, {plan}) + _.assign(config, { plan }) stubbings.add(last.testDouble, concatImpliedCallback(last.args, config), stubbedValues, config) return last.testDouble } diff --git a/test/safe/args-match.test.js b/test/safe/args-match.test.js index 32044a01..0af0e360 100644 --- a/test/safe/args-match.test.js +++ b/test/safe/args-match.test.js @@ -16,7 +16,7 @@ module.exports = { assert._isEqual(result, false) }, 'exact match' () { - result = subject([5], [5], {allowMatchers: false}) + result = subject([5], [5], { allowMatchers: false }) assert._isEqual(result, true) } diff --git a/test/safe/callback.test.js b/test/safe/callback.test.js index c7d6561a..81a64a1d 100644 --- a/test/safe/callback.test.js +++ b/test/safe/callback.test.js @@ -92,7 +92,7 @@ module.exports = { 'callback is asynchronous': { 'using the defer option': { 'like this': (done) => { - td.when(testDouble('/A'), {defer: true}).thenCallback(null, 'B') + td.when(testDouble('/A'), { defer: true }).thenCallback(null, 'B') testDouble('/A', (e, r) => { callbackInvoked = true @@ -109,10 +109,10 @@ module.exports = { }, 'using the delay option': { 'like this': (done) => { - td.when(testDouble('/A'), {delay: 40}).thenCallback(null, 'B') - td.when(testDouble('/C'), {delay: 20}).thenCallback(null, 'D') - td.when(testDouble('/E'), {delay: 30}).thenResolve('F') - td.when(testDouble('/G'), {delay: 10}).thenReject('H') + td.when(testDouble('/A'), { delay: 40 }).thenCallback(null, 'B') + td.when(testDouble('/C'), { delay: 20 }).thenCallback(null, 'D') + td.when(testDouble('/E'), { delay: 30 }).thenResolve('F') + td.when(testDouble('/G'), { delay: 10 }).thenReject('H') results = [] testDouble('/A', (er, result) => { diff --git a/test/safe/config.test.js b/test/safe/config.test.js index e77a0fbc..28661ecc 100644 --- a/test/safe/config.test.js +++ b/test/safe/config.test.js @@ -7,7 +7,7 @@ module.exports = { }) }, 'overriding a real property' () { - const config = td.config({ignoreWarnings: true}) + const config = td.config({ ignoreWarnings: true }) assert._isEqual(config.ignoreWarnings, true) assert._isEqual(config.ignoreWarnings, true) @@ -18,7 +18,7 @@ module.exports = { const warnings = [] console.warn = function (warning) { warnings.push(warning) } - const config = td.config({extendWhenReplacingConstructors: true}) + const config = td.config({ extendWhenReplacingConstructors: true }) assert._isEqual(config.extendWhenReplacingConstructors, undefined) assert._isEqual(td.config().extendWhenReplacingConstructors, undefined) @@ -31,7 +31,7 @@ module.exports = { 'overriding a non-existent property' () { let error - try { td.config({wat: 'wat?'}) } catch (e) { error = e } + try { td.config({ wat: 'wat?' }) } catch (e) { error = e } assert._isEqual(error.message, 'Error: testdouble.js - td.config - "wat" is not a valid configuration ' + diff --git a/test/safe/explain.test.js b/test/safe/explain.test.js index 1ed0958e..a37f4bac 100644 --- a/test/safe/explain.test.js +++ b/test/safe/explain.test.js @@ -33,8 +33,8 @@ module.exports = { assert._isEqual(result, { name: undefined, calls: [ - {context: 'lol', args: [88]}, - {context: 'woo', args: ['not 88', 44]} + { context: 'lol', args: [88] }, + { context: 'woo', args: ['not 88', 44] } ], callCount: 2, description: `This test double has 2 stubbings and 2 invocations. diff --git a/test/safe/imitate.test.js b/test/safe/imitate.test.js index 72fe40f4..61e1f6b0 100644 --- a/test/safe/imitate.test.js +++ b/test/safe/imitate.test.js @@ -36,10 +36,10 @@ module.exports = { assert._isEqual(td.imitate(new Error('foo')).message, 'foo') }, 'skips encountered objects' () { - const foo = {a: 1, b: 2} - const bar = {c: 3, foo: foo} + const foo = { a: 1, b: 2 } + const bar = { c: 3, foo: foo } foo.bar = bar - const original = {item: foo} + const original = { item: foo } const result = td.imitate(original) diff --git a/test/safe/log.test.js b/test/safe/log.test.js index fe4b644b..f7be574b 100644 --- a/test/safe/log.test.js +++ b/test/safe/log.test.js @@ -27,7 +27,7 @@ module.exports = { assert._isEqual(warnings[0], 'Warning: testdouble.js - td.someFunc - ugh (see: http? )') }, 'with td.config({ignoreWarnings: true})' () { - td.config({ignoreWarnings: true}) + td.config({ ignoreWarnings: true }) subject.warn('waaaarning') @@ -53,7 +53,7 @@ module.exports = { }, '.error': { 'suppressErrors: true' () { - td.config({suppressErrors: true}) + td.config({ suppressErrors: true }) subject.error('hi', 'hi') diff --git a/test/safe/matchers.test.js b/test/safe/matchers.test.js index 91522009..82e0176e 100644 --- a/test/safe/matchers.test.js +++ b/test/safe/matchers.test.js @@ -282,15 +282,15 @@ module.exports = { }) }, 'objects with nested edge cases' () { - matches(td.matchers.contains({d: new Date('1999')}), {d: new Date('1999')}) - doesntMatch(td.matchers.contains({d: new Date('1999')}), {d: new Date('2099')}) + matches(td.matchers.contains({ d: new Date('1999') }), { d: new Date('1999') }) + doesntMatch(td.matchers.contains({ d: new Date('1999') }), { d: new Date('2099') }) - matches(td.matchers.contains({e: new Error('ew')}), {e: new Error('eww')}) - doesntMatch(td.matchers.contains({e: new Error('?')}), {e: new Error('!')}) + matches(td.matchers.contains({ e: new Error('ew') }), { e: new Error('eww') }) + doesntMatch(td.matchers.contains({ e: new Error('?') }), { e: new Error('!') }) - matches(td.matchers.contains({r: /abc/}), {r: /abc/}) - matches(td.matchers.contains({r: /abc/}), {r: 'abc'}) - doesntMatch(td.matchers.contains({r: /abc/}), {r: /abcd/}) + matches(td.matchers.contains({ r: /abc/ }), { r: /abc/ }) + matches(td.matchers.contains({ r: /abc/ }), { r: 'abc' }) + doesntMatch(td.matchers.contains({ r: /abc/ }), { r: /abcd/ }) }, 'nonsense' () { // These are a bit stupid, but necessary to support deep comparisons diff --git a/test/safe/stringify-anything.test.js b/test/safe/stringify-anything.test.js index 40ee80df..0f94956d 100644 --- a/test/safe/stringify-anything.test.js +++ b/test/safe/stringify-anything.test.js @@ -16,7 +16,7 @@ module.exports = { }, 'matchers' () { assert._isEqual(subject(td.matchers.isA(Number)), 'isA(Number)') - assert._isEqual(subject({val: td.matchers.isA(Number)}), '{val: isA(Number)}') + assert._isEqual(subject({ val: td.matchers.isA(Number) }), '{val: isA(Number)}') }, 'long strings of objects should be multi-lined' () { const object = { diff --git a/test/safe/typescript-typings.test.ts b/test/safe/typescript-typings.test.ts index 3f6ffc61..1157ce3a 100644 --- a/test/safe/typescript-typings.test.ts +++ b/test/safe/typescript-typings.test.ts @@ -30,13 +30,13 @@ export = { const FakeBear = td.constructor(Bear) - assert.equal(td.explain(FakeBear.prototype.sleep).isTestDouble, true) + assert.strictEqual(td.explain(FakeBear.prototype.sleep).isTestDouble, true) const bear = td.object('A bear') td.when(bear.sleep()).thenReturn('zzzzzz') - assert.equal(bear.sleep(), 'zzzzzz') + assert.strictEqual(bear.sleep(), 'zzzzzz') } const testObject = { @@ -73,7 +73,7 @@ export = { const explanation = td.explain(f) - assert.equal( + assert.strictEqual( explanation.description.split('\n')[0], 'This test double has 5 stubbings and 1 invocations.' ) diff --git a/test/safe/verify.test.js b/test/safe/verify.test.js index 04a35446..f2e388d4 100644 --- a/test/safe/verify.test.js +++ b/test/safe/verify.test.js @@ -110,7 +110,7 @@ module.exports = { 'using deep matchers': { 'single level': { beforeEach () { - testDouble({value: 55}) + testDouble({ value: 55 }) }, 'satisfied' () { td.verify(testDouble({ diff --git a/test/safe/when.test.js b/test/safe/when.test.js index 24eaa458..7cc566ef 100644 --- a/test/safe/when.test.js +++ b/test/safe/when.test.js @@ -24,16 +24,16 @@ module.exports = { 'conditional stubbing' () { td.when(testDouble(1)).thenReturn('foo') td.when(testDouble(2)).thenReturn('bar') - td.when(testDouble({lol: 'cheese'})).thenReturn('nom') - td.when(testDouble({lol: 'fungus'})).thenReturn('eww') - td.when(testDouble({lol: 'fungus'}, 2)).thenReturn('eww2') + td.when(testDouble({ lol: 'cheese' })).thenReturn('nom') + td.when(testDouble({ lol: 'fungus' })).thenReturn('eww') + td.when(testDouble({ lol: 'fungus' }, 2)).thenReturn('eww2') assert._isEqual(testDouble(), void 0) assert._isEqual(testDouble(1), 'foo') assert._isEqual(testDouble(2), 'bar') - assert._isEqual(testDouble({lol: 'cheese'}), 'nom') - assert._isEqual(testDouble({lol: 'fungus'}), 'eww') - assert._isEqual(testDouble({lol: 'fungus'}, 2), 'eww2') + assert._isEqual(testDouble({ lol: 'cheese' }), 'nom') + assert._isEqual(testDouble({ lol: 'fungus' }), 'eww') + assert._isEqual(testDouble({ lol: 'fungus' }, 2), 'eww2') }, 'multiple test doubles' () { const td1 = td.when(td.func()()).thenReturn('lol1') @@ -51,10 +51,10 @@ module.exports = { }, 'using deep matchers': { 'single level' () { - td.when(testDouble({key: td.matchers.isA(String)})).thenReturn('yay') + td.when(testDouble({ key: td.matchers.isA(String) })).thenReturn('yay') - assert._isEqual(testDouble({key: 'testytest'}), 'yay') - assert._isEqual(testDouble({key: 42}), void 0) + assert._isEqual(testDouble({ key: 'testytest' }), 'yay') + assert._isEqual(testDouble({ key: 42 }), void 0) assert._isEqual(testDouble({}), void 0) assert._isEqual(testDouble('i am a string'), void 0) }, @@ -207,7 +207,7 @@ module.exports = { } } } - td.config({promiseConstructor: FakePromise}) + td.config({ promiseConstructor: FakePromise }) }, 'td.when…thenResolve' (done) { td.when(testDouble(10)).thenResolve('pants') @@ -229,7 +229,7 @@ module.exports = { const errors = [] console.warn = (m) => { warnings.push(m) } console.error = (m) => { errors.push(m) } - td.config({promiseConstructor: undefined}) + td.config({ promiseConstructor: undefined }) td.when(testDouble(10)).thenResolve('pants') @@ -278,7 +278,7 @@ module.exports = { }, 'limiting times stubbing will work': { 'a single stub' () { - td.when(testDouble(), {times: 2}).thenReturn('pants') + td.when(testDouble(), { times: 2 }).thenReturn('pants') result = [testDouble(), testDouble(), testDouble()] @@ -286,7 +286,7 @@ module.exports = { }, 'two overlapping stubbings' () { td.when(testDouble()).thenReturn('NO') - td.when(testDouble(), {times: 1}).thenReturn('YES') + td.when(testDouble(), { times: 1 }).thenReturn('YES') result = [testDouble(), testDouble(), testDouble()] diff --git a/test/unit/config.test.js b/test/unit/config.test.js index 67d7430f..75e486d2 100644 --- a/test/unit/config.test.js +++ b/test/unit/config.test.js @@ -15,13 +15,13 @@ module.exports = { }) }, 'overriding an actual property': () => { - const result = subject({ignoreWarnings: true}) + const result = subject({ ignoreWarnings: true }) assert.equal(result.ignoreWarnings, true) assert.equal(subject().ignoreWarnings, true) }, 'overriding a deprecated property': () => { - const result = subject({extendWhenReplacingConstructors: true}) + const result = subject({ extendWhenReplacingConstructors: true }) assert.equal(result.extendWhenReplacingConstructors, undefined) assert.equal(subject().extendWhenReplacingConstructors, undefined) @@ -30,7 +30,7 @@ module.exports = { )) }, 'overriding a non-existent property': () => { - subject({wat: 'wat?'}) + subject({ wat: 'wat?' }) td.verify(log.error('td.config', '"wat" is not a valid configuration ' + diff --git a/test/unit/imitate/create-imitation.test.js b/test/unit/imitate/create-imitation.test.js index 3b5ba932..de1a7ae8 100644 --- a/test/unit/imitate/create-imitation.test.js +++ b/test/unit/imitate/create-imitation.test.js @@ -45,7 +45,7 @@ module.exports = { assert.deepEqual(result, 'fake thing') }, 'other instances': () => { - const original = {a: 'b'} + const original = { a: 'b' } const result = subject(original, []) @@ -65,7 +65,7 @@ module.exports = { }, 'generators do not blow up and just return themselves i guess': () => { const generator = () => {} - td.when(tdFunction(), {ignoreExtraArgs: true}).thenReturn('fake thing') + td.when(tdFunction(), { ignoreExtraArgs: true }).thenReturn('fake thing') td.when(isGenerator(generator)).thenReturn(true) assert.strictEqual(subject(generator, []), generator) diff --git a/test/unit/imitate/index.test.js b/test/unit/imitate/index.test.js index 73f51d97..0c93173b 100644 --- a/test/unit/imitate/index.test.js +++ b/test/unit/imitate/index.test.js @@ -26,10 +26,10 @@ module.exports = { td.verify(overwriteChildren('another thing', 'fake2', td.matchers.isA(Function))) }, 'breaks cycles by tracking encounteredObjects': () => { - const top = {type: 'top'} + const top = { type: 'top' } const childCallbackCaptor = td.matchers.captor() td.when(initializeNames(top, undefined)).thenReturn(['lol']) - td.when(createImitation(top, ['lol']), {times: 1}).thenReturn('fake-top') + td.when(createImitation(top, ['lol']), { times: 1 }).thenReturn('fake-top') const result = subject(top) diff --git a/test/unit/imitate/overwrite-children/copy-props.test.js b/test/unit/imitate/overwrite-children/copy-props.test.js index 84ac0ea9..470e98db 100644 --- a/test/unit/imitate/overwrite-children/copy-props.test.js +++ b/test/unit/imitate/overwrite-children/copy-props.test.js @@ -5,7 +5,7 @@ import subject from '../../../../src/imitate/overwrite-children/copy-props' module.exports = { 'copies basic props retaining existing': () => { const thing = {} - const target = {d: 5} + const target = { d: 5 } subject(target, { a: basicPropDescriptorFor(1), @@ -21,8 +21,8 @@ module.exports = { 'overwrites only writable and configurable existing props': () => { const target = Object.defineProperties({}, { a: basicPropDescriptorFor(4), - b: basicPropDescriptorFor(5, {writable: false}), - c: basicPropDescriptorFor(6, {configurable: false}) + b: basicPropDescriptorFor(5, { writable: false }), + c: basicPropDescriptorFor(6, { configurable: false }) }) subject(target, { @@ -53,7 +53,7 @@ module.exports = { const target = {} subject(target, { - lol: basicPropDescriptorFor(42, {enumerable: false}) + lol: basicPropDescriptorFor(42, { enumerable: false }) }) assert.equal(target.lol, 42) @@ -69,8 +69,8 @@ module.exports = { const target = {} subject(target, { - a: basicPropDescriptorFor(42, {enumerable: true}), - b: basicPropDescriptorFor(foo, {enumerable: true}) + a: basicPropDescriptorFor(42, { enumerable: true }), + b: basicPropDescriptorFor(foo, { enumerable: true }) }) assert.equal(target.a, 42) @@ -79,7 +79,7 @@ module.exports = { assert.strictEqual(Object.getOwnPropertyDescriptor(target, 'b').enumerable, true) }, 'only copies props passed to it': () => { - const target = {d: 4} + const target = { d: 4 } subject(target, { a: basicPropDescriptorFor(1), diff --git a/test/unit/imitate/overwrite-children/index.test.js b/test/unit/imitate/overwrite-children/index.test.js index e6e9acdd..3e44675f 100644 --- a/test/unit/imitate/overwrite-children/index.test.js +++ b/test/unit/imitate/overwrite-children/index.test.js @@ -14,9 +14,9 @@ module.exports = { subject('some original', 'some target', () => { throw new Error('do not fire!') }) - td.verify(gatherProps(), {ignoreExtraArgs: true, times: 0}) - td.verify(copyProps(), {ignoreExtraArgs: true, times: 0}) - td.verify(chainPrototype(), {ignoreExtraArgs: true, times: 0}) + td.verify(gatherProps(), { ignoreExtraArgs: true, times: 0 }) + td.verify(copyProps(), { ignoreExtraArgs: true, times: 0 }) + td.verify(chainPrototype(), { ignoreExtraArgs: true, times: 0 }) }, 'an array': () => { const target = [] @@ -27,8 +27,8 @@ module.exports = { subject(['foo', 'bar'], target, overwriteChildren) assert.deepEqual(target, ['fake foo', 'fake bar']) - td.verify(gatherProps(), {ignoreExtraArgs: true, times: 0}) - td.verify(copyProps(), {ignoreExtraArgs: true, times: 0}) + td.verify(gatherProps(), { ignoreExtraArgs: true, times: 0 }) + td.verify(copyProps(), { ignoreExtraArgs: true, times: 0 }) }, 'an object': () => { const overwriteChildren = td.function('.overwriteChildren') diff --git a/test/unit/log.test.js b/test/unit/log.test.js index 57d8b34c..5438b656 100644 --- a/test/unit/log.test.js +++ b/test/unit/log.test.js @@ -8,14 +8,14 @@ module.exports = { }, '.warn': { 'not ignoring warnings': () => { - td.when(config()).thenReturn({ignoreWarnings: false}) + td.when(config()).thenReturn({ ignoreWarnings: false }) subject.warn('aFunc', 'a message', 'http://url') td.verify(console.warn('Warning: testdouble.js - aFunc - a message (see: http://url )')) }, 'ignoring warnings': () => { - td.when(config()).thenReturn({ignoreWarnings: true}) + td.when(config()).thenReturn({ ignoreWarnings: true }) subject.warn('aFunc', 'a message', 'http://url') @@ -24,14 +24,14 @@ module.exports = { }, '.error': { 'not suppressing errors': () => { - td.when(config()).thenReturn({suppressErrors: false}) + td.when(config()).thenReturn({ suppressErrors: false }) assert.throws(() => { subject.error('aFunc', 'a message', 'http://url') }, /Error: testdouble\.js - aFunc - a message \(see: http:\/\/url \)/) }, 'suppressing errors': () => { - td.when(config()).thenReturn({suppressErrors: true}) + td.when(config()).thenReturn({ suppressErrors: true }) assert.doesntThrow(() => { subject.error('aFunc', 'a message', 'http://url') diff --git a/test/unit/log/ensure-promise.test.js b/test/unit/log/ensure-promise.test.js index 1b9f618f..f7c0e9cb 100644 --- a/test/unit/log/ensure-promise.test.js +++ b/test/unit/log/ensure-promise.test.js @@ -7,7 +7,7 @@ module.exports = { subject = require('../../../src/log/ensure-promise').default }, 'config has no promise set (warn)': () => { - td.when(config()).thenReturn({promiseConstructor: null}) + td.when(config()).thenReturn({ promiseConstructor: null }) subject('warn') @@ -23,7 +23,7 @@ testdouble.js which promise constructor to use with \`td.config\`, like so: )) }, 'config has a promise set': () => { - td.when(config()).thenReturn({promiseConstructor: function () {}}) + td.when(config()).thenReturn({ promiseConstructor: function () {} }) subject('warn') @@ -31,7 +31,7 @@ testdouble.js which promise constructor to use with \`td.config\`, like so: assert.equal(td.explain(log.error).callCount, 0) }, 'config has no promise set (error level)': () => { - td.when(config()).thenReturn({promiseConstructor: null}) + td.when(config()).thenReturn({ promiseConstructor: null }) subject('error') @@ -49,7 +49,7 @@ a promise constructor with \`td.config\`, like this: }, 'config has a promise set (on error level)': () => { - td.when(config()).thenReturn({promiseConstructor: function () {}}) + td.when(config()).thenReturn({ promiseConstructor: function () {} }) subject('error') diff --git a/test/unit/satisfy/deliver-outcome.test.js b/test/unit/satisfy/deliver-outcome.test.js index 9e4bae54..70b58543 100644 --- a/test/unit/satisfy/deliver-outcome.test.js +++ b/test/unit/satisfy/deliver-outcome.test.js @@ -16,7 +16,7 @@ module.exports = { assert.equal(result, 'pants') }, 'thenDo calls current outcome': () => { - const call = new Call({a: 1}, ['sauce', 'nice']) + const call = new Call({ a: 1 }, ['sauce', 'nice']) let context, args const userFunc = function (...someArgs) { context = this @@ -28,7 +28,7 @@ module.exports = { const result = subject(stubbing, call) assert.equal(result, 'nailed it') - assert.deepEqual(context, {a: 1}) + assert.deepEqual(context, { a: 1 }) assert.deepEqual(args, ['sauce', 'nice']) }, 'thenThrow throws current outcome': () => { diff --git a/test/unit/satisfy/find-last-stubbing-match.test.js b/test/unit/satisfy/find-last-stubbing-match.test.js index c4dee220..e99492bd 100644 --- a/test/unit/satisfy/find-last-stubbing-match.test.js +++ b/test/unit/satisfy/find-last-stubbing-match.test.js @@ -49,7 +49,7 @@ module.exports = { const call = new Call(this, [42]) const stubbing1 = new Stubbing('thenBlah', [42], ['blah']) const stubbing2 = new Stubbing('thenBlah', ['pants'], ['blah']) - const stubbing3 = new Stubbing('thenBlah', [42], ['blah'], {times: 2}) + const stubbing3 = new Stubbing('thenBlah', [42], ['blah'], { times: 2 }) stubbingRegister.add(double, stubbing1) stubbingRegister.add(double, stubbing2) stubbingRegister.add(double, stubbing3) diff --git a/test/unit/satisfy/invoke-callbacks.test.js b/test/unit/satisfy/invoke-callbacks.test.js index c001bffb..9019f76c 100644 --- a/test/unit/satisfy/invoke-callbacks.test.js +++ b/test/unit/satisfy/invoke-callbacks.test.js @@ -11,7 +11,7 @@ module.exports = { }, 'invokes a basic callback matcher with args': () => { // TODO: once matchers & callbacks are ported to value types, replace w/that - const callbackMatcher = {args: ['pants']} + const callbackMatcher = { args: ['pants'] } const stubbing = new Stubbing('thenBlah', [42, callbackMatcher]) const realCallback = () => {} const call = new Call(null, [42, realCallback]) @@ -68,7 +68,7 @@ module.exports = { }, 'passes delay & defer settings to callLater': () => { const callbackMatcher = {} - const stubbing = new Stubbing('thenBlah', [callbackMatcher], [], {delay: 42, defer: true}) + const stubbing = new Stubbing('thenBlah', [callbackMatcher], [], { delay: 42, defer: true }) const realCallback = () => {} const call = new Call(null, [realCallback]) td.when(isCallback(callbackMatcher)).thenReturn(true) diff --git a/test/unit/share/create-promise.test.js b/test/unit/share/create-promise.test.js index dfaa6c7d..423a269a 100644 --- a/test/unit/share/create-promise.test.js +++ b/test/unit/share/create-promise.test.js @@ -19,7 +19,7 @@ module.exports = { handler(resolver, rejecter) } } - td.when(config()).thenReturn({promiseConstructor: fakePromise}) + td.when(config()).thenReturn({ promiseConstructor: fakePromise }) stubbing = new Stubbing(null, null, ['pants'], { defer: 'a defer', delay: 'a delay' diff --git a/test/unit/value/call-log.test.js b/test/unit/value/call-log.test.js index 2af2bdc8..ca89e134 100644 --- a/test/unit/value/call-log.test.js +++ b/test/unit/value/call-log.test.js @@ -38,15 +38,15 @@ module.exports = { assert.deepEqual(subject.for(double2), [call2]) const third = subject.pop() - assert.deepEqual(third, {double: double1, call: call3}) + assert.deepEqual(third, { double: double1, call: call3 }) assert.deepEqual(subject.for(double1), [call1]) const second = subject.pop() - assert.deepEqual(second, {double: double2, call: call2}) + assert.deepEqual(second, { double: double2, call: call2 }) assert.deepEqual(subject.for(double2), []) const first = subject.pop() - assert.deepEqual(first, {double: double1, call: call1}) + assert.deepEqual(first, { double: double1, call: call1 }) assert.deepEqual(subject.for(double1), []) } } diff --git a/test/unit/value/stubbing.test.js b/test/unit/value/stubbing.test.js index 3358d90b..3a4be5c3 100644 --- a/test/unit/value/stubbing.test.js +++ b/test/unit/value/stubbing.test.js @@ -13,7 +13,7 @@ module.exports = { assert.equal(subject.hasTimesRemaining, true) }, 'times set to 0': () => { - const subject = new Stubbing(null, null, null, {times: 0}) + const subject = new Stubbing(null, null, null, { times: 0 }) assert.equal(subject.hasTimesRemaining, false) @@ -22,7 +22,7 @@ module.exports = { assert.equal(subject.hasTimesRemaining, false) }, 'times set to 1': () => { - const subject = new Stubbing(null, null, null, {times: 1}) + const subject = new Stubbing(null, null, null, { times: 1 }) assert.equal(subject.hasTimesRemaining, true) @@ -31,7 +31,7 @@ module.exports = { assert.equal(subject.hasTimesRemaining, false) }, 'times set to 2': () => { - const subject = new Stubbing(null, null, null, {times: 2}) + const subject = new Stubbing(null, null, null, { times: 2 }) assert.equal(subject.hasTimesRemaining, true) @@ -44,7 +44,7 @@ module.exports = { assert.equal(subject.hasTimesRemaining, false) }, 'guards against duplicate calls (only count once)': () => { - const subject = new Stubbing(null, null, null, {times: 2}) + const subject = new Stubbing(null, null, null, { times: 2 }) assert.equal(subject.hasTimesRemaining, true) diff --git a/test/unit/verify/index.test.js b/test/unit/verify/index.test.js index a53eab38..97f7cbf1 100644 --- a/test/unit/verify/index.test.js +++ b/test/unit/verify/index.test.js @@ -15,8 +15,8 @@ module.exports = { 'verified to have occurred as configured': () => { const double = new Double() const call = new Call() - const config = {some: 'option'} - td.when(popDemonstration()).thenReturn({double, call}) + const config = { some: 'option' } + td.when(popDemonstration()).thenReturn({ double, call }) td.when(didCallOccur(double, call, config)).thenReturn(true) subject(/* imagine double('a','b','c') */ undefined, config) @@ -28,8 +28,8 @@ module.exports = { 'demonstrated call DID NOT occur, failing test': () => { const double = new Double() const call = new Call() - const config = {some: 'option'} - td.when(popDemonstration()).thenReturn({double, call}) + const config = { some: 'option' } + td.when(popDemonstration()).thenReturn({ double, call }) td.when(didCallOccur(double, call, config)).thenReturn(false) subject(/* imagine double('a','b','X') */ undefined, config) @@ -39,7 +39,7 @@ module.exports = { assert.equal(td.explain(warnIfAlsoStubbed).callCount, 0) }, 'demonstration missing blows up': () => { - const config = {some: 'option'} + const config = { some: 'option' } td.when(popDemonstration()).thenThrow(new Error('wups')) assert.throws(() => { diff --git a/test/unit/when/add-implied-callback-arg-if-necessary.test.js b/test/unit/when/add-implied-callback-arg-if-necessary.test.js index 74d17ba9..74576112 100644 --- a/test/unit/when/add-implied-callback-arg-if-necessary.test.js +++ b/test/unit/when/add-implied-callback-arg-if-necessary.test.js @@ -12,14 +12,14 @@ module.exports = { assert.deepEqual(result, [{}, 50]) }, 'type is thenCallback and no callback matcher is in the args': () => { - td.when(isCallback(), {ignoreExtraArgs: true}).thenReturn(false) + td.when(isCallback(), { ignoreExtraArgs: true }).thenReturn(false) const result = subject('thenCallback', [42, 'pants']) assert.deepEqual(result, [42, 'pants', callback]) }, 'type is thenCallback and a callback matcher IS in the args': () => { - td.when(isCallback('a callback'), {ignoreExtraArgs: true}).thenReturn(true) + td.when(isCallback('a callback'), { ignoreExtraArgs: true }).thenReturn(true) const result = subject('thenCallback', [42, 'pants', 'a callback']) diff --git a/test/unit/when/index.test.js b/test/unit/when/index.test.js index 004c14c7..e99a46ea 100644 --- a/test/unit/when/index.test.js +++ b/test/unit/when/index.test.js @@ -20,7 +20,7 @@ module.exports = { const result = subject('_fake rehearsal arg_', 'some options') - td.verify(ensureRehearsal({double, call})) + td.verify(ensureRehearsal({ double, call })) assert.equal(result, 'chained methods') const stubbings = StubbingRegister.instance.get(double) assert.equal(stubbings.length, 1)