File: test.js

package info (click to toggle)
node-pascalcase 0.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 108 kB
  • ctags: 4
  • sloc: makefile: 4; sh: 2
file content (42 lines) | stat: -rw-r--r-- 1,397 bytes parent folder | download | duplicates (2)
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
'use strict';

/* deps: mocha */
var assert = require('assert');
var should = require('should');
var pascalcase = require('./');

describe('pascalcase', function () {
  it('should uppercase a single character string:', function () {
    pascalcase('a').should.equal('A');
  });

  it('should work with spaces:', function () {
    pascalcase('foo bar baz').should.equal('FooBarBaz');
  });

  it('should not lowercase existing camelcasing:', function () {
    pascalcase('fooBarBaz').should.equal('FooBarBaz');
    pascalcase('FooBarBaz').should.equal('FooBarBaz');
    pascalcase(' FooBarBaz').should.equal('FooBarBaz');
    pascalcase(' fooBarBaz').should.equal('FooBarBaz');
  });

  it('should work with other non-word-characters:', function () {
    pascalcase('foo_bar-baz').should.equal('FooBarBaz');
    pascalcase('foo.bar.baz').should.equal('FooBarBaz');
    pascalcase('foo/bar/baz').should.equal('FooBarBaz');
    pascalcase('foo[bar)baz').should.equal('FooBarBaz');
    pascalcase('#foo+bar*baz').should.equal('FooBarBaz');
    pascalcase('$foo~bar`baz').should.equal('FooBarBaz');
  });

  it('should strip leading non-word-characters:', function () {
    pascalcase('_foo_bar-baz-').should.equal('FooBarBaz');
  });

  it('should throw an error when invalid args are passed:', function () {
    (function () {
      pascalcase();
    }).should.throw('expected a string.');
  });
});