-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathslug.js
39 lines (30 loc) · 1.07 KB
/
slug.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'use strict'
const assert = require('assert')
const zmd = require('../zmd')
const Slugger = zmd.Slugger
let slugger
describe('Slugger', function () {
beforeEach(function () {
slugger = new Slugger()
})
it('It should return a lowercase string', function () {
assert.strictEqual(slugger.get('Test'), 'test')
})
it('It should support collisons', function () {
assert.strictEqual(slugger.get('test'), 'test')
assert.strictEqual(slugger.get('test'), 'test-1')
assert.strictEqual(slugger.get('test'), 'test-2')
})
it('It should support number collisions', function () {
assert.strictEqual(slugger.get('test 1'), 'test-1')
assert.strictEqual(slugger.get('test'), 'test')
assert.strictEqual(slugger.get('test'), 'test-2')
})
it('It should remove punctuation character', function () {
assert.strictEqual(slugger.get('demo.html'), 'demohtml')
assert.strictEqual(slugger.get('test#section'), 'testsection')
})
it('It should replace space to -', function () {
assert.strictEqual(slugger.get('space between'), 'space-between')
})
})