Skip to content

Commit

Permalink
Fix bug when not given options
Browse files Browse the repository at this point in the history
Closes GH-5.
Closes GH-6.

Reviewed-by: Titus Wormer <tituswormer@gmail.com>
  • Loading branch information
foray1010 authored Feb 18, 2020
1 parent 1d5f377 commit dcd629a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function titleCase(str, options) {
if (!str) return ''

const stop = opts.stopwords || defaults
const keep = options.keepSpaces
const keep = opts.keepSpaces
const splitter = /(\s+|[-‑–—])/

return str
Expand Down
12 changes: 12 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,15 @@ test('titleCase', function(t) {
})
t.end()
})

test('allow undefined `options`', function(t) {
const patterns = [
['this is a test', 'This Is a Test'],
['Thing With Extra Spaces', 'Thing With Extra Spaces']
]

patterns.forEach(pattern => {
t.equal(titleCase(pattern[0]), pattern[1], pattern[1])
})
t.end()
})

0 comments on commit dcd629a

Please sign in to comment.