WXL
3 天以前 2cc85c64f1c64a2dbaeae276a3e2ca8420de76b7
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* global describe,it */
 
var getSlug = require('../lib/speakingurl');
 
describe('getSlug smart truncate', function () {
    'use strict';
 
    it('should maintain case characters, with smart truncate', function (done) {
 
        getSlug('Foobarbaz, Bar Baz', {
                truncate: 12
            })
            .should.eql('foobarbaz');
 
        getSlug('Foobarbaz, Bar Baz', {
                truncate: 15
            })
            .should.eql('foobarbaz-bar');
 
        getSlug(' Foobarbaz, Bar Baz', {
                truncate: 15
            })
            .should.eql('foobarbaz-bar');
 
        getSlug('  Foobarbaz,    Bar Baz', {
                truncate: 15
            })
            .should.eql('foobarbaz-bar');
 
        getSlug('Foo Foo bar Zoo Bar Baz', {
                truncate: 15
            })
            .should.eql('foo-foo-bar-zoo');
 
        getSlug('Foo Foo bar ZooBar Baz', {
                truncate: 15
            })
            .should.eql('foo-foo-bar');
 
        getSlug('Foo Foo bar ZooBar Baz', {
                truncate: 15
            })
            .should.eql('foo-foo-bar');
 
        getSlug('Foo Foo Bar Bar', {
                truncate: "foo"
            })
            .should.eql('foo-foo-bar-bar');
 
        getSlug('Foo Foo Bar Bar', {
                truncate: false
            })
            .should.eql('foo-foo-bar-bar');
 
        getSlug('Foo Foo Bar Bar', {
                truncate: true
            })
            .should.eql('foo-foo-bar-bar');
 
        getSlug('a Foo', {
                truncate: true
            })
            .should.eql('a-foo');
 
        done();
 
    });
});