examples/simple/services/functionalService.js
function getStuffAndDeleteSecret(opts, someArgument) {
  // We depend on "stuffs" repository.
  const stuffs = opts.stuffs

  // We may now carry on.
  return stuffs.getStuff(someArgument).then(stuff => {
    // Modify return value. Just to prove this is testable.
    delete stuff.secret
    return stuff
  })
}
function getStuffAndDeleteSecret(opts, someArgument) {
  // We depend on "stuffs" repository.
  const stuffs = opts.stuffs

  // We may now carry on.
  return stuffs.getStuff(someArgument).then(stuff => {
    // Modify return value. Just to prove this is testable.
    delete stuff.secret
    return stuff
  })
}
function getStuffAndDeleteSecret ( opts , someArgument ) { // We depend on "stuffs" repository. const stuffs = opts . stuffs // We may now carry on. return stuffs . getStuff ( someArgument ) . then ( stuff => { // Modify return value. Just to prove this is testable. delete stuff . secret return stuff } ) }
By exporting this function as-is, we can inject mocks as the first argument!!!!!
By exporting this function as - is we can inject mocks as the first argument!!!!!