Commit 12d2b302 authored by Gergely Ujvari's avatar Gergely Ujvari

Unit test for string-helpers

parent 54d8d08b
......@@ -41,6 +41,7 @@ module.exports = function(config) {
'h/static/scripts/vendor/moment-timezone-data.js',
'h/static/scripts/vendor/Markdown.Converter.js',
'h/static/scripts/vendor/sockjs-0.3.4.js',
'h/static/scripts/vendor/unorm.js',
'h/static/scripts/vendor/uuid.js',
'h/static/scripts/app.js',
'h/static/scripts/auth.js',
......
assert = chai.assert
sinon.assert.expose(assert, prefix: '')
describe 'h.helpers.stringHelpers', ->
stringHelpers = null
beforeEach module('h.helpers.stringHelpers')
beforeEach inject (_stringHelpers_) ->
stringHelpers = _stringHelpers_
describe '.unidecode', ->
it 'normalizes the input string', ->
text = 'die Stra\u00DFe'
decoded = stringHelpers.unidecode text
assert.equal decoded, 'die Straße'
it 'calls the right normalization', ->
unorm.nfc = sinon.stub().returns('')
stringHelpers.unidecode '', 'nfc'
sinon.assert.called unorm.nfc
it 'removes combining characters', ->
text = 'Fürge rőt róka túlszökik zsíros étkű kutyán'
decoded = stringHelpers.unidecode text
expected = 'Furge rot roka tulszokik zsiros etku kutyan'
assert.equal decoded, expected
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment