|
| 1 | +var should = require('should'); |
| 2 | +var vm = require('vm'); |
| 3 | +var fs = require('fs'); |
| 4 | +var filename = __filename.replace(/\.test\.js$/, '.js'); |
| 5 | +vm.runInThisContext(fs.readFileSync(filename), filename); |
| 6 | + |
| 7 | + |
| 8 | +describe('capitalize', function() { |
| 9 | + it('should exist', function(){ |
| 10 | + should.exist(capitalize); |
| 11 | + }); |
| 12 | + |
| 13 | + it('should be a function', function() { |
| 14 | + capitalize.should.be.a.Function; |
| 15 | + }); |
| 16 | + |
| 17 | + it('should return an string', function() { |
| 18 | + var result = capitalize('hello'); |
| 19 | + should.exist(result); |
| 20 | + result.should.be.an.instanceof(String); |
| 21 | + }); |
| 22 | + |
| 23 | + it('should return an empty string if no input provided', function() { |
| 24 | + var result = capitalize(); |
| 25 | + result.should.be.eql(''); |
| 26 | + }); |
| 27 | + |
| 28 | + it('should capitalize a single character', function(){ |
| 29 | + var result = capitalize('a'); |
| 30 | + result.should.be.eql('A'); |
| 31 | + }); |
| 32 | + |
| 33 | + it('should capitalize the first letter of multiple worlds', function(){ |
| 34 | + var result = capitalize('hello world'); |
| 35 | + result.should.be.eql('Hello World'); |
| 36 | + }); |
| 37 | + |
| 38 | + it('should not change capitalization for any other character', function(){ |
| 39 | + var result = capitalize('hELLO wORLD'); |
| 40 | + result.should.be.eql('HELLO WORLD'); |
| 41 | + }); |
| 42 | + |
| 43 | +}); |
0 commit comments