mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
* Fix: 2-byte character support of slug * Fix: Decodes slug to display slug * Fix: Removed a logic of replaceDiacritics * Fix: Fixed slugify to pass tests * Fix: Fixed not to remove underscore * Adds the test for slugify.js * Fix: Fix to jump to heading * Added a comment * Fix: Created click event only linking to heading * Fix: Fix to use handleLinkClick(e) * Fix: Changed the regex rule * Fix: Changed the regex rule of extractId
59 lines
1.6 KiB
JavaScript
59 lines
1.6 KiB
JavaScript
import test from 'ava'
|
|
import slugify from 'browser/lib/slugify'
|
|
|
|
test('alphabet and digit', t => {
|
|
const upperAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
|
const lowerAlphabet = 'abcdefghijklmnopqrstuvwxyz'
|
|
const digit = '0123456789'
|
|
const testCase = upperAlphabet + lowerAlphabet + digit
|
|
const decodeSlug = decodeURI(slugify(testCase))
|
|
|
|
t.true(decodeSlug === testCase)
|
|
})
|
|
|
|
test('should delete unavailable symbols', t => {
|
|
const availableSymbols = '_-'
|
|
const testCase = availableSymbols + '][!\'#$%&()*+,./:;<=>?@\\^{|}~`'
|
|
const decodeSlug = decodeURI(slugify(testCase))
|
|
|
|
t.true(decodeSlug === availableSymbols)
|
|
})
|
|
|
|
test('should convert from white spaces between words to hyphens', t => {
|
|
const testCase = 'This is one'
|
|
const expectedString = 'This-is-one'
|
|
const decodeSlug = decodeURI(slugify(testCase))
|
|
|
|
t.true(decodeSlug === expectedString)
|
|
})
|
|
|
|
test('should remove leading white spaces', t => {
|
|
const testCase = ' This is one'
|
|
const expectedString = 'This-is-one'
|
|
const decodeSlug = decodeURI(slugify(testCase))
|
|
|
|
t.true(decodeSlug === expectedString)
|
|
})
|
|
|
|
test('should remove trailing white spaces', t => {
|
|
const testCase = 'This is one '
|
|
const expectedString = 'This-is-one'
|
|
const decodeSlug = decodeURI(slugify(testCase))
|
|
|
|
t.true(decodeSlug === expectedString)
|
|
})
|
|
|
|
test('2-byte charactor support', t => {
|
|
const testCase = '菠萝芒果テストÀžƁƵ'
|
|
const decodeSlug = decodeURI(slugify(testCase))
|
|
|
|
t.true(decodeSlug === testCase)
|
|
})
|
|
|
|
test('emoji', t => {
|
|
const testCase = '🌸'
|
|
const decodeSlug = decodeURI(slugify(testCase))
|
|
|
|
t.true(decodeSlug === testCase)
|
|
})
|