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', ->
stringHelpers = _stringHelpers_
describe '.uniFold', ->
it 'normalizes the input string', ->
text = 'die Stra\u00DFe'
it 'removes hungarian marks', ->
text = 'Fürge rőt róka túlszökik zsíros étkű kutyán'
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', ->
stub = sinon.stub(unorm, "nfkd").returns('')
stringHelpers.uniFold ''
it 'removes greek marks', ->
text = 'Καλημέρα κόσμε'
decoded = stringHelpers.uniFold text
expected = 'Καλημερα κοσμε'
sinon.assert.called unorm.nfkd
stub.restore()
assert.equal decoded, expected
it 'removes combining characters', ->
text = 'Fürge rőt róka túlszökik zsíros étkű kutyán'
it 'removes japanese marks', ->
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
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