|
2 | 2 |
|
3 | 3 | require('mocha');
|
4 | 4 | var assert = require('assert');
|
| 5 | +var utils = require('../lib/utils'); |
5 | 6 | var HTML = require('../lib/utils/html');
|
6 | 7 |
|
7 |
| -describe('html', function() { |
8 |
| - describe('parseAttributes', function() { |
9 |
| - it('should parse attributes', function() { |
10 |
| - assert.equal(HTML.parseAttributes({a: 'b', c: 200 }), 'a="b" c="200"'); |
| 8 | +describe('utils', function() { |
| 9 | + describe('chop', function() { |
| 10 | + it('should return an empty string if undefined', function() { |
| 11 | + assert.equal(utils.chop(), ''); |
| 12 | + }); |
| 13 | + it('should remove non-word characters from start of string', function() { |
| 14 | + assert.equal(utils.chop('- foo bar baz'), 'foo bar baz'); |
| 15 | + }); |
| 16 | + it('should remove non-word characters from end of string', function() { |
| 17 | + assert.equal(utils.chop('foo bar baz _- '), 'foo bar baz'); |
11 | 18 | });
|
12 | 19 | });
|
13 |
| -}); |
14 | 20 |
|
| 21 | + describe('changecase', function() { |
| 22 | + it('should return an empty string if undefined', function() { |
| 23 | + assert.equal(utils.changecase(), ''); |
| 24 | + }); |
| 25 | + it('should lowercase a mixed case string', function() { |
| 26 | + assert.equal(utils.changecase('fooBarBazQux'), 'foobarbazqux'); |
| 27 | + }); |
| 28 | + it('should lowercase a single character', function() { |
| 29 | + assert.equal(utils.changecase('f'), 'f'); |
| 30 | + assert.equal(utils.changecase('A'), 'a'); |
| 31 | + }); |
| 32 | + }); |
| 33 | + |
| 34 | + describe('html', function() { |
| 35 | + describe('condense', function() { |
| 36 | + it('should condense multiple newlines into a single newline', function() { |
| 37 | + assert.equal(HTML.condense('foo\r\n \r\n bar\n'), 'foo\n\nbar\n'); |
| 38 | + }); |
| 39 | + }); |
| 40 | + |
| 41 | + describe('padcomments', function() { |
| 42 | + it('should add newlines around comments', function() { |
| 43 | + assert.equal(HTML.padcomments('<!-- foo -->'), '\n<!-- foo -->'); |
| 44 | + }); |
| 45 | + }); |
| 46 | + |
| 47 | + describe('parseAttributes', function() { |
| 48 | + it('should parse attributes', function() { |
| 49 | + assert.equal(HTML.parseAttributes({a: 'b', c: 200 }), 'a="b" c="200"'); |
| 50 | + }); |
| 51 | + }); |
| 52 | + |
| 53 | + describe('toAttributes', function() { |
| 54 | + it('should convert an object hash into html attributes', function() { |
| 55 | + var hash = {disabled: true, display: 'hidden', class: 'fade'}; |
| 56 | + assert.equal(HTML.toAttributes(hash), ' disabled display="hidden" class="fade"'); |
| 57 | + }); |
| 58 | + }); |
| 59 | + }); |
| 60 | +}); |
0 commit comments