Commit 97f829b2 authored by Gergely Ujvari's avatar Gergely Ujvari

Add more tests for stringHelper

parent 383cfa4c
...@@ -10,22 +10,44 @@ describe 'h.helpers.stringHelpers', -> ...@@ -10,22 +10,44 @@ describe 'h.helpers.stringHelpers', ->
stringHelpers = _stringHelpers_ stringHelpers = _stringHelpers_
describe '.uniFold', -> describe '.uniFold', ->
it 'normalizes the input string', -> it 'removes hungarian marks', ->
text = 'die Stra\u00DFe' text = 'Fürge rőt róka túlszökik zsíros étkű kutyán'
decoded = stringHelpers.uniFold text decoded = stringHelpers.uniFold text
expected = 'Furge rot roka tulszokik zsiros etku kutyan'
assert.equal decoded, 'die Straße' assert.equal decoded, expected
it 'calls the right normalization', -> it 'removes greek marks', ->
stub = sinon.stub(unorm, "nfkd").returns('') text = 'Καλημέρα κόσμε'
stringHelpers.uniFold '' decoded = stringHelpers.uniFold text
expected = 'Καλημερα κοσμε'
sinon.assert.called unorm.nfkd assert.equal decoded, expected
stub.restore()
it 'removes combining characters', -> it 'removes japanese marks', ->
text = 'Fürge rőt róka túlszökik zsíros étkű kutyán' text = 'カタカナコンバータ'
decoded = stringHelpers.uniFold text decoded = stringHelpers.uniFold text
expected = 'Furge rot roka tulszokik zsiros etku kutyan' expected = 'カタカナコンハータ'
assert.equal decoded, expected
it 'removes marathi marks', ->
text = 'काचं शक्नोम्यत्तुम'
decoded = stringHelpers.uniFold text
expected = 'कच शकनमयततम'
assert.equal decoded, expected
it 'removes thai marks', ->
text = 'ฉันกินกระจกได้ แต่มันไม่ทำให้ฉันเจ็บ'
decoded = stringHelpers.uniFold text
expected = 'ฉนกนกระจกได แตมนไมทาใหฉนเจบ'
assert.equal decoded, expected
it 'removes all marks', ->
text = '̀ ́ ̂ ̃ ̄ ̅ ̆ ̇ ̈ ̉ ̊ ̋ ̌ ̍ ̎ ̏ ̐ ̑ ̒ ̓ ̔ ̕ ̖ ̗ ̘ ̙ ̚ ̛ ̜ ̝ ̞ ̟ ̠ ̡ ̢ ̣ ̤ ̥ ̦ ̧ ̨ ̩ ̪ ̫ ̬ ̭ ̮ ̯ ̰ ̱ ̲ ̳ ̴ ̵ ̶ ̷ ̸ ̹ ̺ ̻ ̼ ̽ ̾ ̿ ̀ ́ ͂ ̓ ̈́ ͅ ͠ ͡"'
decoded = stringHelpers.uniFold text
expected = ' "'
assert.equal decoded, expected 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