Skip to content

Commit

Permalink
standard --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
searls committed Oct 8, 2018
1 parent 3e03d23 commit 5659f33
Show file tree
Hide file tree
Showing 39 changed files with 103 additions and 103 deletions.
2 changes: 1 addition & 1 deletion src/explain.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:')
: ''
}

Expand Down
2 changes: 1 addition & 1 deletion src/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/replace/module/jest-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/replace/module/require-actual.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion src/share/create-promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
4 changes: 2 additions & 2 deletions src/store/calls.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/store/stubbings.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ var createPromise = (stubbing, value, willResolve) => {
return new Promise((resolve, reject) => {
callCallback(stubbing, () =>
willResolve ? resolve(value) : reject(value)
, [value])
, [value])
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/value/call-log.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:')
}
}

Expand All @@ -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:`)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/verify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/when.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion test/safe/args-match.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
10 changes: 5 additions & 5 deletions test/safe/callback.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) => {
Expand Down
6 changes: 3 additions & 3 deletions test/safe/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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 ' +
Expand Down
4 changes: 2 additions & 2 deletions test/safe/explain.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions test/safe/imitate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions test/safe/log.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -53,7 +53,7 @@ module.exports = {
},
'.error': {
'suppressErrors: true' () {
td.config({suppressErrors: true})
td.config({ suppressErrors: true })

subject.error('hi', 'hi')

Expand Down
14 changes: 7 additions & 7 deletions test/safe/matchers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/safe/stringify-anything.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
6 changes: 3 additions & 3 deletions test/safe/typescript-typings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ export = {

const FakeBear = td.constructor<Bear>(Bear)

assert.equal(td.explain(FakeBear.prototype.sleep).isTestDouble, true)
assert.strictEqual(td.explain(FakeBear.prototype.sleep).isTestDouble, true)

const bear = td.object<Bear>('A bear')

td.when(bear.sleep()).thenReturn('zzzzzz')

assert.equal(bear.sleep(), 'zzzzzz')
assert.strictEqual(bear.sleep(), 'zzzzzz')
}

const testObject = {
Expand Down Expand Up @@ -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.'
)
Expand Down
2 changes: 1 addition & 1 deletion test/safe/verify.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ module.exports = {
'using deep matchers': {
'single level': {
beforeEach () {
testDouble({value: 55})
testDouble({ value: 55 })
},
'satisfied' () {
td.verify(testDouble({
Expand Down
26 changes: 13 additions & 13 deletions test/safe/when.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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)
},
Expand Down Expand Up @@ -207,7 +207,7 @@ module.exports = {
}
}
}
td.config({promiseConstructor: FakePromise})
td.config({ promiseConstructor: FakePromise })
},
'td.when…thenResolve' (done) {
td.when(testDouble(10)).thenResolve('pants')
Expand All @@ -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')

Expand Down Expand Up @@ -278,15 +278,15 @@ 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()]

assert._isEqual(result, ['pants', 'pants', undefined])
},
'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()]

Expand Down
6 changes: 3 additions & 3 deletions test/unit/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 ' +
Expand Down

0 comments on commit 5659f33

Please sign in to comment.