test-anything icon indicating copy to clipboard operation
test-anything copied to clipboard

Exercise 3 is not using the minimal boilerplatte?

Open dmitriz opened this issue 6 years ago • 0 comments

The following solves the exercise 3:

var t = require('tap')
var fancify = require(process.argv[2])

t.is(fancify('Hello'), `~*~Hello~*~`)
t.is(fancify('Hello', true), `~*~HELLO~*~`)
t.is(fancify('Hello', false, '!'), `~!~Hello~!~`)

That feels simpler (e.g. no nesting) than the solution provided:

var test = require('tape')
var fancify = require(process.argv[2])

test('fancify', function (t) {
  t.equal(fancify('Wat'), '~*~Wat~*~', 'Wraps a string in ~*~')
  t.equal(fancify('Wat', true), '~*~WAT~*~', 'Optionally makes it allcaps')
  t.equal(fancify('Wat', false, '%'), '~%~Wat~%~', 'Optionally allows to set the character')
  t.end()
})

https://github.com/workshopper/test-anything/blob/master/exercises/tape-it-together/solution.md

Also, no need to write t.end(), which feels noisy.

So I wonder about possible reasoning behind the more verbose solution to the same problem?

dmitriz avatar May 20 '18 06:05 dmitriz