const test = require('tape')
const maxstache = require('./')

test('should assert input types', function (t) {
  t.plan(2)
  t.throws(maxstache.bind(null), /string/)
  t.throws(maxstache.bind(null, 'foobar', 'no object'), /object/)
})

test('should replace strings', function (t) {
  t.plan(1)

  const str = 'My name is {{name}}'
  const ctx = { name: 'jjjohnny' }
  const res = maxstache(str, ctx)

  t.equal(res, 'My name is jjjohnny')
})

test('should work even if the string starts with a var', function (t) {
  t.plan(1)

  const str = '{{name}}, my name is'
  const ctx = { name: 'Yoda' }
  const res = maxstache(str, ctx)

  t.equal(res, 'Yoda, my name is')
})

@@ -658,12 +658,270 @@
 ame is')%0A%7D)%0A
+%0Atest('should work even if two vars are next to each other', function (t) %7B%0A  t.plan(1)%0A%0A  const str = '%7B%7Bfirst%7D%7D%7B%7Bsecond%7D%7D, my name is'%0A  const ctx = %7B first: 'Foo', second: 'bar' %7D%0A  const res = maxstache(str, ctx)%0A%0A  t.equal(res, 'Foobar, my name is')%0A%7D)%0A

add double var test