1 | var should = require('./init.js');
|
2 | var app, compound;
|
3 |
|
4 | describe('utilities', function () {
|
5 | before(function() {
|
6 | app = getApp();
|
7 | compound = app.compound;
|
8 | });
|
9 |
|
10 | it('should camelize string', function () {
|
11 | var cc = compound.utils.camelize;
|
12 | cc('underscored_string').should.equal('underscoredString');
|
13 | cc('underscored_string', 1).should.equal('UnderscoredString');
|
14 | });
|
15 |
|
16 | it('should humanize string', function () {
|
17 | var hs = compound.utils.humanize;
|
18 | hs('hey_man').should.equal('Hey man');
|
19 | });
|
20 |
|
21 | it('should classify string', function () {
|
22 | var hs = compound.utils.classify;
|
23 | hs('bio_robots').should.equal('bioRobot');
|
24 | });
|
25 |
|
26 | it('should underscore string', function () {
|
27 | var us = compound.utils.underscore;
|
28 | us('IAmARobot').should.equal('i_am_a_robot');
|
29 | us('_IAmARobot').should.equal('_i_am_a_robot');
|
30 | us('_iAmARobot').should.equal('_i_am_a_robot');
|
31 | });
|
32 |
|
33 | it('should add spaces', function () {
|
34 | compound.utils.addSpaces('hello', 8).should.equal('hello ');
|
35 | compound.utils.addSpaces('hello', 8, true).should.equal(' hello');
|
36 | });
|
37 |
|
38 | describe('utils#inherits', function() {
|
39 |
|
40 | it('should inherit superclass', function() {
|
41 | function MyClass(){}
|
42 | SuperClass.classMethod = function(){};
|
43 | function SuperClass(){}
|
44 | compound.utils.inherits(MyClass, SuperClass);
|
45 | var myObj = new MyClass;
|
46 | myObj.should.be.an.instanceOf(SuperClass);
|
47 | MyClass.super_.should.equal(SuperClass);
|
48 | should.not.exists(MyClass.classMethod);
|
49 | });
|
50 |
|
51 | it('should inherit superclass with class methods', function() {
|
52 | function MyClass(){}
|
53 | SuperClass.classMethod = function(){};
|
54 | function SuperClass(){}
|
55 | compound.utils.inherits(MyClass, SuperClass, true);
|
56 | var myObj = new MyClass;
|
57 | myObj.should.be.an.instanceOf(SuperClass);
|
58 | MyClass.super_.should.equal(SuperClass);
|
59 | should.exists(MyClass.classMethod);
|
60 | });
|
61 |
|
62 | });
|
63 | });
|
64 |
|