|
| 1 | +/// <reference path="../../../typings/_custom.d.ts" /> |
| 2 | +import {CapitalizePipe, CapitalizeFactory} from './Capitalize-Pipe'; |
| 3 | + |
| 4 | +describe('Capitalize', () => { |
| 5 | + |
| 6 | + describe('CapitalizePipe', () => { |
| 7 | + var subject; |
| 8 | + var result; |
| 9 | + var pipe; |
| 10 | + |
| 11 | + beforeEach(() => { |
| 12 | + pipe = new CapitalizePipe(); |
| 13 | + }); |
| 14 | + afterEach(() => { |
| 15 | + expect(subject).toEqual(result); |
| 16 | + }); |
| 17 | + |
| 18 | + describe('#support', () => { |
| 19 | + |
| 20 | + it('should support string', () => { |
| 21 | + subject = pipe.supports('yolo'); |
| 22 | + result = true; |
| 23 | + }); |
| 24 | + |
| 25 | + it('should not support null', () => { |
| 26 | + subject = pipe.supports(null); |
| 27 | + result = false; |
| 28 | + }); |
| 29 | + |
| 30 | + it('should not support NaN', () => { |
| 31 | + subject = pipe.supports(NaN); |
| 32 | + result = false; |
| 33 | + }); |
| 34 | + |
| 35 | + it('should not support new Object()', () => { |
| 36 | + subject = pipe.supports(new Object()); |
| 37 | + result = false; |
| 38 | + }); |
| 39 | + |
| 40 | + it('should not support function(){}', () => { |
| 41 | + subject = pipe.supports(function(){}); |
| 42 | + result = false; |
| 43 | + }); |
| 44 | + |
| 45 | + }); |
| 46 | + |
| 47 | + describe('#transform', () => { |
| 48 | + it('should transform string to Capitalized versions', () => { |
| 49 | + subject = pipe.transform('yolo'); |
| 50 | + result = 'Yolo'; |
| 51 | + }); |
| 52 | + |
| 53 | + it('should transform all strings to Capitalized versions', () => { |
| 54 | + var str = 'what does the scouter say about its power level'; |
| 55 | + |
| 56 | + subject = pipe.transform(str, true); |
| 57 | + result = 'What Does The Scouter Say About Its Power Level'; |
| 58 | + }); |
| 59 | + |
| 60 | + }); |
| 61 | + |
| 62 | + |
| 63 | + describe('#capitalizeWord', () => { |
| 64 | + it('should capitalized a word', () => { |
| 65 | + subject = pipe.capitalizeWord('something'); |
| 66 | + result = 'Something'; |
| 67 | + }); |
| 68 | + |
| 69 | + it('should only capitalized first char', () => { |
| 70 | + subject = pipe.capitalizeWord('something something something'); |
| 71 | + result = 'Something something something'; |
| 72 | + }); |
| 73 | + |
| 74 | + }); |
| 75 | + |
| 76 | + |
| 77 | + }); |
| 78 | + |
| 79 | + describe('CapitalizeFactory', () => { |
| 80 | + var subject; |
| 81 | + var result; |
| 82 | + var factory; |
| 83 | + |
| 84 | + beforeEach(() => { |
| 85 | + factory = new CapitalizeFactory(); |
| 86 | + }); |
| 87 | + |
| 88 | + afterEach(() => { |
| 89 | + expect(subject).toEqual(result); |
| 90 | + }); |
| 91 | + |
| 92 | + it('should exist', () => { |
| 93 | + subject = Boolean(factory); |
| 94 | + result = true; |
| 95 | + }); |
| 96 | + |
| 97 | + describe('#support', () => { |
| 98 | + it('should support string', () => { |
| 99 | + subject = factory.supports('yolo'); |
| 100 | + result = true; |
| 101 | + }); |
| 102 | + |
| 103 | + it('should not support null', () => { |
| 104 | + subject = factory.supports(null); |
| 105 | + result = false; |
| 106 | + }); |
| 107 | + |
| 108 | + it('should not support NaN', () => { |
| 109 | + subject = factory.supports(NaN); |
| 110 | + result = false; |
| 111 | + }); |
| 112 | + |
| 113 | + it('should not support new Object()', () => { |
| 114 | + subject = factory.supports(new Object()); |
| 115 | + result = false; |
| 116 | + }); |
| 117 | + |
| 118 | + it('should not support function(){}', () => { |
| 119 | + subject = factory.supports(function(){}); |
| 120 | + result = false; |
| 121 | + }); |
| 122 | + |
| 123 | + |
| 124 | + }); |
| 125 | + |
| 126 | + describe('#create', () => { |
| 127 | + it('should be instance of CapitalizePipe', () => { |
| 128 | + subject = factory.create() instanceof CapitalizePipe; |
| 129 | + result = true; |
| 130 | + }); |
| 131 | + |
| 132 | + }); |
| 133 | + |
| 134 | + |
| 135 | + }); |
| 136 | + |
| 137 | + |
| 138 | +}); |
0 commit comments