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
69
/* global describe,it */
 
var getSlug = require('../lib/speakingurl');
 
describe('getSlug titleCase', function () {
    'use strict';
 
    it('should title-case the characters', function (done) {
 
        getSlug('This is big foo', {
                titleCase: true
            })
            .should.eql('This-Is-Big-Foo');
 
        getSlug('This is Big foo', {
                titleCase: true
            })
            .should.eql('This-Is-Big-Foo');
 
        getSlug('Don\'t drink and drive', {
                titleCase: true
            })
            .should.eql('Don-t-Drink-And-Drive');
 
        done();
    });
 
    it('should title-case the characters with custom array', function (done) {
 
        getSlug('This is yet foo and bar', {
                titleCase: ['and', 'yet']
            })
            .should.eql('This-Is-yet-Foo-and-Bar');
 
        getSlug('This is a foo and an angry bird', {
                titleCase: ['a', 'an', 'and']
            })
            .should.eql('This-Is-a-Foo-and-an-Angry-Bird');
 
        getSlug('This is a foo and an angry bird show', {
                titleCase: ['a']
            })
            .should.eql('This-Is-a-Foo-And-An-Angry-Bird-Show');
 
        getSlug('Don\'t drink and drive', {
                titleCase: ['and']
            })
            .should.eql('Don-t-Drink-and-Drive');
 
        getSlug('Don\'t drink and drive', {
                titleCase: {}
            })
            .should.eql('Don-t-Drink-And-Drive');
 
        getSlug('Don\'t drink and drive', {
                titleCase: {
                    'drink': 'drive'
                }
            })
            .should.eql('Don-t-Drink-And-Drive');
 
        getSlug('Don\'t drink and drive', {
                titleCase: 42
            })
            .should.eql('Don-t-Drink-And-Drive');
 
        done();
    });
});