Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / i / test / utils / string-test.js
1 (function() {
2   var assert, vows, util;
3
4   vows = require('vows');
5
6   assert = require('assert');
7
8   util = require('../../lib/util');
9
10   vows.describe('Module core extension String').addBatch({
11     'Testing value': {
12       topic: 'bullet',
13       'join the keys': function(topic) {
14         return assert.equal(util.string.value(topic), 'bullet');
15       }
16     },
17     'Testing gsub': {
18       topic: 'bullet',
19       'when no args': function(topic) {
20         return assert.equal(util.string.gsub(topic), 'bullet');
21       },
22       'when only 1 arg': function(topic) {
23         return assert.equal(util.string.gsub(topic, /./), 'bullet');
24       },
25       'when given proper args': function(topic) {
26         return assert.equal(util.string.gsub(topic, /[aeiou]/, '*'), 'b*ll*t');
27       },
28       'when replacement is a function': {
29         'with many groups': function(topic) {
30           var str;
31           str = util.string.gsub(topic, /([aeiou])(.)/, function($) {
32             return "<" + $[1] + ">" + $[2];
33           });
34           return assert.equal(str, 'b<u>ll<e>t');
35         },
36         'with no groups': function(topic) {
37           var str;
38           str = util.string.gsub(topic, /[aeiou]/, function($) {
39             return "<" + $[1] + ">";
40           });
41           return assert.equal(str, 'b<u>ll<e>t');
42         }
43       },
44       'when replacement is special': {
45         'with many groups': function(topic) {
46           return assert.equal(util.string.gsub(topic, /([aeiou])(.)/, '<$1>$2'), 'b<u>ll<e>t');
47         },
48         'with no groups': function(topic) {
49           return assert.equal(util.string.gsub(topic, /[aeiou]/, '<$1>'), 'b<u>ll<e>t');
50         }
51       }
52     },
53     'Testing capitalize': {
54       topic: 'employee salary',
55       'normal': function(topic) {
56         return assert.equal(util.string.capitalize(topic), 'Employee Salary');
57       }
58     },
59     'Testing upcase': {
60       topic: 'bullet',
61       'only first letter should be upcase': function(topic) {
62         return assert.equal(util.string.upcase(topic), 'Bullet');
63       },
64       'letter after underscore': function(topic) {
65         return assert.equal(util.string.upcase('bullet_record'), 'Bullet_Record');
66       },
67       'letter after slash': function(topic) {
68         return assert.equal(util.string.upcase('bullet_record/errors'), 'Bullet_Record/Errors');
69       },
70       'no letter after space': function(topic) {
71         return assert.equal(util.string.upcase('employee salary'), 'Employee salary');
72       }
73     },
74     'Testing downcase': {
75       topic: 'BULLET',
76       'only first letter should be downcase': function(topic) {
77         return assert.equal(util.string.downcase(topic), 'bULLET');
78       },
79       'letter after underscore': function(topic) {
80         return assert.equal(util.string.downcase('BULLET_RECORD'), 'bULLET_rECORD');
81       },
82       'letter after slash': function(topic) {
83         return assert.equal(util.string.downcase('BULLET_RECORD/ERRORS'), 'bULLET_rECORD/eRRORS');
84       }
85     }
86   })["export"](module);
87
88 }).call(this);