From d14f555305c0d946ddde7aae4328be00071c4883 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Ewerl=C3=B6f?= Date: Mon, 23 Nov 2015 18:58:09 +0100 Subject: [PATCH 01/10] removed the empty file --- jasmine-matchers/jasmine-matchers-tests.ts.tscparams | 1 - 1 file changed, 1 deletion(-) delete mode 100644 jasmine-matchers/jasmine-matchers-tests.ts.tscparams diff --git a/jasmine-matchers/jasmine-matchers-tests.ts.tscparams b/jasmine-matchers/jasmine-matchers-tests.ts.tscparams deleted file mode 100644 index d3f5a12fa..000000000 --- a/jasmine-matchers/jasmine-matchers-tests.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ - From b51e822a32abc08c8965d589389a48157d88d0a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Ewerl=C3=B6f?= Date: Mon, 23 Nov 2015 18:58:24 +0100 Subject: [PATCH 02/10] added the definitions for jamie mason's jasmine-matchers --- .../jamiemason-jasmine-matchers.d.ts | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 jasmine-matchers/jamiemason-jasmine-matchers.d.ts diff --git a/jasmine-matchers/jamiemason-jasmine-matchers.d.ts b/jasmine-matchers/jamiemason-jasmine-matchers.d.ts new file mode 100644 index 000000000..119cccb89 --- /dev/null +++ b/jasmine-matchers/jamiemason-jasmine-matchers.d.ts @@ -0,0 +1,108 @@ +// Type definitions for jasmine-matchers 2.0.0-beta2 +// Project: https://github.com/JamieMason/Jasmine-Matchers +// Definitions by: UserPixel +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/* +Typings 2015 UserPixel + +TypeScript tests auto-extracted from jasmine-matchers unit test. + +Original jasmine-matchers license applies: + +Copyright (C) 2013, uxebu Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +/// + +declare module jasmine { + interface Matchers { + // These functions are written in the order defined in the src directory of jasmine-matchers + // The type system is used smartly whenever it can provide value (by looking at the code of every matcher) + toBeAfter(otherDate: Date, actualDate: Date): boolean; // + toBeArray(actualArray: any[]): boolean; // + toBeArrayOfBooleans(actualArray: any[]): boolean; // + toBeArrayOfNumbers(actualArray: any[]): boolean; + toBeArrayOfObjects(actualArray: any[]): boolean; + toBeArrayOfSize(size: number, actualArray: any[]): boolean; + toBeArrayOfStrings(actualArray: any[]): boolean; + toBeBefore(otherDate: Date, actualDate: Date): boolean; // + toBeBoolean(actual: boolean): boolean; + toBeCalculable(actual: number): boolean; + toBeDate(actual: Date): boolean; + toBeEmptyArray(actualArray: any[]): boolean; + toBeEmptyObject(actual: {}): boolean; + toBeEmptyString(actual: string): boolean; + toBeEvenNumber(actual: number): boolean; + toBeFalse(actual: boolean): boolean; + toBeFunction(actual: any): boolean; + toBeHtmlString(actual: string): boolean; + toBeIso8601(actual: string): boolean; + toBeJsonString(actual: string): boolean; + toBeLongerThan(actual: string): boolean; + toBeNonEmptyArray(actualArray: any[]): boolean; + toBeNonEmptyObject(actual: {}): boolean; + toBeNonEmptyString(actual: string): boolean; + toBeNumber(actual: number): boolean; + toBeObject(actual: {}): boolean; + toBeOddNumber(actual: number): boolean; + toBeSameLengthAs(other: string, actual: string): boolean; + toBeShorterThan(other: string, actual: string): boolean; + toBeString(actual: string): boolean; + toBeTrue(actual: boolean): boolean; + toBeWhitespace(actual: string): boolean; + toBeWholeNumber(actual: number): boolean; + toBeWithinRange(floor: number, ceiling: number, actual: number): boolean; + + toEndWith(subString: string, actual: string): boolean; + + toHaveArray(key: string, actual: {}): boolean; + toHaveArrayOfBooleans(key: string, actual: {}): boolean; + toHaveArrayOfNumbers(key: string, actual: {}): boolean; + toHaveArrayOfObjects(key: string, actual: {}): boolean; + toHaveArrayOfSize(key: string, size: number, actual: {}): boolean; + toHaveArrayOfStrings(key: string, actual: {}): boolean; + toHaveBoolean(key: string, actual: {}): boolean; + toHaveCalculable(key: string, actual: {}): boolean; + toHaveDate(key: string, actual: {}): boolean; + toHaveDateAfter(key: string, actual: {}): boolean; + toHaveDateBefore(key: string, actual: {}): boolean; + toHaveEmptyArray(key: string, actual: {}): boolean; + toHaveEmptyObject(key: string, actual: {}): boolean; + toHaveEmptyString(key: string, actual: {}): boolean; + toHaveEvenNumber(key: string, actual: {}): boolean; + toHaveFalse(key: string, actual: {}): boolean; + toHaveHtmlString(key: string, actual: {}): boolean; + toHaveIso8601(key: string, actual: {}): boolean; + toHaveJsonString(key: string, actual: {}): boolean; + toHaveMember(key: string, actual: {}): boolean; + toHaveMethod(key: string, actual: {}): boolean; + toHaveNonEmptyArray(key: string, actual: {}): boolean; + toHaveNonEmptyObject(key: string, actual: {}): boolean; + toHaveNonEmptyString(key: string, actual: {}): boolean; + toHaveNumber(key: string, actual: {}): boolean; + toHaveNumberWithinRange(key: string, actual: {}): boolean; + toHaveObject(key: string, actual: {}): boolean; + toHaveOddNumber(key: string, actual: {}): boolean; + toHaveString(key: string, actual: {}): boolean; + toHaveStringLongerThan(key: string, actual: {}): boolean; + toHaveStringSameLengthAs(key: string, actual: {}): boolean; + toHaveStringShorterThan(key: string, actual: {}): boolean; + toHaveTrue(key: string, actual: {}): boolean; + toHaveWhitespaceString(key: string, actual: {}): boolean; + toHaveWholeNumber(key: string, actual: {}): boolean; + + toImplement(api: {}, actual: {}): boolean; + + toStartWith(subString: string, actual: string): boolean; + + toThrowAnyError(throwerFn: (...any) => any): boolean; + toThrowErrorOfType(type: string, throwerFn: (...any) => any): boolean; + } +} From fd48b8e7d1153c45c4e085d1cd0900d326923c3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Ewerl=C3=B6f?= Date: Mon, 23 Nov 2015 19:00:25 +0100 Subject: [PATCH 03/10] fixd priliminary compiler errors --- jasmine-matchers/jamiemason-jasmine-matchers.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jasmine-matchers/jamiemason-jasmine-matchers.d.ts b/jasmine-matchers/jamiemason-jasmine-matchers.d.ts index 119cccb89..6a2b8a49a 100644 --- a/jasmine-matchers/jamiemason-jasmine-matchers.d.ts +++ b/jasmine-matchers/jamiemason-jasmine-matchers.d.ts @@ -102,7 +102,7 @@ declare module jasmine { toStartWith(subString: string, actual: string): boolean; - toThrowAnyError(throwerFn: (...any) => any): boolean; - toThrowErrorOfType(type: string, throwerFn: (...any) => any): boolean; + toThrowAnyError(throwerFn: () => any): boolean; + toThrowErrorOfType(type: string, throwerFn: () => any): boolean; } } From 8cbcd054b62891994cec69a7ea3cf138d23dcbe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Ewerl=C3=B6f?= Date: Mon, 23 Nov 2015 19:32:49 +0100 Subject: [PATCH 04/10] added all tests from the original repo and passed all the tests --- .../jamiemason-jasmine-matchers-tests.ts | 1994 +++++++++++++++++ .../jamiemason-jasmine-matchers.d.ts | 148 +- 2 files changed, 2068 insertions(+), 74 deletions(-) create mode 100644 jasmine-matchers/jamiemason-jasmine-matchers-tests.ts diff --git a/jasmine-matchers/jamiemason-jasmine-matchers-tests.ts b/jasmine-matchers/jamiemason-jasmine-matchers-tests.ts new file mode 100644 index 000000000..ade9e8cb5 --- /dev/null +++ b/jasmine-matchers/jamiemason-jasmine-matchers-tests.ts @@ -0,0 +1,1994 @@ +/// +/// + +// Taken directly from the test directory of the original repo + +declare var describeWhenNotArray: (arr: string) => void; +declare var describeToBeArrayOfX: (arr: string, descriptor: {}) => void; +declare var describeToHaveArrayX: (arr: string, descriptor: () => void) => void; +declare var describeToHaveX: (arr: string, descriptor: () => void) => void; +declare var describeToHaveBooleanX: (arr: string, descriptor: () => void) => void; +declare var badReference: {someValue: any}; +var _undefined; + +describe('toBeAfter', function() { + describe('when invoked', function() { + describe('when value is a Date', function() { + describe('when date occurs after another', function() { + it('should confirm', function() { + expect(new Date('2013-01-01T01:00:00.000Z')).toBeAfter(new Date('2013-01-01T00:00:00.000Z')); + }); + }); + describe('when date does NOT occur after another', function() { + it('should deny', function() { + expect(new Date('2013-01-01T00:00:00.000Z')).not.toBeAfter(new Date('2013-01-01T01:00:00.000Z')); + }); + }); + }); + }); +}); + + +describe('toBeArray', function() { + describe('when invoked', function() { + describe('when subject is a true Array', function() { + it('should confirm', function() { + expect([]).toBeArray(); + expect(new Array()).toBeArray(); + }); + }); + describeWhenNotArray('toBeArray'); + }); +}); + + +describe('toBeArrayOfBooleans', function() { + describeToBeArrayOfX('toBeArrayOfBooleans', { + type: 'Boolean', + whenValid: function() { + expect([true]).toBeArrayOfBooleans(); + expect([new Boolean(true)]).toBeArrayOfBooleans(); + expect([new Boolean(false)]).toBeArrayOfBooleans(); + expect([false, true]).toBeArrayOfBooleans(); + }, + whenInvalid: function() { + expect([null]).not.toBeArrayOfBooleans(); + }, + whenMixed: function() { + expect([null, false]).not.toBeArrayOfBooleans(); + expect([null, true]).not.toBeArrayOfBooleans(); + } + }); +}); + + +describe('toBeArrayOfNumbers', function() { + describeToBeArrayOfX('toBeArrayOfNumbers', { + type: 'Number', + whenValid: function() { + expect([1]).toBeArrayOfNumbers(); + expect([new Number(1)]).toBeArrayOfNumbers(); + expect([new Number(0)]).toBeArrayOfNumbers(); + expect([0, 1]).toBeArrayOfNumbers(); + }, + whenInvalid: function() { + expect([null]).not.toBeArrayOfNumbers(); + }, + whenMixed: function() { + expect([null, 0]).not.toBeArrayOfNumbers(); + } + }); +}); + +describe('toBeArrayOfObjects', function() { + describeToBeArrayOfX('toBeArrayOfObjects', { + type: 'Object', + whenValid: function() { + expect([{}, {}]).toBeArrayOfObjects(); + }, + whenInvalid: function() { + expect([null]).not.toBeArrayOfObjects(); + expect(['Object']).not.toBeArrayOfObjects(); + expect(['[object Object]']).not.toBeArrayOfObjects(); + }, + whenMixed: function() { + expect([null, {}]).not.toBeArrayOfObjects(); + } + }); +}); + +describe('toBeArrayOfSize', function() { + describe('when invoked', function() { + describe('when subject is a true Array', function() { + describe('when subject has the expected number of members', function() { + it('should confirm', function() { + expect([]).toBeArrayOfSize(0); + expect([null]).toBeArrayOfSize(1); + expect([false, false]).toBeArrayOfSize(2); + expect([_undefined, _undefined]).toBeArrayOfSize(2); + }); + }); + describe('when subject has an unexpected number of members', function() { + it('should deny', function() { + expect([]).not.toBeArrayOfSize(1); + expect([null]).not.toBeArrayOfSize(0); + expect([true, true]).not.toBeArrayOfSize(1); + }); + }); + }); + describeWhenNotArray('toBeArrayOfSize'); + }); +}); + + +describe('toBeArrayOfStrings', function() { + describeToBeArrayOfX('toBeArrayOfStrings', { + type: 'String', + whenValid: function() { + expect(['truthy']).toBeArrayOfStrings(); + expect([new String('truthy')]).toBeArrayOfStrings(); + expect([new String('')]).toBeArrayOfStrings(); + expect(['', 'truthy']).toBeArrayOfStrings(); + }, + whenInvalid: function() { + expect([null]).not.toBeArrayOfStrings(); + }, + whenMixed: function() { + expect([null, '']).not.toBeArrayOfStrings(); + } + }); +}); + +describe('toBeBefore', function() { + describe('when invoked', function() { + describe('when value is a Date', function() { + describe('when date occurs before another', function() { + it('should confirm', function() { + expect(new Date('2013-01-01T00:00:00.000Z')).toBeBefore(new Date('2013-01-01T01:00:00.000Z')); + }); + }); + describe('when date does NOT occur before another', function() { + it('should deny', function() { + expect(new Date('2013-01-01T01:00:00.000Z')).not.toBeBefore(new Date('2013-01-01T00:00:00.000Z')); + }); + }); + }); + }); +}); + + +describe('toBeBoolean', function() { + describe('when invoked', function() { + describe('when subject not only truthy or falsy, but a boolean', function() { + it('should confirm', function() { + expect(true).toBeBoolean(); + expect(false).toBeBoolean(); + expect(new Boolean(true)).toBeBoolean(); + expect(new Boolean(false)).toBeBoolean(); + }); + }); + describe('when subject is truthy or falsy', function() { + it('should deny', function() { + expect(1).not.toBeBoolean(); + expect(0).not.toBeBoolean(); + }); + }); + }); +}); + +describe('toBeCalculable', function() { + describe('when invoked', function() { + describe('when subject CAN be coerced to be used in mathematical operations', function() { + it('should confirm', function() { + expect('1').toBeCalculable(); + expect('').toBeCalculable(); + expect(null).toBeCalculable(); + }); + }); + describe('when subject can NOT be coerced by JavaScript to be used in mathematical operations', function() { + it('should deny', function() { + expect({}).not.toBeCalculable(); + expect(NaN).not.toBeCalculable(); + }); + }); + }); +}); + +describe('toBeDate', function() { + describe('when invoked', function() { + describe('when value is an instance of Date', function() { + it('should confirm', function() { + expect(new Date()).toBeDate(); + }); + }); + describe('when value is NOT an instance of Date', function() { + it('should deny', function() { + expect(null).not.toBeDate(); + }); + }); + }); +}); + +describe('toBeEmptyArray', function() { + describe('when invoked', function() { + describe('when subject is a true Array', function() { + describe('when subject has members', function() { + it('should confirm', function() { + expect([]).toBeEmptyArray(); + }); + }); + describe('when subject has no members', function() { + it('should deny', function() { + expect([null]).not.toBeEmptyArray(); + expect(['']).not.toBeEmptyArray(); + expect([1]).not.toBeEmptyArray(); + expect([true]).not.toBeEmptyArray(); + expect([false]).not.toBeEmptyArray(); + }); + }); + }); + describeWhenNotArray('toBeEmptyArray'); + }); +}); + +describe('toBeEmptyObject', function() { + beforeEach(function() { + this.Foo = function() {}; + }); + describe('when invoked', function() { + describe('when subject IS an Object with no instance members', function() { + beforeEach(function() { + this.Foo.prototype = { + b: 2 + }; + }); + it('should confirm', function() { + expect(new this.Foo()).toBeEmptyObject(); + expect({}).toBeEmptyObject(); + }); + }); + describe('when subject is NOT an Object with no instance members', function() { + it('should deny', function() { + expect({ + a: 1 + }).not.toBeEmptyObject(); + expect(null).not.toBeNonEmptyObject(); + }); + }); + }); +}); + +describe('toBeEmptyString', function() { + describe('when invoked', function() { + describe('when subject IS a string with no characters', function() { + it('should confirm', function() { + expect('').toBeEmptyString(); + }); + }); + describe('when subject is NOT a string with no characters', function() { + it('should deny', function() { + expect(' ').not.toBeEmptyString(); + }); + }); + }); +}); + +describe('toBeEvenNumber', function() { + describe('when invoked', function() { + describe('when subject IS an even number', function() { + it('should confirm', function() { + expect(2).toBeEvenNumber(); + }); + }); + describe('when subject is NOT an even number', function() { + it('should deny', function() { + expect(1).not.toBeEvenNumber(); + expect(NaN).not.toBeEvenNumber(); + }); + }); + }); +}); + + +describe('toBeFalse', function() { + describe('when invoked', function() { + describe('when subject is not only falsy, but a boolean false', function() { + it('should confirm', function() { + expect(false).toBeFalse(); + expect(new Boolean(false)).toBeFalse(); + }); + }); + describe('when subject is falsy', function() { + it('should deny', function() { + expect(1).not.toBeFalse(); + }); + }); + }); +}); + +describe('toBeFunction', function() { + describe('when invoked', function() { + describe('when subject IS a function', function() { + it('should confirm', function() { + expect(function() {}).toBeFunction(); + }); + }); + describe('when subject is NOT a function', function() { + it('should deny', function() { + expect(/regexp/).not.toBeFunction(); + }); + }); + }); +}); + +describe('toBeHtmlString', function() { + describe('when invoked', function() { + describe('when subject IS a string of HTML markup', function() { + beforeEach(function() { + this.ngMultiLine = ''; + this.ngMultiLine += ''; + this.ngMultiLine += '\n'; + this.ngMultiLine += ' Watch with Google TV'; + this.ngMultiLine += '\n'; + this.ngMultiLine += ''; + this.ngMultiLine += '\n'; + }); + it('should confirm', function() { + expect('text').toBeHtmlString(); + expect('baz').toBeHtmlString(); + expect('
').toBeHtmlString(); + expect('
  • ').toBeHtmlString(); + expect(this.ngMultiLine).toBeHtmlString(); + }); + }); + describe('when subject is NOT a string of HTML markup', function() { + it('should deny', function() { + expect('div').not.toBeHtmlString(); + expect(null).not.toBeHtmlString(); + }); + }); + }); +}); + +describe('toBeIso8601', function() { + describe('when invoked', function() { + describe('when value is a Date String conforming to the ISO 8601 standard', function() { + describe('when specified date is valid', function() { + it('should confirm', function() { + expect('2013-07-08T07:29:15.863Z').toBeIso8601(); + expect('2013-07-08T07:29:15.863').toBeIso8601(); + expect('2013-07-08T07:29:15').toBeIso8601(); + expect('2013-07-08T07:29').toBeIso8601(); + expect('2013-07-08').toBeIso8601(); + }); + }); + describe('when specified date is NOT valid', function() { + it('should deny', function() { + expect('2013-99-12T00:00:00.000Z').not.toBeIso8601(); + expect('2013-12-99T00:00:00.000Z').not.toBeIso8601(); + expect('2013-01-01T99:00:00.000Z').not.toBeIso8601(); + expect('2013-01-01T99:99:00.000Z').not.toBeIso8601(); + expect('2013-01-01T00:00:99.000Z').not.toBeIso8601(); + }); + }); + }); + describe('when value is a String NOT conforming to the ISO 8601 standard', function() { + it('should deny', function() { + expect('2013-07-08T07:29:15.').not.toBeIso8601(); + expect('2013-07-08T07:29:').not.toBeIso8601(); + expect('2013-07-08T07:2').not.toBeIso8601(); + expect('2013-07-08T07:').not.toBeIso8601(); + expect('2013-07-08T07').not.toBeIso8601(); + expect('2013-07-08T').not.toBeIso8601(); + expect('2013-07-0').not.toBeIso8601(); + expect('2013-07-').not.toBeIso8601(); + expect('2013-07').not.toBeIso8601(); + expect('2013-0').not.toBeIso8601(); + expect('2013-').not.toBeIso8601(); + expect('2013').not.toBeIso8601(); + expect('201').not.toBeIso8601(); + expect('20').not.toBeIso8601(); + expect('2').not.toBeIso8601(); + expect('').not.toBeIso8601(); + }); + }); + }); +}); +var _undefined; + +describe('toBeJsonString', function() { + describe('when invoked', function() { + describe('when subject IS a string of parseable JSON', function() { + it('should confirm', function() { + expect('{}').toBeJsonString(); + expect('[]').toBeJsonString(); + expect('[1]').toBeJsonString(); + }); + }); + describe('when subject is NOT a string of parseable JSON', function() { + it('should deny', function() { + expect('[1,]').not.toBeJsonString(); + expect('<>').not.toBeJsonString(); + expect(null).not.toBeJsonString(); + expect('').not.toBeJsonString(); + expect(_undefined).not.toBeJsonString(); + }); + }); + }); +}); + +describe('toBeLongerThan', function() { + describe('when invoked', function() { + describe('when the subject and comparison ARE both strings', function() { + describe('when the subject IS longer than the comparision string', function() { + it('should confirm', function() { + expect('abc').toBeLongerThan('ab'); + expect('a').toBeLongerThan(''); + }); + }); + describe('when the subject is NOT longer than the comparision string', function() { + it('should deny', function() { + expect('ab').not.toBeLongerThan('abc'); + expect('').not.toBeLongerThan('a'); + }); + }); + }); + describe('when the subject and comparison are NOT both strings', function() { + it('should deny (we are asserting the relative lengths of two strings)', function() { + expect('truthy').not.toBeLongerThan(_undefined); + expect(_undefined).not.toBeLongerThan('truthy'); + expect('').not.toBeLongerThan(_undefined); + expect(_undefined).not.toBeLongerThan(''); + }); + }); + }); +}); + +describe('toBeNonEmptyArray', function() { + describe('when invoked', function() { + describe('when subject is a true Array', function() { + describe('when subject has members', function() { + it('should confirm', function() { + expect([null]).toBeNonEmptyArray(); + expect([_undefined]).toBeNonEmptyArray(); + expect(['']).toBeNonEmptyArray(); + }); + }); + describe('when subject has no members', function() { + it('should deny', function() { + expect([]).not.toBeNonEmptyArray(); + }); + }); + }); + describeWhenNotArray('toBeNonEmptyArray'); + }); +}); + +describe('toBeNonEmptyObject', function() { + beforeEach(function() { + this.Foo = function() {}; + }); + describe('when invoked', function() { + describe('when subject IS an Object with at least one instance member', function() { + it('should confirm', function() { + expect({ + a: 1 + }).toBeNonEmptyObject(); + }); + }); + describe('when subject is NOT an Object with at least one instance member', function() { + beforeEach(function() { + this.Foo.prototype = { + b: 2 + }; + }); + it('should deny', function() { + expect(new this.Foo()).not.toBeNonEmptyObject(); + expect({}).not.toBeNonEmptyObject(); + expect(null).not.toBeNonEmptyObject(); + }); + }); + }); +}); + +describe('toBeNonEmptyString', function() { + describe('when invoked', function() { + describe('when subject IS a string with at least one character', function() { + it('should confirm', function() { + expect(' ').toBeNonEmptyString(); + }); + }); + describe('when subject is NOT a string with at least one character', function() { + it('should deny', function() { + expect('').not.toBeNonEmptyString(); + expect(null).not.toBeNonEmptyString(); + }); + }); + }); +}); + +describe('toBeNumber', function() { + describe('when invoked', function() { + describe('when subject IS a number', function() { + it('should confirm', function() { + expect(1).toBeNumber(); + expect(1.11).toBeNumber(); + expect(1e3).toBeNumber(); + expect(0.11).toBeNumber(); + expect(-11).toBeNumber(); + }); + }); + describe('when subject is NOT a number', function() { + it('should deny', function() { + expect('1').not.toBeNumber(); + expect(NaN).not.toBeNumber(); + }); + }); + }); +}); + + +describe('toBeObject', function() { + beforeEach(function() { + this.Foo = function() {}; + }); + describe('when invoked', function() { + describe('when subject IS an Object', function() { + it('should confirm', function() { + expect(new Object()).toBeObject(); + expect(new this.Foo()).toBeObject(); + expect({}).toBeObject(); + }); + }); + describe('when subject is NOT an Object', function() { + it('should deny', function() { + expect(null).not.toBeObject(); + expect(123).not.toBeObject(); + expect('[object Object]').not.toBeObject(); + }); + }); + }); +}); + +describe('toBeOddNumber', function() { + describe('when invoked', function() { + describe('when subject IS an odd number', function() { + it('should confirm', function() { + expect(1).toBeOddNumber(); + }); + }); + describe('when subject is NOT an odd number', function() { + it('should deny', function() { + expect(2).not.toBeOddNumber(); + expect(NaN).not.toBeOddNumber(); + }); + }); + }); +}); +var _undefined; + +describe('toBeSameLengthAs', function() { + describe('when invoked', function() { + describe('when the subject and comparison ARE both strings', function() { + describe('when the subject IS the same length as the comparision string', function() { + it('should confirm', function() { + expect('ab').toBeSameLengthAs('ab'); + }); + }); + describe('when the subject is NOT the same length as the comparision string', function() { + it('should deny', function() { + expect('abc').not.toBeSameLengthAs('ab'); + expect('a').not.toBeSameLengthAs(''); + expect('').not.toBeSameLengthAs('a'); + }); + }); + }); + describe('when the subject and comparison are NOT both strings', function() { + it('should deny (we are asserting the relative lengths of two strings)', function() { + expect('truthy').not.toBeSameLengthAs(_undefined); + expect(_undefined).not.toBeSameLengthAs('truthy'); + expect('').not.toBeSameLengthAs(_undefined); + expect(_undefined).not.toBeSameLengthAs(''); + }); + }); + }); +}); +var _undefined; + +describe('toBeShorterThan', function() { + describe('when invoked', function() { + describe('when the subject and comparison ARE both strings', function() { + describe('when the subject IS shorter than the comparision string', function() { + it('should confirm', function() { + expect('ab').toBeShorterThan('abc'); + expect('').toBeShorterThan('a'); + }); + }); + describe('when the subject is NOT shorter than the comparision string', function() { + it('should deny', function() { + expect('abc').not.toBeShorterThan('ab'); + expect('a').not.toBeShorterThan(''); + }); + }); + }); + describe('when the subject and comparison are NOT both strings', function() { + it('should deny (we are asserting the relative lengths of two strings)', function() { + expect('truthy').not.toBeShorterThan(_undefined); + expect(_undefined).not.toBeShorterThan('truthy'); + expect('').not.toBeShorterThan(_undefined); + expect(_undefined).not.toBeShorterThan(''); + }); + }); + }); +}); + +describe('toBeString', function() { + describe('when invoked', function() { + describe('when subject IS a string of any length', function() { + it('should confirm', function() { + expect('').toBeString(); + expect(' ').toBeString(); + }); + }); + describe('when subject is NOT a string of any length', function() { + it('should deny', function() { + expect(null).not.toBeString(); + }); + }); + }); +}); + + +describe('toBeTrue', function() { + describe('when invoked', function() { + describe('when subject is not only truthy, but a boolean true', function() { + it('should confirm', function() { + expect(true).toBeTrue(); + expect(new Boolean(true)).toBeTrue(); + }); + }); + describe('when subject is truthy', function() { + it('should deny', function() { + expect(1).not.toBeTrue(); + }); + }); + }); +}); + +describe('toBeWhitespace', function() { + describe('when invoked', function() { + describe('when subject IS a string containing only tabs, spaces, returns etc', function() { + it('should confirm', function() { + expect(' ').toBeWhitespace(); + expect('').toBeWhitespace(); + }); + }); + describe('when subject is NOT a string containing only tabs, spaces, returns etc', function() { + it('should deny', function() { + expect('has-no-whitespace').not.toBeWhitespace(); + expect('has whitespace').not.toBeWhitespace(); + expect(null).not.toBeWhitespace(); + }); + }); + }); +}); + +describe('toBeWholeNumber', function() { + describe('when invoked', function() { + describe('when subject IS a number with no positive decimal places', function() { + it('should confirm', function() { + expect(1).toBeWholeNumber(); + expect(0).toBeWholeNumber(); + expect(0.0).toBeWholeNumber(); + }); + }); + describe('when subject is NOT a number with no positive decimal places', function() { + it('should deny', function() { + expect(NaN).not.toBeWholeNumber(); + expect(1.1).not.toBeWholeNumber(); + expect(0.1).not.toBeWholeNumber(); + }); + }); + }); +}); + +describe('toBeWithinRange', function() { + describe('when invoked', function() { + describe('when subject IS a number >= floor and <= ceiling', function() { + it('should confirm', function() { + expect(0).toBeWithinRange(0, 2); + expect(1).toBeWithinRange(0, 2); + expect(2).toBeWithinRange(0, 2); + }); + }); + describe('when subject is NOT a number >= floor and <= ceiling', function() { + it('should deny', function() { + expect(-3).not.toBeWithinRange(0, 2); + expect(-2).not.toBeWithinRange(0, 2); + expect(-1).not.toBeWithinRange(0, 2); + expect(3).not.toBeWithinRange(0, 2); + expect(NaN).not.toBeWithinRange(0, 2); + }); + }); + }); +}); +var _undefined; + +describe('toEndWith', function() { + describe('when invoked', function() { + describe('when subject is NOT an undefined or empty string', function() { + describe('when subject is a string whose trailing characters match the expected string', function() { + it('should confirm', function() { + expect('jamie').toEndWith('mie'); + }); + }); + describe('when subject is a string whose trailing characters DO NOT match the expected string', function() { + it('should deny', function() { + expect('jamie ').not.toEndWith('mie'); + expect('jamiE').not.toEndWith('mie'); + }); + }); + }); + describe('when subject IS an undefined or empty string', function() { + it('should deny', function() { + expect('').not.toEndWith(''); + expect(_undefined).not.toEndWith(''); + expect(_undefined).not.toEndWith('undefined'); + expect('undefined').not.toEndWith(_undefined); + }); + }); + }); +}); + +describe('toHaveArray', function() { + describeToHaveArrayX('toHaveArray', function() { + it('should confirm', function() { + expect({ + memberName: [] + }).toHaveArray('memberName'); + expect({ + memberName: [1, 2, 3] + }).toHaveArray('memberName'); + }); + }); +}); + + +describe('toHaveArrayOfBooleans', function() { + describeToHaveArrayX('toHaveArrayOfBooleans', function() { + describe('when named Array is empty', function() { + it('should confirm', function() { + expect({ + memberName: [] + }).toHaveArrayOfBooleans('memberName'); + }); + }); + describe('when named Array has items', function() { + describe('when all items are booleans', function() { + it('should confirm', function() { + expect({ + memberName: [true] + }).toHaveArrayOfBooleans('memberName'); + expect({ + memberName: [new Boolean(true)] + }).toHaveArrayOfBooleans('memberName'); + expect({ + memberName: [new Boolean(false)] + }).toHaveArrayOfBooleans('memberName'); + expect({ + memberName: [false, true] + }).toHaveArrayOfBooleans('memberName'); + }); + }); + describe('when any item is not a boolean', function() { + it('should deny', function() { + expect({ + memberName: [null] + }).not.toHaveArrayOfBooleans('memberName'); + expect({ + memberName: [null, false] + }).not.toHaveArrayOfBooleans('memberName'); + }); + }); + }); + }); +}); + + +describe('toHaveArrayOfNumbers', function() { + describeToHaveArrayX('toHaveArrayOfNumbers', function() { + describe('when named Array is empty', function() { + it('should confirm', function() { + expect({ + memberName: [] + }).toHaveArrayOfNumbers('memberName'); + }); + }); + describe('when named Array has items', function() { + describe('when all items are numbers', function() { + it('should confirm', function() { + expect({ + memberName: [1] + }).toHaveArrayOfNumbers('memberName'); + expect({ + memberName: [new Number(1)] + }).toHaveArrayOfNumbers('memberName'); + expect({ + memberName: [new Number(0)] + }).toHaveArrayOfNumbers('memberName'); + expect({ + memberName: [0, 1] + }).toHaveArrayOfNumbers('memberName'); + }); + }); + describe('when any item is not a number', function() { + it('should deny', function() { + expect({ + memberName: [null] + }).not.toHaveArrayOfNumbers('memberName'); + expect({ + memberName: [null, 0] + }).not.toHaveArrayOfNumbers('memberName'); + }); + }); + }); + }); +}); + +describe('toHaveArrayOfObjects', function() { + describeToHaveArrayX('toHaveArrayOfObjects', function() { + describe('when named Array is empty', function() { + it('should confirm', function() { + expect({ + memberName: [] + }).toHaveArrayOfObjects('memberName'); + }); + }); + describe('when named Array has items', function() { + describe('when all items are objects', function() { + it('should confirm', function() { + expect({ + memberName: [{}] + }).toHaveArrayOfObjects('memberName'); + expect({ + memberName: [{}, {}] + }).toHaveArrayOfObjects('memberName'); + }); + }); + describe('when any item is not an object', function() { + it('should deny', function() { + expect({ + memberName: [null] + }).not.toHaveArrayOfObjects('memberName'); + expect({ + memberName: [null, {}] + }).not.toHaveArrayOfObjects('memberName'); + }); + }); + }); + }); +}); + +describe('toHaveArrayOfSize', function() { + describeToHaveArrayX('toHaveArrayOfSize', function() { + describe('when number of expected items does not match', function() { + it('should deny', function() { + expect({ + memberName: '' + }).not.toHaveArrayOfSize('memberName'); + expect({ + memberName: ['bar'] + }).not.toHaveArrayOfSize('memberName', 0); + }); + }); + describe('when number of expected items does match', function() { + it('should confirm', function() { + expect({ + memberName: [] + }).toHaveArrayOfSize('memberName', 0); + expect({ + memberName: ['bar'] + }).toHaveArrayOfSize('memberName', 1); + expect({ + memberName: ['bar', 'baz'] + }).toHaveArrayOfSize('memberName', 2); + }); + }); + }); +}); + + +describe('toHaveArrayOfStrings', function() { + describeToHaveArrayX('toHaveArrayOfStrings', function() { + describe('when named Array is empty', function() { + it('should confirm', function() { + expect({ + memberName: [] + }).toHaveArrayOfStrings('memberName'); + }); + }); + describe('when named Array has items', function() { + describe('when all items are strings', function() { + it('should confirm', function() { + expect({ + memberName: ['truthy'] + }).toHaveArrayOfStrings('memberName'); + expect({ + memberName: [new String('truthy')] + }).toHaveArrayOfStrings('memberName'); + expect({ + memberName: [new String('')] + }).toHaveArrayOfStrings('memberName'); + expect({ + memberName: ['', 'truthy'] + }).toHaveArrayOfStrings('memberName'); + }); + }); + describe('when any item is not a string', function() { + it('should deny', function() { + expect({ + memberName: [null] + }).not.toHaveArrayOfStrings('memberName'); + expect({ + memberName: [null, ''] + }).not.toHaveArrayOfStrings('memberName'); + }); + }); + }); + }); +}); + + +describe('toHaveBoolean', function() { + describeToHaveBooleanX('toHaveBoolean', function() { + describe('when primitive', function() { + it('should confirm', function() { + expect({ + memberName: true + }).toHaveBoolean('memberName'); + expect({ + memberName: false + }).toHaveBoolean('memberName'); + }); + }); + describe('when Boolean object', function() { + it('should confirm', function() { + expect({ + memberName: new Boolean(true) + }).toHaveBoolean('memberName'); + expect({ + memberName: new Boolean(false) + }).toHaveBoolean('memberName'); + }); + }); + }); +}); + +describe('toHaveCalculable', function() { + describeToHaveX('toHaveCalculable', function() { + describe('when subject CAN be coerced to be used in mathematical operations', function() { + it('should confirm', function() { + expect({ + memberName: '1' + }).toHaveCalculable('memberName'); + expect({ + memberName: '' + }).toHaveCalculable('memberName'); + expect({ + memberName: null + }).toHaveCalculable('memberName'); + }); + }); + describe('when subject can NOT be coerced by JavaScript to be used in mathematical operations', function() { + it('should deny', function() { + expect({ + memberName: {} + }).not.toHaveCalculable('memberName'); + expect({ + memberName: NaN + }).not.toHaveCalculable('memberName'); + }); + }); + }); +}); + +describe('toHaveDate', function() { + var mockDate; + beforeEach(function() { + mockDate = { + any: new Date(), + early: new Date('2013-01-01T00:00:00.000Z'), + late: new Date('2013-01-01T01:00:00.000Z') + }; + }); + describeToHaveX('toHaveDate', function() { + describe('when member is an instance of Date', function() { + it('should confirm', function() { + expect({ + memberName: mockDate.any + }).toHaveDate('memberName'); + }); + }); + describe('when member is NOT an instance of Date', function() { + it('should deny', function() { + expect({ + memberName: null + }).not.toHaveDate('memberName'); + }); + }); + }); +}); + +describe('toHaveDateAfter', function() { + var mockDate; + beforeEach(function() { + mockDate = { + any: new Date(), + early: new Date('2013-01-01T00:00:00.000Z'), + late: new Date('2013-01-01T01:00:00.000Z') + }; + }); + describeToHaveX('toHaveDateAfter', function() { + describe('when member is an instance of Date', function() { + describe('when date occurs before another', function() { + it('should confirm', function() { + expect({ + memberName: mockDate.late + }).toHaveDateAfter('memberName', mockDate.early); + }); + }); + describe('when date does NOT occur before another', function() { + it('should deny', function() { + expect({ + memberName: mockDate.early + }).not.toHaveDateAfter('memberName', mockDate.late); + }); + }); + }); + describe('when member is NOT an instance of Date', function() { + it('should deny', function() { + expect({ + memberName: null + }).not.toHaveDateAfter('memberName', mockDate.any); + }); + }); + }); +}); + +describeToHaveX('toHaveDateBefore', function() { + var mockDate; + beforeEach(function() { + mockDate = { + any: new Date(), + early: new Date('2013-01-01T00:00:00.000Z'), + late: new Date('2013-01-01T01:00:00.000Z') + }; + }); + describe('when member is an instance of Date', function() { + describe('when date occurs before another', function() { + it('should confirm', function() { + expect({ + memberName: mockDate.early + }).toHaveDateBefore('memberName', mockDate.late); + }); + }); + describe('when date does NOT occur before another', function() { + it('should deny', function() { + expect({ + memberName: mockDate.late + }).not.toHaveDateBefore('memberName', mockDate.early); + }); + }); + }); + describe('when member is NOT an instance of Date', function() { + it('should deny', function() { + expect({ + memberName: null + }).not.toHaveDateBefore('memberName', mockDate.any); + }); + }); +}); + +describe('toHaveEmptyArray', function() { + describeToHaveArrayX('toHaveEmptyArray', function() { + describe('when named array has members', function() { + it('should deny', function() { + expect({ + memberName: [1, 2, 3] + }).not.toHaveEmptyArray('memberName'); + expect({ + memberName: '' + }).not.toHaveEmptyArray('memberName'); + }); + }); + describe('when named array has no members', function() { + it('should confirm', function() { + expect({ + memberName: [] + }).toHaveEmptyArray('memberName'); + }); + }); + }); +}); + +describe('toHaveEmptyObject', function() { + beforeEach(function() { + this.Foo = function() {}; + }); + describeToHaveX('toHaveEmptyObject', function() { + describe('when subject IS an Object with no instance members', function() { + beforeEach(function() { + this.Foo.prototype = { + b: 2 + }; + }); + it('should confirm', function() { + expect({ + memberName: new this.Foo() + }).toHaveEmptyObject('memberName'); + expect({ + memberName: {} + }).toHaveEmptyObject('memberName'); + }); + }); + describe('when subject is NOT an Object with no instance members', function() { + it('should deny', function() { + expect({ + memberName: { + a: 1 + } + }).not.toHaveEmptyObject('memberName'); + expect({ + memberName: null + }).not.toHaveNonEmptyObject('memberName'); + }); + }); + }); +}); + +describe('toHaveEmptyString', function() { + describeToHaveX('toHaveEmptyString', function() { + describe('when subject IS a string with no characters', function() { + it('should confirm', function() { + expect({ + memberName: '' + }).toHaveEmptyString('memberName'); + }); + }); + describe('when subject is NOT a string with no characters', function() { + it('should deny', function() { + expect({ + memberName: ' ' + }).not.toHaveEmptyString('memberName'); + }); + }); + }); +}); + +describe('toHaveEvenNumber', function() { + describeToHaveX('toHaveEvenNumber', function() { + describe('when subject IS an even number', function() { + it('should confirm', function() { + expect({ + memberName: 2 + }).toHaveEvenNumber('memberName'); + }); + }); + describe('when subject is NOT an even number', function() { + it('should deny', function() { + expect({ + memberName: 1 + }).not.toHaveEvenNumber('memberName'); + expect({ + memberName: NaN + }).not.toHaveEvenNumber('memberName'); + }); + }); + }); +}); + +describe('toHaveFalse', function() { + describeToHaveBooleanX('toHaveFalse', function() { + describe('when primitive', function() { + describe('when true', function() { + it('should deny', function() { + expect({ + memberName: true + }).not.toHaveFalse('memberName'); + }); + }); + describe('when false', function() { + it('should confirm', function() { + expect({ + memberName: false + }).toHaveFalse('memberName'); + }); + }); + }); + describe('when Boolean object', function() { + describe('when true', function() { + it('should deny', function() { + expect({ + memberName: new Boolean(true) + }).not.toHaveFalse('memberName'); + }); + }); + describe('when false', function() { + it('should confirm', function() { + expect({ + memberName: new Boolean(false) + }).toHaveFalse('memberName'); + }); + }); + }); + }); +}); + +describe('toHaveHtmlString', function() { + describeToHaveX('toHaveHtmlString', function() { + describe('when subject IS a string of HTML markup', function() { + beforeEach(function() { + this.ngMultiLine = ''; + this.ngMultiLine += ''; + this.ngMultiLine += '\n'; + this.ngMultiLine += ' Watch with Google TV'; + this.ngMultiLine += '\n'; + this.ngMultiLine += ''; + this.ngMultiLine += '\n'; + }); + it('should confirm', function() { + expect({ + memberName: 'text' + }).toHaveHtmlString('memberName'); + expect({ + memberName: 'baz' + }).toHaveHtmlString('memberName'); + expect({ + memberName: '
    ' + }).toHaveHtmlString('memberName'); + expect({ + memberName: '
  • ' + }).toHaveHtmlString('memberName'); + expect({ + memberName: this.ngMultiLine + }).toHaveHtmlString('memberName'); + }); + }); + describe('when subject is NOT a string of HTML markup', function() { + it('should deny', function() { + expect({ + memberName: 'div' + }).not.toHaveHtmlString('memberName'); + expect({ + memberName: null + }).not.toHaveHtmlString('memberName'); + }); + }); + }); +}); + +describe('toHaveIso8601', function() { + describeToHaveX('toHaveIso8601', function() { + describe('when member is a Date String conforming to the ISO 8601 standard', + function() { + describe('when specified date is valid', function() { + it('should confirm', function() { + expect({ + memberName: '2013-07-08T07:29:15.863Z' + }).toHaveIso8601('memberName'); + expect({ + memberName: '2013-07-08T07:29:15.863' + }).toHaveIso8601('memberName'); + expect({ + memberName: '2013-07-08T07:29:15' + }).toHaveIso8601('memberName'); + expect({ + memberName: '2013-07-08T07:29' + }).toHaveIso8601('memberName'); + expect({ + memberName: '2013-07-08' + }).toHaveIso8601('memberName'); + }); + }); + describe('when specified date is NOT valid', function() { + it('should deny', function() { + expect({ + memberName: '2013-99-12T00:00:00.000Z' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-12-99T00:00:00.000Z' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-01-01T99:00:00.000Z' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-01-01T99:99:00.000Z' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-01-01T00:00:99.000Z' + }).not.toHaveIso8601('memberName'); + }); + }); + }); + describe('when member is a String NOT conforming to the ISO 8601 standard', + function() { + it('should deny', function() { + expect({ + memberName: '2013-07-08T07:29:15.' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-07-08T07:29:' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-07-08T07:2' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-07-08T07:' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-07-08T07' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-07-08T' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-07-0' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-07-' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-07' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-0' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '201' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '20' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '' + }).not.toHaveIso8601('memberName'); + }); + }); + }); +}); + +describe('toHaveJsonString', function() { + describeToHaveX('toHaveJsonString', function() { + describe('when subject IS a string of parseable JSON', function() { + it('should confirm', function() { + expect({ + memberName: '{}' + }).toHaveJsonString('memberName'); + expect({ + memberName: '[]' + }).toHaveJsonString('memberName'); + expect({ + memberName: '[1]' + }).toHaveJsonString('memberName'); + }); + }); + describe('when subject is NOT a string of parseable JSON', function() { + it('should deny', function() { + expect({ + memberName: '[1,]' + }).not.toHaveJsonString('memberName'); + expect({ + memberName: '<>' + }).not.toHaveJsonString('memberName'); + expect({ + memberName: null + }).not.toHaveJsonString('memberName'); + expect({ + memberName: '' + }).not.toHaveJsonString('memberName'); + expect({ + memberName: _undefined + }).not.toHaveJsonString('memberName'); + }); + }); + }); +}); + +describe('toHaveMember', function() { + describeToHaveX('toHaveMember', function() {}); +}); + +describe('toHaveMethod', function() { + describeToHaveX('toHaveMethod', function() { + describe('when subject IS a function', function() { + it('should confirm', function() { + expect({ + memberName: function() {} + }).toHaveMethod('memberName'); + }); + }); + describe('when subject is NOT a function', function() { + it('should deny', function() { + expect({ + memberName: /regexp/ + }).not.toHaveMethod('memberName'); + }); + }); + }); +}); + +describe('toHaveNonEmptyArray', function() { + describeToHaveArrayX('toHaveNonEmptyArray', function() { + describe('when named array has no members', function() { + it('should deny', function() { + expect({ + memberName: [] + }).not.toHaveNonEmptyArray('memberName'); + }); + }); + describe('when named array has members', function() { + it('should confirm', function() { + expect({ + memberName: [1, 2, 3] + }).toHaveNonEmptyArray('memberName'); + }); + }); + }); +}); + +describe('toHaveNonEmptyObject', function() { + describeToHaveX('toHaveNonEmptyObject', function() { + beforeEach(function() { + this.Foo = function() {}; + }); + describe('when subject IS an Object with at least one instance member', function() { + it('should confirm', function() { + expect({ + memberName: { + a: 1 + } + }).toHaveNonEmptyObject('memberName'); + }); + }); + describe('when subject is NOT an Object with at least one instance member', function() { + beforeEach(function() { + this.Foo.prototype = { + b: 2 + }; + }); + it('should deny', function() { + expect({ + memberName: new this.Foo() + }).not.toHaveNonEmptyObject('memberName'); + expect({ + memberName: {} + }).not.toHaveNonEmptyObject('memberName'); + expect({ + memberName: null + }).not.toHaveNonEmptyObject('memberName'); + }); + }); + }); +}); + +describe('toHaveNonEmptyString', function() { + describeToHaveX('toHaveNonEmptyString', function() { + describe('when subject IS a string with at least one character', function() { + it('should confirm', function() { + expect({ + memberName: ' ' + }).toHaveNonEmptyString('memberName'); + }); + }); + describe('when subject is NOT a string with at least one character', function() { + it('should deny', function() { + expect({ + memberName: '' + }).not.toHaveNonEmptyString('memberName'); + expect({ + memberName: null + }).not.toHaveNonEmptyString('memberName'); + }); + }); + }); +}); + +describe('toHaveNumber', function() { + describeToHaveX('toHaveNumber', function() { + describe('when subject IS a number', function() { + it('should confirm', function() { + expect({ + memberName: 1 + }).toHaveNumber('memberName'); + expect({ + memberName: 1.11 + }).toHaveNumber('memberName'); + expect({ + memberName: 1e3 + }).toHaveNumber('memberName'); + expect({ + memberName: 0.11 + }).toHaveNumber('memberName'); + expect({ + memberName: -11 + }).toHaveNumber('memberName'); + }); + }); + describe('when subject is NOT a number', function() { + it('should deny', function() { + expect({ + memberName: '1' + }).not.toHaveNumber('memberName'); + expect({ + memberName: NaN + }).not.toHaveNumber('memberName'); + }); + }); + }); +}); + +describe('toHaveNumberWithinRange', function() { + describeToHaveX('toHaveNumberWithinRange', function() { + describe('when subject IS a number >= floor and <= ceiling', function() { + it('should confirm', function() { + expect({ + memberName: 0 + }).toHaveNumberWithinRange('memberName', 0, 2); + expect({ + memberName: 1 + }).toHaveNumberWithinRange('memberName', 0, 2); + expect({ + memberName: 2 + }).toHaveNumberWithinRange('memberName', 0, 2); + }); + }); + describe('when subject is NOT a number >= floor and <= ceiling', function() { + it('should deny', function() { + expect({ + memberName: -3 + }).not.toHaveNumberWithinRange('memberName', 0, 2); + expect({ + memberName: -2 + }).not.toHaveNumberWithinRange('memberName', 0, 2); + expect({ + memberName: -1 + }).not.toHaveNumberWithinRange('memberName', 0, 2); + expect({ + memberName: 3 + }).not.toHaveNumberWithinRange('memberName', 0, 2); + expect({ + memberName: NaN + }).not.toHaveNumberWithinRange('memberName', 0, 2); + }); + }); + }); +}); + +describe('toHaveObject', function() { + describeToHaveX('toHaveObject', function() { + beforeEach(function() { + this.Foo = function() {}; + }); + describe('when subject IS an Object', function() { + it('should confirm', function() { + expect({ + memberName: new Object() + }).toHaveObject('memberName'); + expect({ + memberName: new this.Foo() + }).toHaveObject('memberName'); + expect({ + memberName: {} + }).toHaveObject('memberName'); + }); + }); + describe('when subject is NOT an Object', function() { + it('should deny', function() { + expect({ + memberName: null + }).not.toHaveObject('memberName'); + expect({ + memberName: 123 + }).not.toHaveObject('memberName'); + expect({ + memberName: '[object Object]' + }).not.toHaveObject('memberName'); + }); + }); + }); +}); + +describe('toHaveOddNumber', function() { + describeToHaveX('toHaveOddNumber', function() { + describe('when subject IS an odd number', function() { + it('should confirm', function() { + expect({ + memberName: 1 + }).toHaveOddNumber('memberName'); + }); + }); + describe('when subject is NOT an odd number', function() { + it('should deny', function() { + expect({ + memberName: 2 + }).not.toHaveOddNumber('memberName'); + expect({ + memberName: NaN + }).not.toHaveOddNumber('memberName'); + }); + }); + }); +}); + +describe('toHaveString', function() { + describeToHaveX('toHaveString', function() { + describe('when subject IS a string of any length', function() { + it('should confirm', function() { + expect({ + memberName: '' + }).toHaveString('memberName'); + expect({ + memberName: ' ' + }).toHaveString('memberName'); + }); + }); + describe('when subject is NOT a string of any length', function() { + it('should deny', function() { + expect({ + memberName: null + }).not.toHaveString('memberName'); + }); + }); + }); +}); + +describe('toHaveStringLongerThan', function() { + describeToHaveX('toHaveStringLongerThan', function() { + describe('when the subject and comparison ARE both strings', function() { + describe('when the subject IS longer than the comparision string', function() { + it('should confirm', function() { + expect({ + memberName: 'abc' + }).toHaveStringLongerThan('memberName', 'ab'); + expect({ + memberName: 'a' + }).toHaveStringLongerThan('memberName', ''); + }); + }); + describe('when the subject is NOT longer than the comparision string', function() { + it('should deny', function() { + expect({ + memberName: 'ab' + }).not.toHaveStringLongerThan('memberName', 'abc'); + expect({ + memberName: '' + }).not.toHaveStringLongerThan('memberName', 'a'); + }); + }); + }); + describe('when the subject and comparison are NOT both strings', function() { + it('should deny (we are asserting the relative lengths of two strings)', function() { + expect({ + memberName: 'truthy' + }).not.toHaveStringLongerThan('memberName', _undefined); + expect({ + memberName: _undefined + }).not.toHaveStringLongerThan('memberName', 'truthy'); + expect({ + memberName: '' + }).not.toHaveStringLongerThan('memberName', _undefined); + expect({ + memberName: _undefined + }).not.toHaveStringLongerThan('memberName', ''); + }); + }); + }); +}); + +describe('toHaveStringSameLengthAs', function() { + describeToHaveX('toHaveStringSameLengthAs', function() { + describe('when the subject and comparison ARE both strings', function() { + describe('when the subject IS the same length as the comparision string', function() { + it('should confirm', function() { + expect({ + memberName: 'ab' + }).toHaveStringSameLengthAs('memberName', 'ab'); + }); + }); + describe('when the subject is NOT the same length as the comparision string', function() { + it('should deny', function() { + expect({ + memberName: 'abc' + }).not.toHaveStringSameLengthAs('memberName', 'ab'); + expect({ + memberName: 'a' + }).not.toHaveStringSameLengthAs('memberName', ''); + expect({ + memberName: '' + }).not.toHaveStringSameLengthAs('memberName', 'a'); + }); + }); + }); + describe('when the subject and comparison are NOT both strings', function() { + it('should deny (we are asserting the relative lengths of two strings)', function() { + expect({ + memberName: 'truthy' + }).not.toHaveStringSameLengthAs('memberName', _undefined); + expect({ + memberName: _undefined + }).not.toHaveStringSameLengthAs('memberName', 'truthy'); + expect({ + memberName: '' + }).not.toHaveStringSameLengthAs('memberName', _undefined); + expect({ + memberName: _undefined + }).not.toHaveStringSameLengthAs('memberName', ''); + }); + }); + }); +}); + +describe('toHaveStringShorterThan', function() { + describeToHaveX('toHaveStringShorterThan', function() { + describe('when the subject and comparison ARE both strings', function() { + describe('when the subject IS shorter than the comparision string', function() { + it('should confirm', function() { + expect({ + memberName: 'ab' + }).toHaveStringShorterThan('memberName', 'abc'); + expect({ + memberName: '' + }).toHaveStringShorterThan('memberName', 'a'); + }); + }); + describe('when the subject is NOT shorter than the comparision string', function() { + it('should deny', function() { + expect({ + memberName: 'abc' + }).not.toHaveStringShorterThan('memberName', 'ab'); + expect({ + memberName: 'a' + }).not.toHaveStringShorterThan('memberName', ''); + }); + }); + }); + describe('when the subject and comparison are NOT both strings', function() { + it('should deny (we are asserting the relative lengths of two strings)', function() { + expect({ + memberName: 'truthy' + }).not.toHaveStringShorterThan('memberName', _undefined); + expect({ + memberName: _undefined + }).not.toHaveStringShorterThan('memberName', 'truthy'); + expect({ + memberName: '' + }).not.toHaveStringShorterThan('memberName', _undefined); + expect({ + memberName: _undefined + }).not.toHaveStringShorterThan('memberName', ''); + }); + }); + }); +}); + + +describe('toHaveTrue', function() { + describeToHaveBooleanX('toHaveTrue', function() { + describe('when primitive', function() { + describe('when true', function() { + it('should confirm', function() { + expect({ + memberName: true + }).toHaveTrue('memberName'); + }); + }); + describe('when false', function() { + it('should deny', function() { + expect({ + memberName: false + }).not.toHaveTrue('memberName'); + }); + }); + }); + describe('when Boolean object', function() { + describe('when true', function() { + it('should confirm', function() { + expect({ + memberName: new Boolean(true) + }).toHaveTrue('memberName'); + }); + }); + describe('when false', function() { + it('should deny', function() { + expect({ + memberName: new Boolean(false) + }).not.toHaveTrue('memberName'); + }); + }); + }); + }); +}); + +describe('toHaveWhitespaceString', function() { + describeToHaveX('toHaveWhitespaceString', function() { + describe('when subject IS a string containing only tabs, spaces, returns etc', function() { + it('should confirm', function() { + expect({ + memberName: ' ' + }).toHaveWhitespaceString('memberName'); + expect({ + memberName: '' + }).toHaveWhitespaceString('memberName'); + }); + }); + describe('when subject is NOT a string containing only tabs, spaces, returns etc', function() { + it('should deny', function() { + expect({ + memberName: 'has-no-whitespace' + }).not.toHaveWhitespaceString('memberName'); + expect({ + memberName: 'has whitespace' + }).not.toHaveWhitespaceString('memberName'); + expect({ + memberName: null + }).not.toHaveWhitespaceString('memberName'); + }); + }); + }); +}); + +describe('toHaveWholeNumber', function() { + describeToHaveX('toHaveWholeNumber', function() { + describe('when subject IS a number with no positive decimal places', function() { + it('should confirm', function() { + expect({ + memberName: 1 + }).toHaveWholeNumber('memberName'); + expect({ + memberName: 0 + }).toHaveWholeNumber('memberName'); + expect({ + memberName: 0.0 + }).toHaveWholeNumber('memberName'); + }); + }); + describe('when subject is NOT a number with no positive decimal places', function() { + it('should deny', function() { + expect({ + memberName: NaN + }).not.toHaveWholeNumber('memberName'); + expect({ + memberName: 1.1 + }).not.toHaveWholeNumber('memberName'); + expect({ + memberName: 0.1 + }).not.toHaveWholeNumber('memberName'); + }); + }); + }); +}); + +describe('toImplement', function() { + describe('when invoked', function() { + describe('when subject IS an Object containing all of the supplied members', function() { + it('should confirm', function() { + expect({ + a: 1, + b: 2 + }).toImplement({ + a: 1, + b: 2 + }); + expect({ + a: 1, + b: 2 + }).toImplement({ + a: 1 + }); + }); + }); + describe('when subject is NOT an Object containing all of the supplied members', function() { + it('should deny', function() { + expect({ + a: 1 + }).not.toImplement({ + c: 3 + }); + expect(null).not.toImplement({ + a: 1 + }); + }); + }); + }); +}); + +describe('toStartWith', function() { + describe('when invoked', function() { + describe('when subject is NOT an undefined or empty string', function() { + describe('when subject is a string whose leading characters match the expected string', function() { + it('should confirm', function() { + expect('jamie').toStartWith('jam'); + }); + }); + describe('when subject is a string whose leading characters DO NOT match the expected string', function() { + it('should deny', function() { + expect(' jamie').not.toStartWith('jam'); + expect('Jamie').not.toStartWith('jam'); + }); + }); + }); + describe('when subject IS an undefined or empty string', function() { + it('should deny', function() { + expect('').not.toStartWith(''); + expect(_undefined).not.toStartWith(''); + expect(_undefined).not.toStartWith('undefined'); + expect('undefined').not.toStartWith(_undefined); + }); + }); + }); +}); + + +describe('toThrowAnyError', function() { + describe('when supplied a function', function() { + describe('when function errors when invoked', function() { + beforeEach(function() { + this.throwError = function() { + throw new Error('wut?'); + }; + this.badReference = function() { + return badReference.someValue; + }; + }); + it('should confirm', function() { + expect(this.throwError).toThrowAnyError(); + expect(this.badReference).toThrowAnyError(); + }); + }); + describe('when function does NOT error when invoked', function() { + beforeEach(function() { + this.noErrors = function() {}; + }); + it('should deny', function() { + expect(this.noErrors).not.toThrowAnyError(); + }); + }); + }); +}); + + +describe('toThrowErrorOfType', function() { + describe('when supplied a function', function() { + describe('when function errors when invoked', function() { + beforeEach(function() { + this.throwError = function() { + throw new Error('wut?'); + }; + this.badReference = function() { + return badReference.someValue; + }; + }); + describe('when the error is of the expected type', function() { + it('should confirm', function() { + expect(this.throwError).toThrowErrorOfType('Error'); + expect(this.badReference).toThrowErrorOfType('ReferenceError'); + }); + }); + describe('when the error is NOT of the expected type', function() { + it('should confirm', function() { + expect(this.throwError).not.toThrowErrorOfType('ReferenceError'); + expect(this.badReference).not.toThrowErrorOfType('Error'); + }); + }); + }); + }); +}); diff --git a/jasmine-matchers/jamiemason-jasmine-matchers.d.ts b/jasmine-matchers/jamiemason-jasmine-matchers.d.ts index 6a2b8a49a..e293496c6 100644 --- a/jasmine-matchers/jamiemason-jasmine-matchers.d.ts +++ b/jasmine-matchers/jamiemason-jasmine-matchers.d.ts @@ -25,84 +25,84 @@ declare module jasmine { interface Matchers { // These functions are written in the order defined in the src directory of jasmine-matchers // The type system is used smartly whenever it can provide value (by looking at the code of every matcher) - toBeAfter(otherDate: Date, actualDate: Date): boolean; // - toBeArray(actualArray: any[]): boolean; // - toBeArrayOfBooleans(actualArray: any[]): boolean; // - toBeArrayOfNumbers(actualArray: any[]): boolean; - toBeArrayOfObjects(actualArray: any[]): boolean; - toBeArrayOfSize(size: number, actualArray: any[]): boolean; - toBeArrayOfStrings(actualArray: any[]): boolean; - toBeBefore(otherDate: Date, actualDate: Date): boolean; // - toBeBoolean(actual: boolean): boolean; - toBeCalculable(actual: number): boolean; - toBeDate(actual: Date): boolean; - toBeEmptyArray(actualArray: any[]): boolean; - toBeEmptyObject(actual: {}): boolean; - toBeEmptyString(actual: string): boolean; - toBeEvenNumber(actual: number): boolean; - toBeFalse(actual: boolean): boolean; - toBeFunction(actual: any): boolean; - toBeHtmlString(actual: string): boolean; - toBeIso8601(actual: string): boolean; - toBeJsonString(actual: string): boolean; - toBeLongerThan(actual: string): boolean; - toBeNonEmptyArray(actualArray: any[]): boolean; - toBeNonEmptyObject(actual: {}): boolean; - toBeNonEmptyString(actual: string): boolean; - toBeNumber(actual: number): boolean; - toBeObject(actual: {}): boolean; - toBeOddNumber(actual: number): boolean; - toBeSameLengthAs(other: string, actual: string): boolean; - toBeShorterThan(other: string, actual: string): boolean; - toBeString(actual: string): boolean; - toBeTrue(actual: boolean): boolean; - toBeWhitespace(actual: string): boolean; - toBeWholeNumber(actual: number): boolean; - toBeWithinRange(floor: number, ceiling: number, actual: number): boolean; + toBeAfter(otherDate: Date): boolean; // + toBeArray(): boolean; // + toBeArrayOfBooleans(): boolean; // + toBeArrayOfNumbers(): boolean; + toBeArrayOfObjects(): boolean; + toBeArrayOfSize(size: number): boolean; + toBeArrayOfStrings(): boolean; + toBeBefore(otherDate: Date): boolean; // + toBeBoolean(): boolean; + toBeCalculable(): boolean; + toBeDate(): boolean; + toBeEmptyArray(): boolean; + toBeEmptyObject(): boolean; + toBeEmptyString(): boolean; + toBeEvenNumber(): boolean; + toBeFalse(): boolean; + toBeFunction(): boolean; + toBeHtmlString(): boolean; + toBeIso8601(): boolean; + toBeJsonString(): boolean; + toBeLongerThan(other: string): boolean; + toBeNonEmptyArray(): boolean; + toBeNonEmptyObject(): boolean; + toBeNonEmptyString(): boolean; + toBeNumber(): boolean; + toBeObject(): boolean; + toBeOddNumber(): boolean; + toBeSameLengthAs(other: string): boolean; + toBeShorterThan(other: string): boolean; + toBeString(): boolean; + toBeTrue(): boolean; + toBeWhitespace(): boolean; + toBeWholeNumber(): boolean; + toBeWithinRange(floor: number, ceiling: number): boolean; - toEndWith(subString: string, actual: string): boolean; + toEndWith(subString: string): boolean; - toHaveArray(key: string, actual: {}): boolean; - toHaveArrayOfBooleans(key: string, actual: {}): boolean; - toHaveArrayOfNumbers(key: string, actual: {}): boolean; - toHaveArrayOfObjects(key: string, actual: {}): boolean; - toHaveArrayOfSize(key: string, size: number, actual: {}): boolean; - toHaveArrayOfStrings(key: string, actual: {}): boolean; - toHaveBoolean(key: string, actual: {}): boolean; - toHaveCalculable(key: string, actual: {}): boolean; - toHaveDate(key: string, actual: {}): boolean; - toHaveDateAfter(key: string, actual: {}): boolean; - toHaveDateBefore(key: string, actual: {}): boolean; - toHaveEmptyArray(key: string, actual: {}): boolean; - toHaveEmptyObject(key: string, actual: {}): boolean; - toHaveEmptyString(key: string, actual: {}): boolean; - toHaveEvenNumber(key: string, actual: {}): boolean; - toHaveFalse(key: string, actual: {}): boolean; - toHaveHtmlString(key: string, actual: {}): boolean; - toHaveIso8601(key: string, actual: {}): boolean; - toHaveJsonString(key: string, actual: {}): boolean; - toHaveMember(key: string, actual: {}): boolean; - toHaveMethod(key: string, actual: {}): boolean; - toHaveNonEmptyArray(key: string, actual: {}): boolean; - toHaveNonEmptyObject(key: string, actual: {}): boolean; - toHaveNonEmptyString(key: string, actual: {}): boolean; - toHaveNumber(key: string, actual: {}): boolean; - toHaveNumberWithinRange(key: string, actual: {}): boolean; - toHaveObject(key: string, actual: {}): boolean; - toHaveOddNumber(key: string, actual: {}): boolean; - toHaveString(key: string, actual: {}): boolean; - toHaveStringLongerThan(key: string, actual: {}): boolean; - toHaveStringSameLengthAs(key: string, actual: {}): boolean; - toHaveStringShorterThan(key: string, actual: {}): boolean; - toHaveTrue(key: string, actual: {}): boolean; - toHaveWhitespaceString(key: string, actual: {}): boolean; - toHaveWholeNumber(key: string, actual: {}): boolean; + toHaveArray(key: string): boolean; + toHaveArrayOfBooleans(key: string): boolean; + toHaveArrayOfNumbers(key: string): boolean; + toHaveArrayOfObjects(key: string): boolean; + toHaveArrayOfSize(key: string, size?: number): boolean; + toHaveArrayOfStrings(key: string): boolean; + toHaveBoolean(key: string): boolean; + toHaveCalculable(key: string): boolean; + toHaveDate(key: string): boolean; + toHaveDateAfter(key: string, otherDate: Date): boolean; + toHaveDateBefore(key: string, otherDate: Date): boolean; + toHaveEmptyArray(key: string): boolean; + toHaveEmptyObject(key: string): boolean; + toHaveEmptyString(key: string): boolean; + toHaveEvenNumber(key: string): boolean; + toHaveFalse(key: string): boolean; + toHaveHtmlString(key: string): boolean; + toHaveIso8601(key: string): boolean; + toHaveJsonString(key: string): boolean; + toHaveMember(key: string): boolean; + toHaveMethod(key: string): boolean; + toHaveNonEmptyArray(key: string): boolean; + toHaveNonEmptyObject(key: string): boolean; + toHaveNonEmptyString(key: string): boolean; + toHaveNumber(key: string): boolean; + toHaveNumberWithinRange(key: string, floor: number, ceiling: number): boolean; + toHaveObject(key: string): boolean; + toHaveOddNumber(key: string): boolean; + toHaveString(key: string): boolean; + toHaveStringLongerThan(key: string, other: string): boolean; + toHaveStringSameLengthAs(key: string, other: string): boolean; + toHaveStringShorterThan(key: string, other: string): boolean; + toHaveTrue(key: string): boolean; + toHaveWhitespaceString(key: string): boolean; + toHaveWholeNumber(key: string): boolean; - toImplement(api: {}, actual: {}): boolean; + toImplement(api: {}): boolean; - toStartWith(subString: string, actual: string): boolean; + toStartWith(subString: string): boolean; - toThrowAnyError(throwerFn: () => any): boolean; - toThrowErrorOfType(type: string, throwerFn: () => any): boolean; + toThrowAnyError(): boolean; + toThrowErrorOfType(type: string): boolean; } } From 24a38ab5f1742137c03f565198be52734c9a680e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Ewerl=C3=B6f?= Date: Mon, 23 Nov 2015 19:36:28 +0100 Subject: [PATCH 05/10] defined the type for mockDate and _undefined --- jasmine-matchers/jamiemason-jasmine-matchers-tests.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jasmine-matchers/jamiemason-jasmine-matchers-tests.ts b/jasmine-matchers/jamiemason-jasmine-matchers-tests.ts index ade9e8cb5..20f2e9a7e 100644 --- a/jasmine-matchers/jamiemason-jasmine-matchers-tests.ts +++ b/jasmine-matchers/jamiemason-jasmine-matchers-tests.ts @@ -9,7 +9,7 @@ declare var describeToHaveArrayX: (arr: string, descriptor: () => void) => void; declare var describeToHaveX: (arr: string, descriptor: () => void) => void; declare var describeToHaveBooleanX: (arr: string, descriptor: () => void) => void; declare var badReference: {someValue: any}; -var _undefined; +var _undefined: any = undefined; describe('toBeAfter', function() { describe('when invoked', function() { @@ -993,7 +993,7 @@ describe('toHaveCalculable', function() { }); describe('toHaveDate', function() { - var mockDate; + var mockDate: any; beforeEach(function() { mockDate = { any: new Date(), @@ -1020,7 +1020,7 @@ describe('toHaveDate', function() { }); describe('toHaveDateAfter', function() { - var mockDate; + var mockDate: any; beforeEach(function() { mockDate = { any: new Date(), @@ -1056,7 +1056,7 @@ describe('toHaveDateAfter', function() { }); describeToHaveX('toHaveDateBefore', function() { - var mockDate; + var mockDate: any; beforeEach(function() { mockDate = { any: new Date(), From 28b50e6021a9bd3ea8a0240bc4a1ec23e5be0123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Ewerl=C3=B6f?= Date: Mon, 23 Nov 2015 19:41:08 +0100 Subject: [PATCH 06/10] reformated the tests to tab=2 --- .../jamiemason-jasmine-matchers-tests.ts | 3270 ++++++++--------- 1 file changed, 1635 insertions(+), 1635 deletions(-) diff --git a/jasmine-matchers/jamiemason-jasmine-matchers-tests.ts b/jasmine-matchers/jamiemason-jasmine-matchers-tests.ts index 20f2e9a7e..cd4914339 100644 --- a/jasmine-matchers/jamiemason-jasmine-matchers-tests.ts +++ b/jasmine-matchers/jamiemason-jasmine-matchers-tests.ts @@ -8,1987 +8,1987 @@ declare var describeToBeArrayOfX: (arr: string, descriptor: {}) => void; declare var describeToHaveArrayX: (arr: string, descriptor: () => void) => void; declare var describeToHaveX: (arr: string, descriptor: () => void) => void; declare var describeToHaveBooleanX: (arr: string, descriptor: () => void) => void; -declare var badReference: {someValue: any}; +declare var badReference: { someValue: any }; var _undefined: any = undefined; describe('toBeAfter', function() { - describe('when invoked', function() { - describe('when value is a Date', function() { - describe('when date occurs after another', function() { - it('should confirm', function() { - expect(new Date('2013-01-01T01:00:00.000Z')).toBeAfter(new Date('2013-01-01T00:00:00.000Z')); - }); - }); - describe('when date does NOT occur after another', function() { - it('should deny', function() { - expect(new Date('2013-01-01T00:00:00.000Z')).not.toBeAfter(new Date('2013-01-01T01:00:00.000Z')); - }); - }); + describe('when invoked', function() { + describe('when value is a Date', function() { + describe('when date occurs after another', function() { + it('should confirm', function() { + expect(new Date('2013-01-01T01:00:00.000Z')).toBeAfter(new Date('2013-01-01T00:00:00.000Z')); }); + }); + describe('when date does NOT occur after another', function() { + it('should deny', function() { + expect(new Date('2013-01-01T00:00:00.000Z')).not.toBeAfter(new Date('2013-01-01T01:00:00.000Z')); + }); + }); }); + }); }); describe('toBeArray', function() { - describe('when invoked', function() { - describe('when subject is a true Array', function() { - it('should confirm', function() { - expect([]).toBeArray(); - expect(new Array()).toBeArray(); - }); - }); - describeWhenNotArray('toBeArray'); + describe('when invoked', function() { + describe('when subject is a true Array', function() { + it('should confirm', function() { + expect([]).toBeArray(); + expect(new Array()).toBeArray(); + }); }); + describeWhenNotArray('toBeArray'); + }); }); describe('toBeArrayOfBooleans', function() { - describeToBeArrayOfX('toBeArrayOfBooleans', { - type: 'Boolean', - whenValid: function() { - expect([true]).toBeArrayOfBooleans(); - expect([new Boolean(true)]).toBeArrayOfBooleans(); - expect([new Boolean(false)]).toBeArrayOfBooleans(); - expect([false, true]).toBeArrayOfBooleans(); - }, - whenInvalid: function() { - expect([null]).not.toBeArrayOfBooleans(); - }, - whenMixed: function() { - expect([null, false]).not.toBeArrayOfBooleans(); - expect([null, true]).not.toBeArrayOfBooleans(); - } - }); + describeToBeArrayOfX('toBeArrayOfBooleans', { + type: 'Boolean', + whenValid: function() { + expect([true]).toBeArrayOfBooleans(); + expect([new Boolean(true)]).toBeArrayOfBooleans(); + expect([new Boolean(false)]).toBeArrayOfBooleans(); + expect([false, true]).toBeArrayOfBooleans(); + }, + whenInvalid: function() { + expect([null]).not.toBeArrayOfBooleans(); + }, + whenMixed: function() { + expect([null, false]).not.toBeArrayOfBooleans(); + expect([null, true]).not.toBeArrayOfBooleans(); + } + }); }); describe('toBeArrayOfNumbers', function() { - describeToBeArrayOfX('toBeArrayOfNumbers', { - type: 'Number', - whenValid: function() { - expect([1]).toBeArrayOfNumbers(); - expect([new Number(1)]).toBeArrayOfNumbers(); - expect([new Number(0)]).toBeArrayOfNumbers(); - expect([0, 1]).toBeArrayOfNumbers(); - }, - whenInvalid: function() { - expect([null]).not.toBeArrayOfNumbers(); - }, - whenMixed: function() { - expect([null, 0]).not.toBeArrayOfNumbers(); - } - }); + describeToBeArrayOfX('toBeArrayOfNumbers', { + type: 'Number', + whenValid: function() { + expect([1]).toBeArrayOfNumbers(); + expect([new Number(1)]).toBeArrayOfNumbers(); + expect([new Number(0)]).toBeArrayOfNumbers(); + expect([0, 1]).toBeArrayOfNumbers(); + }, + whenInvalid: function() { + expect([null]).not.toBeArrayOfNumbers(); + }, + whenMixed: function() { + expect([null, 0]).not.toBeArrayOfNumbers(); + } + }); }); describe('toBeArrayOfObjects', function() { - describeToBeArrayOfX('toBeArrayOfObjects', { - type: 'Object', - whenValid: function() { - expect([{}, {}]).toBeArrayOfObjects(); - }, - whenInvalid: function() { - expect([null]).not.toBeArrayOfObjects(); - expect(['Object']).not.toBeArrayOfObjects(); - expect(['[object Object]']).not.toBeArrayOfObjects(); - }, - whenMixed: function() { - expect([null, {}]).not.toBeArrayOfObjects(); - } - }); + describeToBeArrayOfX('toBeArrayOfObjects', { + type: 'Object', + whenValid: function() { + expect([{}, {}]).toBeArrayOfObjects(); + }, + whenInvalid: function() { + expect([null]).not.toBeArrayOfObjects(); + expect(['Object']).not.toBeArrayOfObjects(); + expect(['[object Object]']).not.toBeArrayOfObjects(); + }, + whenMixed: function() { + expect([null, {}]).not.toBeArrayOfObjects(); + } + }); }); describe('toBeArrayOfSize', function() { - describe('when invoked', function() { - describe('when subject is a true Array', function() { - describe('when subject has the expected number of members', function() { - it('should confirm', function() { - expect([]).toBeArrayOfSize(0); - expect([null]).toBeArrayOfSize(1); - expect([false, false]).toBeArrayOfSize(2); - expect([_undefined, _undefined]).toBeArrayOfSize(2); - }); - }); - describe('when subject has an unexpected number of members', function() { - it('should deny', function() { - expect([]).not.toBeArrayOfSize(1); - expect([null]).not.toBeArrayOfSize(0); - expect([true, true]).not.toBeArrayOfSize(1); - }); - }); + describe('when invoked', function() { + describe('when subject is a true Array', function() { + describe('when subject has the expected number of members', function() { + it('should confirm', function() { + expect([]).toBeArrayOfSize(0); + expect([null]).toBeArrayOfSize(1); + expect([false, false]).toBeArrayOfSize(2); + expect([_undefined, _undefined]).toBeArrayOfSize(2); }); - describeWhenNotArray('toBeArrayOfSize'); + }); + describe('when subject has an unexpected number of members', function() { + it('should deny', function() { + expect([]).not.toBeArrayOfSize(1); + expect([null]).not.toBeArrayOfSize(0); + expect([true, true]).not.toBeArrayOfSize(1); + }); + }); }); + describeWhenNotArray('toBeArrayOfSize'); + }); }); describe('toBeArrayOfStrings', function() { - describeToBeArrayOfX('toBeArrayOfStrings', { - type: 'String', - whenValid: function() { - expect(['truthy']).toBeArrayOfStrings(); - expect([new String('truthy')]).toBeArrayOfStrings(); - expect([new String('')]).toBeArrayOfStrings(); - expect(['', 'truthy']).toBeArrayOfStrings(); - }, - whenInvalid: function() { - expect([null]).not.toBeArrayOfStrings(); - }, - whenMixed: function() { - expect([null, '']).not.toBeArrayOfStrings(); - } - }); + describeToBeArrayOfX('toBeArrayOfStrings', { + type: 'String', + whenValid: function() { + expect(['truthy']).toBeArrayOfStrings(); + expect([new String('truthy')]).toBeArrayOfStrings(); + expect([new String('')]).toBeArrayOfStrings(); + expect(['', 'truthy']).toBeArrayOfStrings(); + }, + whenInvalid: function() { + expect([null]).not.toBeArrayOfStrings(); + }, + whenMixed: function() { + expect([null, '']).not.toBeArrayOfStrings(); + } + }); }); describe('toBeBefore', function() { - describe('when invoked', function() { - describe('when value is a Date', function() { - describe('when date occurs before another', function() { - it('should confirm', function() { - expect(new Date('2013-01-01T00:00:00.000Z')).toBeBefore(new Date('2013-01-01T01:00:00.000Z')); - }); - }); - describe('when date does NOT occur before another', function() { - it('should deny', function() { - expect(new Date('2013-01-01T01:00:00.000Z')).not.toBeBefore(new Date('2013-01-01T00:00:00.000Z')); - }); - }); + describe('when invoked', function() { + describe('when value is a Date', function() { + describe('when date occurs before another', function() { + it('should confirm', function() { + expect(new Date('2013-01-01T00:00:00.000Z')).toBeBefore(new Date('2013-01-01T01:00:00.000Z')); }); + }); + describe('when date does NOT occur before another', function() { + it('should deny', function() { + expect(new Date('2013-01-01T01:00:00.000Z')).not.toBeBefore(new Date('2013-01-01T00:00:00.000Z')); + }); + }); }); + }); }); describe('toBeBoolean', function() { - describe('when invoked', function() { - describe('when subject not only truthy or falsy, but a boolean', function() { - it('should confirm', function() { - expect(true).toBeBoolean(); - expect(false).toBeBoolean(); - expect(new Boolean(true)).toBeBoolean(); - expect(new Boolean(false)).toBeBoolean(); - }); - }); - describe('when subject is truthy or falsy', function() { - it('should deny', function() { - expect(1).not.toBeBoolean(); - expect(0).not.toBeBoolean(); - }); - }); + describe('when invoked', function() { + describe('when subject not only truthy or falsy, but a boolean', function() { + it('should confirm', function() { + expect(true).toBeBoolean(); + expect(false).toBeBoolean(); + expect(new Boolean(true)).toBeBoolean(); + expect(new Boolean(false)).toBeBoolean(); + }); }); + describe('when subject is truthy or falsy', function() { + it('should deny', function() { + expect(1).not.toBeBoolean(); + expect(0).not.toBeBoolean(); + }); + }); + }); }); describe('toBeCalculable', function() { - describe('when invoked', function() { - describe('when subject CAN be coerced to be used in mathematical operations', function() { - it('should confirm', function() { - expect('1').toBeCalculable(); - expect('').toBeCalculable(); - expect(null).toBeCalculable(); - }); - }); - describe('when subject can NOT be coerced by JavaScript to be used in mathematical operations', function() { - it('should deny', function() { - expect({}).not.toBeCalculable(); - expect(NaN).not.toBeCalculable(); - }); - }); + describe('when invoked', function() { + describe('when subject CAN be coerced to be used in mathematical operations', function() { + it('should confirm', function() { + expect('1').toBeCalculable(); + expect('').toBeCalculable(); + expect(null).toBeCalculable(); + }); }); + describe('when subject can NOT be coerced by JavaScript to be used in mathematical operations', function() { + it('should deny', function() { + expect({}).not.toBeCalculable(); + expect(NaN).not.toBeCalculable(); + }); + }); + }); }); describe('toBeDate', function() { - describe('when invoked', function() { - describe('when value is an instance of Date', function() { - it('should confirm', function() { - expect(new Date()).toBeDate(); - }); - }); - describe('when value is NOT an instance of Date', function() { - it('should deny', function() { - expect(null).not.toBeDate(); - }); - }); + describe('when invoked', function() { + describe('when value is an instance of Date', function() { + it('should confirm', function() { + expect(new Date()).toBeDate(); + }); }); + describe('when value is NOT an instance of Date', function() { + it('should deny', function() { + expect(null).not.toBeDate(); + }); + }); + }); }); describe('toBeEmptyArray', function() { - describe('when invoked', function() { - describe('when subject is a true Array', function() { - describe('when subject has members', function() { - it('should confirm', function() { - expect([]).toBeEmptyArray(); - }); - }); - describe('when subject has no members', function() { - it('should deny', function() { - expect([null]).not.toBeEmptyArray(); - expect(['']).not.toBeEmptyArray(); - expect([1]).not.toBeEmptyArray(); - expect([true]).not.toBeEmptyArray(); - expect([false]).not.toBeEmptyArray(); - }); - }); + describe('when invoked', function() { + describe('when subject is a true Array', function() { + describe('when subject has members', function() { + it('should confirm', function() { + expect([]).toBeEmptyArray(); }); - describeWhenNotArray('toBeEmptyArray'); + }); + describe('when subject has no members', function() { + it('should deny', function() { + expect([null]).not.toBeEmptyArray(); + expect(['']).not.toBeEmptyArray(); + expect([1]).not.toBeEmptyArray(); + expect([true]).not.toBeEmptyArray(); + expect([false]).not.toBeEmptyArray(); + }); + }); }); + describeWhenNotArray('toBeEmptyArray'); + }); }); describe('toBeEmptyObject', function() { - beforeEach(function() { - this.Foo = function() {}; + beforeEach(function() { + this.Foo = function() { }; + }); + describe('when invoked', function() { + describe('when subject IS an Object with no instance members', function() { + beforeEach(function() { + this.Foo.prototype = { + b: 2 + }; + }); + it('should confirm', function() { + expect(new this.Foo()).toBeEmptyObject(); + expect({}).toBeEmptyObject(); + }); }); - describe('when invoked', function() { - describe('when subject IS an Object with no instance members', function() { - beforeEach(function() { - this.Foo.prototype = { - b: 2 - }; - }); - it('should confirm', function() { - expect(new this.Foo()).toBeEmptyObject(); - expect({}).toBeEmptyObject(); - }); - }); - describe('when subject is NOT an Object with no instance members', function() { - it('should deny', function() { - expect({ - a: 1 - }).not.toBeEmptyObject(); - expect(null).not.toBeNonEmptyObject(); - }); - }); + describe('when subject is NOT an Object with no instance members', function() { + it('should deny', function() { + expect({ + a: 1 + }).not.toBeEmptyObject(); + expect(null).not.toBeNonEmptyObject(); + }); }); + }); }); describe('toBeEmptyString', function() { - describe('when invoked', function() { - describe('when subject IS a string with no characters', function() { - it('should confirm', function() { - expect('').toBeEmptyString(); - }); - }); - describe('when subject is NOT a string with no characters', function() { - it('should deny', function() { - expect(' ').not.toBeEmptyString(); - }); - }); + describe('when invoked', function() { + describe('when subject IS a string with no characters', function() { + it('should confirm', function() { + expect('').toBeEmptyString(); + }); }); + describe('when subject is NOT a string with no characters', function() { + it('should deny', function() { + expect(' ').not.toBeEmptyString(); + }); + }); + }); }); describe('toBeEvenNumber', function() { - describe('when invoked', function() { - describe('when subject IS an even number', function() { - it('should confirm', function() { - expect(2).toBeEvenNumber(); - }); - }); - describe('when subject is NOT an even number', function() { - it('should deny', function() { - expect(1).not.toBeEvenNumber(); - expect(NaN).not.toBeEvenNumber(); - }); - }); + describe('when invoked', function() { + describe('when subject IS an even number', function() { + it('should confirm', function() { + expect(2).toBeEvenNumber(); + }); }); + describe('when subject is NOT an even number', function() { + it('should deny', function() { + expect(1).not.toBeEvenNumber(); + expect(NaN).not.toBeEvenNumber(); + }); + }); + }); }); describe('toBeFalse', function() { - describe('when invoked', function() { - describe('when subject is not only falsy, but a boolean false', function() { - it('should confirm', function() { - expect(false).toBeFalse(); - expect(new Boolean(false)).toBeFalse(); - }); - }); - describe('when subject is falsy', function() { - it('should deny', function() { - expect(1).not.toBeFalse(); - }); - }); + describe('when invoked', function() { + describe('when subject is not only falsy, but a boolean false', function() { + it('should confirm', function() { + expect(false).toBeFalse(); + expect(new Boolean(false)).toBeFalse(); + }); }); + describe('when subject is falsy', function() { + it('should deny', function() { + expect(1).not.toBeFalse(); + }); + }); + }); }); describe('toBeFunction', function() { - describe('when invoked', function() { - describe('when subject IS a function', function() { - it('should confirm', function() { - expect(function() {}).toBeFunction(); - }); - }); - describe('when subject is NOT a function', function() { - it('should deny', function() { - expect(/regexp/).not.toBeFunction(); - }); - }); + describe('when invoked', function() { + describe('when subject IS a function', function() { + it('should confirm', function() { + expect(function() { }).toBeFunction(); + }); }); + describe('when subject is NOT a function', function() { + it('should deny', function() { + expect(/regexp/).not.toBeFunction(); + }); + }); + }); }); describe('toBeHtmlString', function() { - describe('when invoked', function() { - describe('when subject IS a string of HTML markup', function() { - beforeEach(function() { - this.ngMultiLine = ''; - this.ngMultiLine += ''; - this.ngMultiLine += '\n'; - this.ngMultiLine += ' Watch with Google TV'; - this.ngMultiLine += '\n'; - this.ngMultiLine += ''; - this.ngMultiLine += '\n'; - }); - it('should confirm', function() { - expect('text').toBeHtmlString(); - expect('baz').toBeHtmlString(); - expect('
    ').toBeHtmlString(); - expect('
  • ').toBeHtmlString(); - expect(this.ngMultiLine).toBeHtmlString(); - }); - }); - describe('when subject is NOT a string of HTML markup', function() { - it('should deny', function() { - expect('div').not.toBeHtmlString(); - expect(null).not.toBeHtmlString(); - }); - }); + describe('when invoked', function() { + describe('when subject IS a string of HTML markup', function() { + beforeEach(function() { + this.ngMultiLine = ''; + this.ngMultiLine += ''; + this.ngMultiLine += '\n'; + this.ngMultiLine += ' Watch with Google TV'; + this.ngMultiLine += '\n'; + this.ngMultiLine += ''; + this.ngMultiLine += '\n'; + }); + it('should confirm', function() { + expect('text').toBeHtmlString(); + expect('baz').toBeHtmlString(); + expect('
    ').toBeHtmlString(); + expect('
  • ').toBeHtmlString(); + expect(this.ngMultiLine).toBeHtmlString(); + }); }); + describe('when subject is NOT a string of HTML markup', function() { + it('should deny', function() { + expect('div').not.toBeHtmlString(); + expect(null).not.toBeHtmlString(); + }); + }); + }); }); describe('toBeIso8601', function() { - describe('when invoked', function() { - describe('when value is a Date String conforming to the ISO 8601 standard', function() { - describe('when specified date is valid', function() { - it('should confirm', function() { - expect('2013-07-08T07:29:15.863Z').toBeIso8601(); - expect('2013-07-08T07:29:15.863').toBeIso8601(); - expect('2013-07-08T07:29:15').toBeIso8601(); - expect('2013-07-08T07:29').toBeIso8601(); - expect('2013-07-08').toBeIso8601(); - }); - }); - describe('when specified date is NOT valid', function() { - it('should deny', function() { - expect('2013-99-12T00:00:00.000Z').not.toBeIso8601(); - expect('2013-12-99T00:00:00.000Z').not.toBeIso8601(); - expect('2013-01-01T99:00:00.000Z').not.toBeIso8601(); - expect('2013-01-01T99:99:00.000Z').not.toBeIso8601(); - expect('2013-01-01T00:00:99.000Z').not.toBeIso8601(); - }); - }); + describe('when invoked', function() { + describe('when value is a Date String conforming to the ISO 8601 standard', function() { + describe('when specified date is valid', function() { + it('should confirm', function() { + expect('2013-07-08T07:29:15.863Z').toBeIso8601(); + expect('2013-07-08T07:29:15.863').toBeIso8601(); + expect('2013-07-08T07:29:15').toBeIso8601(); + expect('2013-07-08T07:29').toBeIso8601(); + expect('2013-07-08').toBeIso8601(); }); - describe('when value is a String NOT conforming to the ISO 8601 standard', function() { - it('should deny', function() { - expect('2013-07-08T07:29:15.').not.toBeIso8601(); - expect('2013-07-08T07:29:').not.toBeIso8601(); - expect('2013-07-08T07:2').not.toBeIso8601(); - expect('2013-07-08T07:').not.toBeIso8601(); - expect('2013-07-08T07').not.toBeIso8601(); - expect('2013-07-08T').not.toBeIso8601(); - expect('2013-07-0').not.toBeIso8601(); - expect('2013-07-').not.toBeIso8601(); - expect('2013-07').not.toBeIso8601(); - expect('2013-0').not.toBeIso8601(); - expect('2013-').not.toBeIso8601(); - expect('2013').not.toBeIso8601(); - expect('201').not.toBeIso8601(); - expect('20').not.toBeIso8601(); - expect('2').not.toBeIso8601(); - expect('').not.toBeIso8601(); - }); + }); + describe('when specified date is NOT valid', function() { + it('should deny', function() { + expect('2013-99-12T00:00:00.000Z').not.toBeIso8601(); + expect('2013-12-99T00:00:00.000Z').not.toBeIso8601(); + expect('2013-01-01T99:00:00.000Z').not.toBeIso8601(); + expect('2013-01-01T99:99:00.000Z').not.toBeIso8601(); + expect('2013-01-01T00:00:99.000Z').not.toBeIso8601(); }); + }); }); + describe('when value is a String NOT conforming to the ISO 8601 standard', function() { + it('should deny', function() { + expect('2013-07-08T07:29:15.').not.toBeIso8601(); + expect('2013-07-08T07:29:').not.toBeIso8601(); + expect('2013-07-08T07:2').not.toBeIso8601(); + expect('2013-07-08T07:').not.toBeIso8601(); + expect('2013-07-08T07').not.toBeIso8601(); + expect('2013-07-08T').not.toBeIso8601(); + expect('2013-07-0').not.toBeIso8601(); + expect('2013-07-').not.toBeIso8601(); + expect('2013-07').not.toBeIso8601(); + expect('2013-0').not.toBeIso8601(); + expect('2013-').not.toBeIso8601(); + expect('2013').not.toBeIso8601(); + expect('201').not.toBeIso8601(); + expect('20').not.toBeIso8601(); + expect('2').not.toBeIso8601(); + expect('').not.toBeIso8601(); + }); + }); + }); }); var _undefined; describe('toBeJsonString', function() { - describe('when invoked', function() { - describe('when subject IS a string of parseable JSON', function() { - it('should confirm', function() { - expect('{}').toBeJsonString(); - expect('[]').toBeJsonString(); - expect('[1]').toBeJsonString(); - }); - }); - describe('when subject is NOT a string of parseable JSON', function() { - it('should deny', function() { - expect('[1,]').not.toBeJsonString(); - expect('<>').not.toBeJsonString(); - expect(null).not.toBeJsonString(); - expect('').not.toBeJsonString(); - expect(_undefined).not.toBeJsonString(); - }); - }); + describe('when invoked', function() { + describe('when subject IS a string of parseable JSON', function() { + it('should confirm', function() { + expect('{}').toBeJsonString(); + expect('[]').toBeJsonString(); + expect('[1]').toBeJsonString(); + }); }); + describe('when subject is NOT a string of parseable JSON', function() { + it('should deny', function() { + expect('[1,]').not.toBeJsonString(); + expect('<>').not.toBeJsonString(); + expect(null).not.toBeJsonString(); + expect('').not.toBeJsonString(); + expect(_undefined).not.toBeJsonString(); + }); + }); + }); }); describe('toBeLongerThan', function() { - describe('when invoked', function() { - describe('when the subject and comparison ARE both strings', function() { - describe('when the subject IS longer than the comparision string', function() { - it('should confirm', function() { - expect('abc').toBeLongerThan('ab'); - expect('a').toBeLongerThan(''); - }); - }); - describe('when the subject is NOT longer than the comparision string', function() { - it('should deny', function() { - expect('ab').not.toBeLongerThan('abc'); - expect('').not.toBeLongerThan('a'); - }); - }); + describe('when invoked', function() { + describe('when the subject and comparison ARE both strings', function() { + describe('when the subject IS longer than the comparision string', function() { + it('should confirm', function() { + expect('abc').toBeLongerThan('ab'); + expect('a').toBeLongerThan(''); }); - describe('when the subject and comparison are NOT both strings', function() { - it('should deny (we are asserting the relative lengths of two strings)', function() { - expect('truthy').not.toBeLongerThan(_undefined); - expect(_undefined).not.toBeLongerThan('truthy'); - expect('').not.toBeLongerThan(_undefined); - expect(_undefined).not.toBeLongerThan(''); - }); + }); + describe('when the subject is NOT longer than the comparision string', function() { + it('should deny', function() { + expect('ab').not.toBeLongerThan('abc'); + expect('').not.toBeLongerThan('a'); }); + }); }); + describe('when the subject and comparison are NOT both strings', function() { + it('should deny (we are asserting the relative lengths of two strings)', function() { + expect('truthy').not.toBeLongerThan(_undefined); + expect(_undefined).not.toBeLongerThan('truthy'); + expect('').not.toBeLongerThan(_undefined); + expect(_undefined).not.toBeLongerThan(''); + }); + }); + }); }); describe('toBeNonEmptyArray', function() { - describe('when invoked', function() { - describe('when subject is a true Array', function() { - describe('when subject has members', function() { - it('should confirm', function() { - expect([null]).toBeNonEmptyArray(); - expect([_undefined]).toBeNonEmptyArray(); - expect(['']).toBeNonEmptyArray(); - }); - }); - describe('when subject has no members', function() { - it('should deny', function() { - expect([]).not.toBeNonEmptyArray(); - }); - }); + describe('when invoked', function() { + describe('when subject is a true Array', function() { + describe('when subject has members', function() { + it('should confirm', function() { + expect([null]).toBeNonEmptyArray(); + expect([_undefined]).toBeNonEmptyArray(); + expect(['']).toBeNonEmptyArray(); }); - describeWhenNotArray('toBeNonEmptyArray'); + }); + describe('when subject has no members', function() { + it('should deny', function() { + expect([]).not.toBeNonEmptyArray(); + }); + }); }); + describeWhenNotArray('toBeNonEmptyArray'); + }); }); describe('toBeNonEmptyObject', function() { - beforeEach(function() { - this.Foo = function() {}; + beforeEach(function() { + this.Foo = function() { }; + }); + describe('when invoked', function() { + describe('when subject IS an Object with at least one instance member', function() { + it('should confirm', function() { + expect({ + a: 1 + }).toBeNonEmptyObject(); + }); }); - describe('when invoked', function() { - describe('when subject IS an Object with at least one instance member', function() { - it('should confirm', function() { - expect({ - a: 1 - }).toBeNonEmptyObject(); - }); - }); - describe('when subject is NOT an Object with at least one instance member', function() { - beforeEach(function() { - this.Foo.prototype = { - b: 2 - }; - }); - it('should deny', function() { - expect(new this.Foo()).not.toBeNonEmptyObject(); - expect({}).not.toBeNonEmptyObject(); - expect(null).not.toBeNonEmptyObject(); - }); - }); + describe('when subject is NOT an Object with at least one instance member', function() { + beforeEach(function() { + this.Foo.prototype = { + b: 2 + }; + }); + it('should deny', function() { + expect(new this.Foo()).not.toBeNonEmptyObject(); + expect({}).not.toBeNonEmptyObject(); + expect(null).not.toBeNonEmptyObject(); + }); }); + }); }); describe('toBeNonEmptyString', function() { - describe('when invoked', function() { - describe('when subject IS a string with at least one character', function() { - it('should confirm', function() { - expect(' ').toBeNonEmptyString(); - }); - }); - describe('when subject is NOT a string with at least one character', function() { - it('should deny', function() { - expect('').not.toBeNonEmptyString(); - expect(null).not.toBeNonEmptyString(); - }); - }); + describe('when invoked', function() { + describe('when subject IS a string with at least one character', function() { + it('should confirm', function() { + expect(' ').toBeNonEmptyString(); + }); }); + describe('when subject is NOT a string with at least one character', function() { + it('should deny', function() { + expect('').not.toBeNonEmptyString(); + expect(null).not.toBeNonEmptyString(); + }); + }); + }); }); describe('toBeNumber', function() { - describe('when invoked', function() { - describe('when subject IS a number', function() { - it('should confirm', function() { - expect(1).toBeNumber(); - expect(1.11).toBeNumber(); - expect(1e3).toBeNumber(); - expect(0.11).toBeNumber(); - expect(-11).toBeNumber(); - }); - }); - describe('when subject is NOT a number', function() { - it('should deny', function() { - expect('1').not.toBeNumber(); - expect(NaN).not.toBeNumber(); - }); - }); + describe('when invoked', function() { + describe('when subject IS a number', function() { + it('should confirm', function() { + expect(1).toBeNumber(); + expect(1.11).toBeNumber(); + expect(1e3).toBeNumber(); + expect(0.11).toBeNumber(); + expect(-11).toBeNumber(); + }); }); + describe('when subject is NOT a number', function() { + it('should deny', function() { + expect('1').not.toBeNumber(); + expect(NaN).not.toBeNumber(); + }); + }); + }); }); describe('toBeObject', function() { - beforeEach(function() { - this.Foo = function() {}; + beforeEach(function() { + this.Foo = function() { }; + }); + describe('when invoked', function() { + describe('when subject IS an Object', function() { + it('should confirm', function() { + expect(new Object()).toBeObject(); + expect(new this.Foo()).toBeObject(); + expect({}).toBeObject(); + }); }); - describe('when invoked', function() { - describe('when subject IS an Object', function() { - it('should confirm', function() { - expect(new Object()).toBeObject(); - expect(new this.Foo()).toBeObject(); - expect({}).toBeObject(); - }); - }); - describe('when subject is NOT an Object', function() { - it('should deny', function() { - expect(null).not.toBeObject(); - expect(123).not.toBeObject(); - expect('[object Object]').not.toBeObject(); - }); - }); + describe('when subject is NOT an Object', function() { + it('should deny', function() { + expect(null).not.toBeObject(); + expect(123).not.toBeObject(); + expect('[object Object]').not.toBeObject(); + }); }); + }); }); describe('toBeOddNumber', function() { - describe('when invoked', function() { - describe('when subject IS an odd number', function() { - it('should confirm', function() { - expect(1).toBeOddNumber(); - }); - }); - describe('when subject is NOT an odd number', function() { - it('should deny', function() { - expect(2).not.toBeOddNumber(); - expect(NaN).not.toBeOddNumber(); - }); - }); + describe('when invoked', function() { + describe('when subject IS an odd number', function() { + it('should confirm', function() { + expect(1).toBeOddNumber(); + }); }); + describe('when subject is NOT an odd number', function() { + it('should deny', function() { + expect(2).not.toBeOddNumber(); + expect(NaN).not.toBeOddNumber(); + }); + }); + }); }); var _undefined; describe('toBeSameLengthAs', function() { - describe('when invoked', function() { - describe('when the subject and comparison ARE both strings', function() { - describe('when the subject IS the same length as the comparision string', function() { - it('should confirm', function() { - expect('ab').toBeSameLengthAs('ab'); - }); - }); - describe('when the subject is NOT the same length as the comparision string', function() { - it('should deny', function() { - expect('abc').not.toBeSameLengthAs('ab'); - expect('a').not.toBeSameLengthAs(''); - expect('').not.toBeSameLengthAs('a'); - }); - }); + describe('when invoked', function() { + describe('when the subject and comparison ARE both strings', function() { + describe('when the subject IS the same length as the comparision string', function() { + it('should confirm', function() { + expect('ab').toBeSameLengthAs('ab'); }); - describe('when the subject and comparison are NOT both strings', function() { - it('should deny (we are asserting the relative lengths of two strings)', function() { - expect('truthy').not.toBeSameLengthAs(_undefined); - expect(_undefined).not.toBeSameLengthAs('truthy'); - expect('').not.toBeSameLengthAs(_undefined); - expect(_undefined).not.toBeSameLengthAs(''); - }); + }); + describe('when the subject is NOT the same length as the comparision string', function() { + it('should deny', function() { + expect('abc').not.toBeSameLengthAs('ab'); + expect('a').not.toBeSameLengthAs(''); + expect('').not.toBeSameLengthAs('a'); }); + }); }); + describe('when the subject and comparison are NOT both strings', function() { + it('should deny (we are asserting the relative lengths of two strings)', function() { + expect('truthy').not.toBeSameLengthAs(_undefined); + expect(_undefined).not.toBeSameLengthAs('truthy'); + expect('').not.toBeSameLengthAs(_undefined); + expect(_undefined).not.toBeSameLengthAs(''); + }); + }); + }); }); var _undefined; describe('toBeShorterThan', function() { - describe('when invoked', function() { - describe('when the subject and comparison ARE both strings', function() { - describe('when the subject IS shorter than the comparision string', function() { - it('should confirm', function() { - expect('ab').toBeShorterThan('abc'); - expect('').toBeShorterThan('a'); - }); - }); - describe('when the subject is NOT shorter than the comparision string', function() { - it('should deny', function() { - expect('abc').not.toBeShorterThan('ab'); - expect('a').not.toBeShorterThan(''); - }); - }); + describe('when invoked', function() { + describe('when the subject and comparison ARE both strings', function() { + describe('when the subject IS shorter than the comparision string', function() { + it('should confirm', function() { + expect('ab').toBeShorterThan('abc'); + expect('').toBeShorterThan('a'); }); - describe('when the subject and comparison are NOT both strings', function() { - it('should deny (we are asserting the relative lengths of two strings)', function() { - expect('truthy').not.toBeShorterThan(_undefined); - expect(_undefined).not.toBeShorterThan('truthy'); - expect('').not.toBeShorterThan(_undefined); - expect(_undefined).not.toBeShorterThan(''); - }); + }); + describe('when the subject is NOT shorter than the comparision string', function() { + it('should deny', function() { + expect('abc').not.toBeShorterThan('ab'); + expect('a').not.toBeShorterThan(''); }); + }); }); + describe('when the subject and comparison are NOT both strings', function() { + it('should deny (we are asserting the relative lengths of two strings)', function() { + expect('truthy').not.toBeShorterThan(_undefined); + expect(_undefined).not.toBeShorterThan('truthy'); + expect('').not.toBeShorterThan(_undefined); + expect(_undefined).not.toBeShorterThan(''); + }); + }); + }); }); describe('toBeString', function() { - describe('when invoked', function() { - describe('when subject IS a string of any length', function() { - it('should confirm', function() { - expect('').toBeString(); - expect(' ').toBeString(); - }); - }); - describe('when subject is NOT a string of any length', function() { - it('should deny', function() { - expect(null).not.toBeString(); - }); - }); + describe('when invoked', function() { + describe('when subject IS a string of any length', function() { + it('should confirm', function() { + expect('').toBeString(); + expect(' ').toBeString(); + }); }); + describe('when subject is NOT a string of any length', function() { + it('should deny', function() { + expect(null).not.toBeString(); + }); + }); + }); }); describe('toBeTrue', function() { - describe('when invoked', function() { - describe('when subject is not only truthy, but a boolean true', function() { - it('should confirm', function() { - expect(true).toBeTrue(); - expect(new Boolean(true)).toBeTrue(); - }); - }); - describe('when subject is truthy', function() { - it('should deny', function() { - expect(1).not.toBeTrue(); - }); - }); + describe('when invoked', function() { + describe('when subject is not only truthy, but a boolean true', function() { + it('should confirm', function() { + expect(true).toBeTrue(); + expect(new Boolean(true)).toBeTrue(); + }); }); + describe('when subject is truthy', function() { + it('should deny', function() { + expect(1).not.toBeTrue(); + }); + }); + }); }); describe('toBeWhitespace', function() { - describe('when invoked', function() { - describe('when subject IS a string containing only tabs, spaces, returns etc', function() { - it('should confirm', function() { - expect(' ').toBeWhitespace(); - expect('').toBeWhitespace(); - }); - }); - describe('when subject is NOT a string containing only tabs, spaces, returns etc', function() { - it('should deny', function() { - expect('has-no-whitespace').not.toBeWhitespace(); - expect('has whitespace').not.toBeWhitespace(); - expect(null).not.toBeWhitespace(); - }); - }); + describe('when invoked', function() { + describe('when subject IS a string containing only tabs, spaces, returns etc', function() { + it('should confirm', function() { + expect(' ').toBeWhitespace(); + expect('').toBeWhitespace(); + }); }); + describe('when subject is NOT a string containing only tabs, spaces, returns etc', function() { + it('should deny', function() { + expect('has-no-whitespace').not.toBeWhitespace(); + expect('has whitespace').not.toBeWhitespace(); + expect(null).not.toBeWhitespace(); + }); + }); + }); }); describe('toBeWholeNumber', function() { - describe('when invoked', function() { - describe('when subject IS a number with no positive decimal places', function() { - it('should confirm', function() { - expect(1).toBeWholeNumber(); - expect(0).toBeWholeNumber(); - expect(0.0).toBeWholeNumber(); - }); - }); - describe('when subject is NOT a number with no positive decimal places', function() { - it('should deny', function() { - expect(NaN).not.toBeWholeNumber(); - expect(1.1).not.toBeWholeNumber(); - expect(0.1).not.toBeWholeNumber(); - }); - }); + describe('when invoked', function() { + describe('when subject IS a number with no positive decimal places', function() { + it('should confirm', function() { + expect(1).toBeWholeNumber(); + expect(0).toBeWholeNumber(); + expect(0.0).toBeWholeNumber(); + }); }); + describe('when subject is NOT a number with no positive decimal places', function() { + it('should deny', function() { + expect(NaN).not.toBeWholeNumber(); + expect(1.1).not.toBeWholeNumber(); + expect(0.1).not.toBeWholeNumber(); + }); + }); + }); }); describe('toBeWithinRange', function() { - describe('when invoked', function() { - describe('when subject IS a number >= floor and <= ceiling', function() { - it('should confirm', function() { - expect(0).toBeWithinRange(0, 2); - expect(1).toBeWithinRange(0, 2); - expect(2).toBeWithinRange(0, 2); - }); - }); - describe('when subject is NOT a number >= floor and <= ceiling', function() { - it('should deny', function() { - expect(-3).not.toBeWithinRange(0, 2); - expect(-2).not.toBeWithinRange(0, 2); - expect(-1).not.toBeWithinRange(0, 2); - expect(3).not.toBeWithinRange(0, 2); - expect(NaN).not.toBeWithinRange(0, 2); - }); - }); + describe('when invoked', function() { + describe('when subject IS a number >= floor and <= ceiling', function() { + it('should confirm', function() { + expect(0).toBeWithinRange(0, 2); + expect(1).toBeWithinRange(0, 2); + expect(2).toBeWithinRange(0, 2); + }); }); + describe('when subject is NOT a number >= floor and <= ceiling', function() { + it('should deny', function() { + expect(-3).not.toBeWithinRange(0, 2); + expect(-2).not.toBeWithinRange(0, 2); + expect(-1).not.toBeWithinRange(0, 2); + expect(3).not.toBeWithinRange(0, 2); + expect(NaN).not.toBeWithinRange(0, 2); + }); + }); + }); }); var _undefined; describe('toEndWith', function() { - describe('when invoked', function() { - describe('when subject is NOT an undefined or empty string', function() { - describe('when subject is a string whose trailing characters match the expected string', function() { - it('should confirm', function() { - expect('jamie').toEndWith('mie'); - }); - }); - describe('when subject is a string whose trailing characters DO NOT match the expected string', function() { - it('should deny', function() { - expect('jamie ').not.toEndWith('mie'); - expect('jamiE').not.toEndWith('mie'); - }); - }); + describe('when invoked', function() { + describe('when subject is NOT an undefined or empty string', function() { + describe('when subject is a string whose trailing characters match the expected string', function() { + it('should confirm', function() { + expect('jamie').toEndWith('mie'); }); - describe('when subject IS an undefined or empty string', function() { - it('should deny', function() { - expect('').not.toEndWith(''); - expect(_undefined).not.toEndWith(''); - expect(_undefined).not.toEndWith('undefined'); - expect('undefined').not.toEndWith(_undefined); - }); + }); + describe('when subject is a string whose trailing characters DO NOT match the expected string', function() { + it('should deny', function() { + expect('jamie ').not.toEndWith('mie'); + expect('jamiE').not.toEndWith('mie'); }); + }); }); + describe('when subject IS an undefined or empty string', function() { + it('should deny', function() { + expect('').not.toEndWith(''); + expect(_undefined).not.toEndWith(''); + expect(_undefined).not.toEndWith('undefined'); + expect('undefined').not.toEndWith(_undefined); + }); + }); + }); }); describe('toHaveArray', function() { - describeToHaveArrayX('toHaveArray', function() { - it('should confirm', function() { - expect({ - memberName: [] - }).toHaveArray('memberName'); - expect({ - memberName: [1, 2, 3] - }).toHaveArray('memberName'); - }); + describeToHaveArrayX('toHaveArray', function() { + it('should confirm', function() { + expect({ + memberName: [] + }).toHaveArray('memberName'); + expect({ + memberName: [1, 2, 3] + }).toHaveArray('memberName'); }); + }); }); describe('toHaveArrayOfBooleans', function() { - describeToHaveArrayX('toHaveArrayOfBooleans', function() { - describe('when named Array is empty', function() { - it('should confirm', function() { - expect({ - memberName: [] - }).toHaveArrayOfBooleans('memberName'); - }); - }); - describe('when named Array has items', function() { - describe('when all items are booleans', function() { - it('should confirm', function() { - expect({ - memberName: [true] - }).toHaveArrayOfBooleans('memberName'); - expect({ - memberName: [new Boolean(true)] - }).toHaveArrayOfBooleans('memberName'); - expect({ - memberName: [new Boolean(false)] - }).toHaveArrayOfBooleans('memberName'); - expect({ - memberName: [false, true] - }).toHaveArrayOfBooleans('memberName'); - }); - }); - describe('when any item is not a boolean', function() { - it('should deny', function() { - expect({ - memberName: [null] - }).not.toHaveArrayOfBooleans('memberName'); - expect({ - memberName: [null, false] - }).not.toHaveArrayOfBooleans('memberName'); - }); - }); - }); + describeToHaveArrayX('toHaveArrayOfBooleans', function() { + describe('when named Array is empty', function() { + it('should confirm', function() { + expect({ + memberName: [] + }).toHaveArrayOfBooleans('memberName'); + }); }); + describe('when named Array has items', function() { + describe('when all items are booleans', function() { + it('should confirm', function() { + expect({ + memberName: [true] + }).toHaveArrayOfBooleans('memberName'); + expect({ + memberName: [new Boolean(true)] + }).toHaveArrayOfBooleans('memberName'); + expect({ + memberName: [new Boolean(false)] + }).toHaveArrayOfBooleans('memberName'); + expect({ + memberName: [false, true] + }).toHaveArrayOfBooleans('memberName'); + }); + }); + describe('when any item is not a boolean', function() { + it('should deny', function() { + expect({ + memberName: [null] + }).not.toHaveArrayOfBooleans('memberName'); + expect({ + memberName: [null, false] + }).not.toHaveArrayOfBooleans('memberName'); + }); + }); + }); + }); }); describe('toHaveArrayOfNumbers', function() { - describeToHaveArrayX('toHaveArrayOfNumbers', function() { - describe('when named Array is empty', function() { - it('should confirm', function() { - expect({ - memberName: [] - }).toHaveArrayOfNumbers('memberName'); - }); - }); - describe('when named Array has items', function() { - describe('when all items are numbers', function() { - it('should confirm', function() { - expect({ - memberName: [1] - }).toHaveArrayOfNumbers('memberName'); - expect({ - memberName: [new Number(1)] - }).toHaveArrayOfNumbers('memberName'); - expect({ - memberName: [new Number(0)] - }).toHaveArrayOfNumbers('memberName'); - expect({ - memberName: [0, 1] - }).toHaveArrayOfNumbers('memberName'); - }); - }); - describe('when any item is not a number', function() { - it('should deny', function() { - expect({ - memberName: [null] - }).not.toHaveArrayOfNumbers('memberName'); - expect({ - memberName: [null, 0] - }).not.toHaveArrayOfNumbers('memberName'); - }); - }); - }); + describeToHaveArrayX('toHaveArrayOfNumbers', function() { + describe('when named Array is empty', function() { + it('should confirm', function() { + expect({ + memberName: [] + }).toHaveArrayOfNumbers('memberName'); + }); }); + describe('when named Array has items', function() { + describe('when all items are numbers', function() { + it('should confirm', function() { + expect({ + memberName: [1] + }).toHaveArrayOfNumbers('memberName'); + expect({ + memberName: [new Number(1)] + }).toHaveArrayOfNumbers('memberName'); + expect({ + memberName: [new Number(0)] + }).toHaveArrayOfNumbers('memberName'); + expect({ + memberName: [0, 1] + }).toHaveArrayOfNumbers('memberName'); + }); + }); + describe('when any item is not a number', function() { + it('should deny', function() { + expect({ + memberName: [null] + }).not.toHaveArrayOfNumbers('memberName'); + expect({ + memberName: [null, 0] + }).not.toHaveArrayOfNumbers('memberName'); + }); + }); + }); + }); }); describe('toHaveArrayOfObjects', function() { - describeToHaveArrayX('toHaveArrayOfObjects', function() { - describe('when named Array is empty', function() { - it('should confirm', function() { - expect({ - memberName: [] - }).toHaveArrayOfObjects('memberName'); - }); - }); - describe('when named Array has items', function() { - describe('when all items are objects', function() { - it('should confirm', function() { - expect({ - memberName: [{}] - }).toHaveArrayOfObjects('memberName'); - expect({ - memberName: [{}, {}] - }).toHaveArrayOfObjects('memberName'); - }); - }); - describe('when any item is not an object', function() { - it('should deny', function() { - expect({ - memberName: [null] - }).not.toHaveArrayOfObjects('memberName'); - expect({ - memberName: [null, {}] - }).not.toHaveArrayOfObjects('memberName'); - }); - }); - }); + describeToHaveArrayX('toHaveArrayOfObjects', function() { + describe('when named Array is empty', function() { + it('should confirm', function() { + expect({ + memberName: [] + }).toHaveArrayOfObjects('memberName'); + }); }); + describe('when named Array has items', function() { + describe('when all items are objects', function() { + it('should confirm', function() { + expect({ + memberName: [{}] + }).toHaveArrayOfObjects('memberName'); + expect({ + memberName: [{}, {}] + }).toHaveArrayOfObjects('memberName'); + }); + }); + describe('when any item is not an object', function() { + it('should deny', function() { + expect({ + memberName: [null] + }).not.toHaveArrayOfObjects('memberName'); + expect({ + memberName: [null, {}] + }).not.toHaveArrayOfObjects('memberName'); + }); + }); + }); + }); }); describe('toHaveArrayOfSize', function() { - describeToHaveArrayX('toHaveArrayOfSize', function() { - describe('when number of expected items does not match', function() { - it('should deny', function() { - expect({ - memberName: '' - }).not.toHaveArrayOfSize('memberName'); - expect({ - memberName: ['bar'] - }).not.toHaveArrayOfSize('memberName', 0); - }); - }); - describe('when number of expected items does match', function() { - it('should confirm', function() { - expect({ - memberName: [] - }).toHaveArrayOfSize('memberName', 0); - expect({ - memberName: ['bar'] - }).toHaveArrayOfSize('memberName', 1); - expect({ - memberName: ['bar', 'baz'] - }).toHaveArrayOfSize('memberName', 2); - }); - }); + describeToHaveArrayX('toHaveArrayOfSize', function() { + describe('when number of expected items does not match', function() { + it('should deny', function() { + expect({ + memberName: '' + }).not.toHaveArrayOfSize('memberName'); + expect({ + memberName: ['bar'] + }).not.toHaveArrayOfSize('memberName', 0); + }); }); + describe('when number of expected items does match', function() { + it('should confirm', function() { + expect({ + memberName: [] + }).toHaveArrayOfSize('memberName', 0); + expect({ + memberName: ['bar'] + }).toHaveArrayOfSize('memberName', 1); + expect({ + memberName: ['bar', 'baz'] + }).toHaveArrayOfSize('memberName', 2); + }); + }); + }); }); describe('toHaveArrayOfStrings', function() { - describeToHaveArrayX('toHaveArrayOfStrings', function() { - describe('when named Array is empty', function() { - it('should confirm', function() { - expect({ - memberName: [] - }).toHaveArrayOfStrings('memberName'); - }); - }); - describe('when named Array has items', function() { - describe('when all items are strings', function() { - it('should confirm', function() { - expect({ - memberName: ['truthy'] - }).toHaveArrayOfStrings('memberName'); - expect({ - memberName: [new String('truthy')] - }).toHaveArrayOfStrings('memberName'); - expect({ - memberName: [new String('')] - }).toHaveArrayOfStrings('memberName'); - expect({ - memberName: ['', 'truthy'] - }).toHaveArrayOfStrings('memberName'); - }); - }); - describe('when any item is not a string', function() { - it('should deny', function() { - expect({ - memberName: [null] - }).not.toHaveArrayOfStrings('memberName'); - expect({ - memberName: [null, ''] - }).not.toHaveArrayOfStrings('memberName'); - }); - }); - }); + describeToHaveArrayX('toHaveArrayOfStrings', function() { + describe('when named Array is empty', function() { + it('should confirm', function() { + expect({ + memberName: [] + }).toHaveArrayOfStrings('memberName'); + }); }); + describe('when named Array has items', function() { + describe('when all items are strings', function() { + it('should confirm', function() { + expect({ + memberName: ['truthy'] + }).toHaveArrayOfStrings('memberName'); + expect({ + memberName: [new String('truthy')] + }).toHaveArrayOfStrings('memberName'); + expect({ + memberName: [new String('')] + }).toHaveArrayOfStrings('memberName'); + expect({ + memberName: ['', 'truthy'] + }).toHaveArrayOfStrings('memberName'); + }); + }); + describe('when any item is not a string', function() { + it('should deny', function() { + expect({ + memberName: [null] + }).not.toHaveArrayOfStrings('memberName'); + expect({ + memberName: [null, ''] + }).not.toHaveArrayOfStrings('memberName'); + }); + }); + }); + }); }); describe('toHaveBoolean', function() { - describeToHaveBooleanX('toHaveBoolean', function() { - describe('when primitive', function() { - it('should confirm', function() { - expect({ - memberName: true - }).toHaveBoolean('memberName'); - expect({ - memberName: false - }).toHaveBoolean('memberName'); - }); - }); - describe('when Boolean object', function() { - it('should confirm', function() { - expect({ - memberName: new Boolean(true) - }).toHaveBoolean('memberName'); - expect({ - memberName: new Boolean(false) - }).toHaveBoolean('memberName'); - }); - }); + describeToHaveBooleanX('toHaveBoolean', function() { + describe('when primitive', function() { + it('should confirm', function() { + expect({ + memberName: true + }).toHaveBoolean('memberName'); + expect({ + memberName: false + }).toHaveBoolean('memberName'); + }); }); + describe('when Boolean object', function() { + it('should confirm', function() { + expect({ + memberName: new Boolean(true) + }).toHaveBoolean('memberName'); + expect({ + memberName: new Boolean(false) + }).toHaveBoolean('memberName'); + }); + }); + }); }); describe('toHaveCalculable', function() { - describeToHaveX('toHaveCalculable', function() { - describe('when subject CAN be coerced to be used in mathematical operations', function() { - it('should confirm', function() { - expect({ - memberName: '1' - }).toHaveCalculable('memberName'); - expect({ - memberName: '' - }).toHaveCalculable('memberName'); - expect({ - memberName: null - }).toHaveCalculable('memberName'); - }); - }); - describe('when subject can NOT be coerced by JavaScript to be used in mathematical operations', function() { - it('should deny', function() { - expect({ - memberName: {} - }).not.toHaveCalculable('memberName'); - expect({ - memberName: NaN - }).not.toHaveCalculable('memberName'); - }); - }); + describeToHaveX('toHaveCalculable', function() { + describe('when subject CAN be coerced to be used in mathematical operations', function() { + it('should confirm', function() { + expect({ + memberName: '1' + }).toHaveCalculable('memberName'); + expect({ + memberName: '' + }).toHaveCalculable('memberName'); + expect({ + memberName: null + }).toHaveCalculable('memberName'); + }); }); + describe('when subject can NOT be coerced by JavaScript to be used in mathematical operations', function() { + it('should deny', function() { + expect({ + memberName: {} + }).not.toHaveCalculable('memberName'); + expect({ + memberName: NaN + }).not.toHaveCalculable('memberName'); + }); + }); + }); }); describe('toHaveDate', function() { - var mockDate: any; - beforeEach(function() { - mockDate = { - any: new Date(), - early: new Date('2013-01-01T00:00:00.000Z'), - late: new Date('2013-01-01T01:00:00.000Z') - }; + var mockDate: any; + beforeEach(function() { + mockDate = { + any: new Date(), + early: new Date('2013-01-01T00:00:00.000Z'), + late: new Date('2013-01-01T01:00:00.000Z') + }; + }); + describeToHaveX('toHaveDate', function() { + describe('when member is an instance of Date', function() { + it('should confirm', function() { + expect({ + memberName: mockDate.any + }).toHaveDate('memberName'); + }); }); - describeToHaveX('toHaveDate', function() { - describe('when member is an instance of Date', function() { - it('should confirm', function() { - expect({ - memberName: mockDate.any - }).toHaveDate('memberName'); - }); - }); - describe('when member is NOT an instance of Date', function() { - it('should deny', function() { - expect({ - memberName: null - }).not.toHaveDate('memberName'); - }); - }); + describe('when member is NOT an instance of Date', function() { + it('should deny', function() { + expect({ + memberName: null + }).not.toHaveDate('memberName'); + }); }); + }); }); describe('toHaveDateAfter', function() { - var mockDate: any; - beforeEach(function() { - mockDate = { - any: new Date(), - early: new Date('2013-01-01T00:00:00.000Z'), - late: new Date('2013-01-01T01:00:00.000Z') - }; - }); - describeToHaveX('toHaveDateAfter', function() { - describe('when member is an instance of Date', function() { - describe('when date occurs before another', function() { - it('should confirm', function() { - expect({ - memberName: mockDate.late - }).toHaveDateAfter('memberName', mockDate.early); - }); - }); - describe('when date does NOT occur before another', function() { - it('should deny', function() { - expect({ - memberName: mockDate.early - }).not.toHaveDateAfter('memberName', mockDate.late); - }); - }); + var mockDate: any; + beforeEach(function() { + mockDate = { + any: new Date(), + early: new Date('2013-01-01T00:00:00.000Z'), + late: new Date('2013-01-01T01:00:00.000Z') + }; + }); + describeToHaveX('toHaveDateAfter', function() { + describe('when member is an instance of Date', function() { + describe('when date occurs before another', function() { + it('should confirm', function() { + expect({ + memberName: mockDate.late + }).toHaveDateAfter('memberName', mockDate.early); }); - describe('when member is NOT an instance of Date', function() { - it('should deny', function() { - expect({ - memberName: null - }).not.toHaveDateAfter('memberName', mockDate.any); - }); + }); + describe('when date does NOT occur before another', function() { + it('should deny', function() { + expect({ + memberName: mockDate.early + }).not.toHaveDateAfter('memberName', mockDate.late); }); + }); }); + describe('when member is NOT an instance of Date', function() { + it('should deny', function() { + expect({ + memberName: null + }).not.toHaveDateAfter('memberName', mockDate.any); + }); + }); + }); }); describeToHaveX('toHaveDateBefore', function() { - var mockDate: any; - beforeEach(function() { - mockDate = { - any: new Date(), - early: new Date('2013-01-01T00:00:00.000Z'), - late: new Date('2013-01-01T01:00:00.000Z') - }; + var mockDate: any; + beforeEach(function() { + mockDate = { + any: new Date(), + early: new Date('2013-01-01T00:00:00.000Z'), + late: new Date('2013-01-01T01:00:00.000Z') + }; + }); + describe('when member is an instance of Date', function() { + describe('when date occurs before another', function() { + it('should confirm', function() { + expect({ + memberName: mockDate.early + }).toHaveDateBefore('memberName', mockDate.late); + }); }); - describe('when member is an instance of Date', function() { - describe('when date occurs before another', function() { - it('should confirm', function() { - expect({ - memberName: mockDate.early - }).toHaveDateBefore('memberName', mockDate.late); - }); - }); - describe('when date does NOT occur before another', function() { - it('should deny', function() { - expect({ - memberName: mockDate.late - }).not.toHaveDateBefore('memberName', mockDate.early); - }); - }); + describe('when date does NOT occur before another', function() { + it('should deny', function() { + expect({ + memberName: mockDate.late + }).not.toHaveDateBefore('memberName', mockDate.early); + }); }); - describe('when member is NOT an instance of Date', function() { - it('should deny', function() { - expect({ - memberName: null - }).not.toHaveDateBefore('memberName', mockDate.any); - }); + }); + describe('when member is NOT an instance of Date', function() { + it('should deny', function() { + expect({ + memberName: null + }).not.toHaveDateBefore('memberName', mockDate.any); }); + }); }); describe('toHaveEmptyArray', function() { - describeToHaveArrayX('toHaveEmptyArray', function() { - describe('when named array has members', function() { - it('should deny', function() { - expect({ - memberName: [1, 2, 3] - }).not.toHaveEmptyArray('memberName'); - expect({ - memberName: '' - }).not.toHaveEmptyArray('memberName'); - }); - }); - describe('when named array has no members', function() { - it('should confirm', function() { - expect({ - memberName: [] - }).toHaveEmptyArray('memberName'); - }); - }); + describeToHaveArrayX('toHaveEmptyArray', function() { + describe('when named array has members', function() { + it('should deny', function() { + expect({ + memberName: [1, 2, 3] + }).not.toHaveEmptyArray('memberName'); + expect({ + memberName: '' + }).not.toHaveEmptyArray('memberName'); + }); }); + describe('when named array has no members', function() { + it('should confirm', function() { + expect({ + memberName: [] + }).toHaveEmptyArray('memberName'); + }); + }); + }); }); describe('toHaveEmptyObject', function() { - beforeEach(function() { - this.Foo = function() {}; + beforeEach(function() { + this.Foo = function() { }; + }); + describeToHaveX('toHaveEmptyObject', function() { + describe('when subject IS an Object with no instance members', function() { + beforeEach(function() { + this.Foo.prototype = { + b: 2 + }; + }); + it('should confirm', function() { + expect({ + memberName: new this.Foo() + }).toHaveEmptyObject('memberName'); + expect({ + memberName: {} + }).toHaveEmptyObject('memberName'); + }); }); - describeToHaveX('toHaveEmptyObject', function() { - describe('when subject IS an Object with no instance members', function() { - beforeEach(function() { - this.Foo.prototype = { - b: 2 - }; - }); - it('should confirm', function() { - expect({ - memberName: new this.Foo() - }).toHaveEmptyObject('memberName'); - expect({ - memberName: {} - }).toHaveEmptyObject('memberName'); - }); - }); - describe('when subject is NOT an Object with no instance members', function() { - it('should deny', function() { - expect({ - memberName: { - a: 1 - } - }).not.toHaveEmptyObject('memberName'); - expect({ - memberName: null - }).not.toHaveNonEmptyObject('memberName'); - }); - }); + describe('when subject is NOT an Object with no instance members', function() { + it('should deny', function() { + expect({ + memberName: { + a: 1 + } + }).not.toHaveEmptyObject('memberName'); + expect({ + memberName: null + }).not.toHaveNonEmptyObject('memberName'); + }); }); + }); }); describe('toHaveEmptyString', function() { - describeToHaveX('toHaveEmptyString', function() { - describe('when subject IS a string with no characters', function() { - it('should confirm', function() { - expect({ - memberName: '' - }).toHaveEmptyString('memberName'); - }); - }); - describe('when subject is NOT a string with no characters', function() { - it('should deny', function() { - expect({ - memberName: ' ' - }).not.toHaveEmptyString('memberName'); - }); - }); + describeToHaveX('toHaveEmptyString', function() { + describe('when subject IS a string with no characters', function() { + it('should confirm', function() { + expect({ + memberName: '' + }).toHaveEmptyString('memberName'); + }); }); + describe('when subject is NOT a string with no characters', function() { + it('should deny', function() { + expect({ + memberName: ' ' + }).not.toHaveEmptyString('memberName'); + }); + }); + }); }); describe('toHaveEvenNumber', function() { - describeToHaveX('toHaveEvenNumber', function() { - describe('when subject IS an even number', function() { - it('should confirm', function() { - expect({ - memberName: 2 - }).toHaveEvenNumber('memberName'); - }); - }); - describe('when subject is NOT an even number', function() { - it('should deny', function() { - expect({ - memberName: 1 - }).not.toHaveEvenNumber('memberName'); - expect({ - memberName: NaN - }).not.toHaveEvenNumber('memberName'); - }); - }); + describeToHaveX('toHaveEvenNumber', function() { + describe('when subject IS an even number', function() { + it('should confirm', function() { + expect({ + memberName: 2 + }).toHaveEvenNumber('memberName'); + }); }); + describe('when subject is NOT an even number', function() { + it('should deny', function() { + expect({ + memberName: 1 + }).not.toHaveEvenNumber('memberName'); + expect({ + memberName: NaN + }).not.toHaveEvenNumber('memberName'); + }); + }); + }); }); describe('toHaveFalse', function() { - describeToHaveBooleanX('toHaveFalse', function() { - describe('when primitive', function() { - describe('when true', function() { - it('should deny', function() { - expect({ - memberName: true - }).not.toHaveFalse('memberName'); - }); - }); - describe('when false', function() { - it('should confirm', function() { - expect({ - memberName: false - }).toHaveFalse('memberName'); - }); - }); + describeToHaveBooleanX('toHaveFalse', function() { + describe('when primitive', function() { + describe('when true', function() { + it('should deny', function() { + expect({ + memberName: true + }).not.toHaveFalse('memberName'); }); - describe('when Boolean object', function() { - describe('when true', function() { - it('should deny', function() { - expect({ - memberName: new Boolean(true) - }).not.toHaveFalse('memberName'); - }); - }); - describe('when false', function() { - it('should confirm', function() { - expect({ - memberName: new Boolean(false) - }).toHaveFalse('memberName'); - }); - }); + }); + describe('when false', function() { + it('should confirm', function() { + expect({ + memberName: false + }).toHaveFalse('memberName'); }); + }); }); + describe('when Boolean object', function() { + describe('when true', function() { + it('should deny', function() { + expect({ + memberName: new Boolean(true) + }).not.toHaveFalse('memberName'); + }); + }); + describe('when false', function() { + it('should confirm', function() { + expect({ + memberName: new Boolean(false) + }).toHaveFalse('memberName'); + }); + }); + }); + }); }); describe('toHaveHtmlString', function() { - describeToHaveX('toHaveHtmlString', function() { - describe('when subject IS a string of HTML markup', function() { - beforeEach(function() { - this.ngMultiLine = ''; - this.ngMultiLine += ''; - this.ngMultiLine += '\n'; - this.ngMultiLine += ' Watch with Google TV'; - this.ngMultiLine += '\n'; - this.ngMultiLine += ''; - this.ngMultiLine += '\n'; - }); - it('should confirm', function() { - expect({ - memberName: 'text' - }).toHaveHtmlString('memberName'); - expect({ - memberName: 'baz' - }).toHaveHtmlString('memberName'); - expect({ - memberName: '
    ' - }).toHaveHtmlString('memberName'); - expect({ - memberName: '
  • ' - }).toHaveHtmlString('memberName'); - expect({ - memberName: this.ngMultiLine - }).toHaveHtmlString('memberName'); - }); - }); - describe('when subject is NOT a string of HTML markup', function() { - it('should deny', function() { - expect({ - memberName: 'div' - }).not.toHaveHtmlString('memberName'); - expect({ - memberName: null - }).not.toHaveHtmlString('memberName'); - }); - }); + describeToHaveX('toHaveHtmlString', function() { + describe('when subject IS a string of HTML markup', function() { + beforeEach(function() { + this.ngMultiLine = ''; + this.ngMultiLine += ''; + this.ngMultiLine += '\n'; + this.ngMultiLine += ' Watch with Google TV'; + this.ngMultiLine += '\n'; + this.ngMultiLine += ''; + this.ngMultiLine += '\n'; + }); + it('should confirm', function() { + expect({ + memberName: 'text' + }).toHaveHtmlString('memberName'); + expect({ + memberName: 'baz' + }).toHaveHtmlString('memberName'); + expect({ + memberName: '
    ' + }).toHaveHtmlString('memberName'); + expect({ + memberName: '
  • ' + }).toHaveHtmlString('memberName'); + expect({ + memberName: this.ngMultiLine + }).toHaveHtmlString('memberName'); + }); }); + describe('when subject is NOT a string of HTML markup', function() { + it('should deny', function() { + expect({ + memberName: 'div' + }).not.toHaveHtmlString('memberName'); + expect({ + memberName: null + }).not.toHaveHtmlString('memberName'); + }); + }); + }); }); describe('toHaveIso8601', function() { - describeToHaveX('toHaveIso8601', function() { - describe('when member is a Date String conforming to the ISO 8601 standard', - function() { - describe('when specified date is valid', function() { - it('should confirm', function() { - expect({ - memberName: '2013-07-08T07:29:15.863Z' - }).toHaveIso8601('memberName'); - expect({ - memberName: '2013-07-08T07:29:15.863' - }).toHaveIso8601('memberName'); - expect({ - memberName: '2013-07-08T07:29:15' - }).toHaveIso8601('memberName'); - expect({ - memberName: '2013-07-08T07:29' - }).toHaveIso8601('memberName'); - expect({ - memberName: '2013-07-08' - }).toHaveIso8601('memberName'); - }); - }); - describe('when specified date is NOT valid', function() { - it('should deny', function() { - expect({ - memberName: '2013-99-12T00:00:00.000Z' - }).not.toHaveIso8601('memberName'); - expect({ - memberName: '2013-12-99T00:00:00.000Z' - }).not.toHaveIso8601('memberName'); - expect({ - memberName: '2013-01-01T99:00:00.000Z' - }).not.toHaveIso8601('memberName'); - expect({ - memberName: '2013-01-01T99:99:00.000Z' - }).not.toHaveIso8601('memberName'); - expect({ - memberName: '2013-01-01T00:00:99.000Z' - }).not.toHaveIso8601('memberName'); - }); - }); - }); - describe('when member is a String NOT conforming to the ISO 8601 standard', - function() { - it('should deny', function() { - expect({ - memberName: '2013-07-08T07:29:15.' - }).not.toHaveIso8601('memberName'); - expect({ - memberName: '2013-07-08T07:29:' - }).not.toHaveIso8601('memberName'); - expect({ - memberName: '2013-07-08T07:2' - }).not.toHaveIso8601('memberName'); - expect({ - memberName: '2013-07-08T07:' - }).not.toHaveIso8601('memberName'); - expect({ - memberName: '2013-07-08T07' - }).not.toHaveIso8601('memberName'); - expect({ - memberName: '2013-07-08T' - }).not.toHaveIso8601('memberName'); - expect({ - memberName: '2013-07-0' - }).not.toHaveIso8601('memberName'); - expect({ - memberName: '2013-07-' - }).not.toHaveIso8601('memberName'); - expect({ - memberName: '2013-07' - }).not.toHaveIso8601('memberName'); - expect({ - memberName: '2013-0' - }).not.toHaveIso8601('memberName'); - expect({ - memberName: '2013-' - }).not.toHaveIso8601('memberName'); - expect({ - memberName: '2013' - }).not.toHaveIso8601('memberName'); - expect({ - memberName: '201' - }).not.toHaveIso8601('memberName'); - expect({ - memberName: '20' - }).not.toHaveIso8601('memberName'); - expect({ - memberName: '2' - }).not.toHaveIso8601('memberName'); - expect({ - memberName: '' - }).not.toHaveIso8601('memberName'); - }); - }); - }); + describeToHaveX('toHaveIso8601', function() { + describe('when member is a Date String conforming to the ISO 8601 standard', + function() { + describe('when specified date is valid', function() { + it('should confirm', function() { + expect({ + memberName: '2013-07-08T07:29:15.863Z' + }).toHaveIso8601('memberName'); + expect({ + memberName: '2013-07-08T07:29:15.863' + }).toHaveIso8601('memberName'); + expect({ + memberName: '2013-07-08T07:29:15' + }).toHaveIso8601('memberName'); + expect({ + memberName: '2013-07-08T07:29' + }).toHaveIso8601('memberName'); + expect({ + memberName: '2013-07-08' + }).toHaveIso8601('memberName'); + }); + }); + describe('when specified date is NOT valid', function() { + it('should deny', function() { + expect({ + memberName: '2013-99-12T00:00:00.000Z' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-12-99T00:00:00.000Z' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-01-01T99:00:00.000Z' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-01-01T99:99:00.000Z' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-01-01T00:00:99.000Z' + }).not.toHaveIso8601('memberName'); + }); + }); + }); + describe('when member is a String NOT conforming to the ISO 8601 standard', + function() { + it('should deny', function() { + expect({ + memberName: '2013-07-08T07:29:15.' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-07-08T07:29:' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-07-08T07:2' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-07-08T07:' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-07-08T07' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-07-08T' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-07-0' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-07-' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-07' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-0' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013-' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2013' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '201' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '20' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '2' + }).not.toHaveIso8601('memberName'); + expect({ + memberName: '' + }).not.toHaveIso8601('memberName'); + }); + }); + }); }); describe('toHaveJsonString', function() { - describeToHaveX('toHaveJsonString', function() { - describe('when subject IS a string of parseable JSON', function() { - it('should confirm', function() { - expect({ - memberName: '{}' - }).toHaveJsonString('memberName'); - expect({ - memberName: '[]' - }).toHaveJsonString('memberName'); - expect({ - memberName: '[1]' - }).toHaveJsonString('memberName'); - }); - }); - describe('when subject is NOT a string of parseable JSON', function() { - it('should deny', function() { - expect({ - memberName: '[1,]' - }).not.toHaveJsonString('memberName'); - expect({ - memberName: '<>' - }).not.toHaveJsonString('memberName'); - expect({ - memberName: null - }).not.toHaveJsonString('memberName'); - expect({ - memberName: '' - }).not.toHaveJsonString('memberName'); - expect({ - memberName: _undefined - }).not.toHaveJsonString('memberName'); - }); - }); + describeToHaveX('toHaveJsonString', function() { + describe('when subject IS a string of parseable JSON', function() { + it('should confirm', function() { + expect({ + memberName: '{}' + }).toHaveJsonString('memberName'); + expect({ + memberName: '[]' + }).toHaveJsonString('memberName'); + expect({ + memberName: '[1]' + }).toHaveJsonString('memberName'); + }); }); + describe('when subject is NOT a string of parseable JSON', function() { + it('should deny', function() { + expect({ + memberName: '[1,]' + }).not.toHaveJsonString('memberName'); + expect({ + memberName: '<>' + }).not.toHaveJsonString('memberName'); + expect({ + memberName: null + }).not.toHaveJsonString('memberName'); + expect({ + memberName: '' + }).not.toHaveJsonString('memberName'); + expect({ + memberName: _undefined + }).not.toHaveJsonString('memberName'); + }); + }); + }); }); describe('toHaveMember', function() { - describeToHaveX('toHaveMember', function() {}); + describeToHaveX('toHaveMember', function() { }); }); describe('toHaveMethod', function() { - describeToHaveX('toHaveMethod', function() { - describe('when subject IS a function', function() { - it('should confirm', function() { - expect({ - memberName: function() {} - }).toHaveMethod('memberName'); - }); - }); - describe('when subject is NOT a function', function() { - it('should deny', function() { - expect({ - memberName: /regexp/ - }).not.toHaveMethod('memberName'); - }); - }); + describeToHaveX('toHaveMethod', function() { + describe('when subject IS a function', function() { + it('should confirm', function() { + expect({ + memberName: function() { } + }).toHaveMethod('memberName'); + }); }); + describe('when subject is NOT a function', function() { + it('should deny', function() { + expect({ + memberName: /regexp/ + }).not.toHaveMethod('memberName'); + }); + }); + }); }); describe('toHaveNonEmptyArray', function() { - describeToHaveArrayX('toHaveNonEmptyArray', function() { - describe('when named array has no members', function() { - it('should deny', function() { - expect({ - memberName: [] - }).not.toHaveNonEmptyArray('memberName'); - }); - }); - describe('when named array has members', function() { - it('should confirm', function() { - expect({ - memberName: [1, 2, 3] - }).toHaveNonEmptyArray('memberName'); - }); - }); + describeToHaveArrayX('toHaveNonEmptyArray', function() { + describe('when named array has no members', function() { + it('should deny', function() { + expect({ + memberName: [] + }).not.toHaveNonEmptyArray('memberName'); + }); }); + describe('when named array has members', function() { + it('should confirm', function() { + expect({ + memberName: [1, 2, 3] + }).toHaveNonEmptyArray('memberName'); + }); + }); + }); }); describe('toHaveNonEmptyObject', function() { - describeToHaveX('toHaveNonEmptyObject', function() { - beforeEach(function() { - this.Foo = function() {}; - }); - describe('when subject IS an Object with at least one instance member', function() { - it('should confirm', function() { - expect({ - memberName: { - a: 1 - } - }).toHaveNonEmptyObject('memberName'); - }); - }); - describe('when subject is NOT an Object with at least one instance member', function() { - beforeEach(function() { - this.Foo.prototype = { - b: 2 - }; - }); - it('should deny', function() { - expect({ - memberName: new this.Foo() - }).not.toHaveNonEmptyObject('memberName'); - expect({ - memberName: {} - }).not.toHaveNonEmptyObject('memberName'); - expect({ - memberName: null - }).not.toHaveNonEmptyObject('memberName'); - }); - }); + describeToHaveX('toHaveNonEmptyObject', function() { + beforeEach(function() { + this.Foo = function() { }; }); + describe('when subject IS an Object with at least one instance member', function() { + it('should confirm', function() { + expect({ + memberName: { + a: 1 + } + }).toHaveNonEmptyObject('memberName'); + }); + }); + describe('when subject is NOT an Object with at least one instance member', function() { + beforeEach(function() { + this.Foo.prototype = { + b: 2 + }; + }); + it('should deny', function() { + expect({ + memberName: new this.Foo() + }).not.toHaveNonEmptyObject('memberName'); + expect({ + memberName: {} + }).not.toHaveNonEmptyObject('memberName'); + expect({ + memberName: null + }).not.toHaveNonEmptyObject('memberName'); + }); + }); + }); }); describe('toHaveNonEmptyString', function() { - describeToHaveX('toHaveNonEmptyString', function() { - describe('when subject IS a string with at least one character', function() { - it('should confirm', function() { - expect({ - memberName: ' ' - }).toHaveNonEmptyString('memberName'); - }); - }); - describe('when subject is NOT a string with at least one character', function() { - it('should deny', function() { - expect({ - memberName: '' - }).not.toHaveNonEmptyString('memberName'); - expect({ - memberName: null - }).not.toHaveNonEmptyString('memberName'); - }); - }); + describeToHaveX('toHaveNonEmptyString', function() { + describe('when subject IS a string with at least one character', function() { + it('should confirm', function() { + expect({ + memberName: ' ' + }).toHaveNonEmptyString('memberName'); + }); }); + describe('when subject is NOT a string with at least one character', function() { + it('should deny', function() { + expect({ + memberName: '' + }).not.toHaveNonEmptyString('memberName'); + expect({ + memberName: null + }).not.toHaveNonEmptyString('memberName'); + }); + }); + }); }); describe('toHaveNumber', function() { - describeToHaveX('toHaveNumber', function() { - describe('when subject IS a number', function() { - it('should confirm', function() { - expect({ - memberName: 1 - }).toHaveNumber('memberName'); - expect({ - memberName: 1.11 - }).toHaveNumber('memberName'); - expect({ - memberName: 1e3 - }).toHaveNumber('memberName'); - expect({ - memberName: 0.11 - }).toHaveNumber('memberName'); - expect({ - memberName: -11 - }).toHaveNumber('memberName'); - }); - }); - describe('when subject is NOT a number', function() { - it('should deny', function() { - expect({ - memberName: '1' - }).not.toHaveNumber('memberName'); - expect({ - memberName: NaN - }).not.toHaveNumber('memberName'); - }); - }); + describeToHaveX('toHaveNumber', function() { + describe('when subject IS a number', function() { + it('should confirm', function() { + expect({ + memberName: 1 + }).toHaveNumber('memberName'); + expect({ + memberName: 1.11 + }).toHaveNumber('memberName'); + expect({ + memberName: 1e3 + }).toHaveNumber('memberName'); + expect({ + memberName: 0.11 + }).toHaveNumber('memberName'); + expect({ + memberName: -11 + }).toHaveNumber('memberName'); + }); }); + describe('when subject is NOT a number', function() { + it('should deny', function() { + expect({ + memberName: '1' + }).not.toHaveNumber('memberName'); + expect({ + memberName: NaN + }).not.toHaveNumber('memberName'); + }); + }); + }); }); describe('toHaveNumberWithinRange', function() { - describeToHaveX('toHaveNumberWithinRange', function() { - describe('when subject IS a number >= floor and <= ceiling', function() { - it('should confirm', function() { - expect({ - memberName: 0 - }).toHaveNumberWithinRange('memberName', 0, 2); - expect({ - memberName: 1 - }).toHaveNumberWithinRange('memberName', 0, 2); - expect({ - memberName: 2 - }).toHaveNumberWithinRange('memberName', 0, 2); - }); - }); - describe('when subject is NOT a number >= floor and <= ceiling', function() { - it('should deny', function() { - expect({ - memberName: -3 - }).not.toHaveNumberWithinRange('memberName', 0, 2); - expect({ - memberName: -2 - }).not.toHaveNumberWithinRange('memberName', 0, 2); - expect({ - memberName: -1 - }).not.toHaveNumberWithinRange('memberName', 0, 2); - expect({ - memberName: 3 - }).not.toHaveNumberWithinRange('memberName', 0, 2); - expect({ - memberName: NaN - }).not.toHaveNumberWithinRange('memberName', 0, 2); - }); - }); + describeToHaveX('toHaveNumberWithinRange', function() { + describe('when subject IS a number >= floor and <= ceiling', function() { + it('should confirm', function() { + expect({ + memberName: 0 + }).toHaveNumberWithinRange('memberName', 0, 2); + expect({ + memberName: 1 + }).toHaveNumberWithinRange('memberName', 0, 2); + expect({ + memberName: 2 + }).toHaveNumberWithinRange('memberName', 0, 2); + }); }); + describe('when subject is NOT a number >= floor and <= ceiling', function() { + it('should deny', function() { + expect({ + memberName: -3 + }).not.toHaveNumberWithinRange('memberName', 0, 2); + expect({ + memberName: -2 + }).not.toHaveNumberWithinRange('memberName', 0, 2); + expect({ + memberName: -1 + }).not.toHaveNumberWithinRange('memberName', 0, 2); + expect({ + memberName: 3 + }).not.toHaveNumberWithinRange('memberName', 0, 2); + expect({ + memberName: NaN + }).not.toHaveNumberWithinRange('memberName', 0, 2); + }); + }); + }); }); describe('toHaveObject', function() { - describeToHaveX('toHaveObject', function() { - beforeEach(function() { - this.Foo = function() {}; - }); - describe('when subject IS an Object', function() { - it('should confirm', function() { - expect({ - memberName: new Object() - }).toHaveObject('memberName'); - expect({ - memberName: new this.Foo() - }).toHaveObject('memberName'); - expect({ - memberName: {} - }).toHaveObject('memberName'); - }); - }); - describe('when subject is NOT an Object', function() { - it('should deny', function() { - expect({ - memberName: null - }).not.toHaveObject('memberName'); - expect({ - memberName: 123 - }).not.toHaveObject('memberName'); - expect({ - memberName: '[object Object]' - }).not.toHaveObject('memberName'); - }); - }); + describeToHaveX('toHaveObject', function() { + beforeEach(function() { + this.Foo = function() { }; }); + describe('when subject IS an Object', function() { + it('should confirm', function() { + expect({ + memberName: new Object() + }).toHaveObject('memberName'); + expect({ + memberName: new this.Foo() + }).toHaveObject('memberName'); + expect({ + memberName: {} + }).toHaveObject('memberName'); + }); + }); + describe('when subject is NOT an Object', function() { + it('should deny', function() { + expect({ + memberName: null + }).not.toHaveObject('memberName'); + expect({ + memberName: 123 + }).not.toHaveObject('memberName'); + expect({ + memberName: '[object Object]' + }).not.toHaveObject('memberName'); + }); + }); + }); }); describe('toHaveOddNumber', function() { - describeToHaveX('toHaveOddNumber', function() { - describe('when subject IS an odd number', function() { - it('should confirm', function() { - expect({ - memberName: 1 - }).toHaveOddNumber('memberName'); - }); - }); - describe('when subject is NOT an odd number', function() { - it('should deny', function() { - expect({ - memberName: 2 - }).not.toHaveOddNumber('memberName'); - expect({ - memberName: NaN - }).not.toHaveOddNumber('memberName'); - }); - }); + describeToHaveX('toHaveOddNumber', function() { + describe('when subject IS an odd number', function() { + it('should confirm', function() { + expect({ + memberName: 1 + }).toHaveOddNumber('memberName'); + }); }); + describe('when subject is NOT an odd number', function() { + it('should deny', function() { + expect({ + memberName: 2 + }).not.toHaveOddNumber('memberName'); + expect({ + memberName: NaN + }).not.toHaveOddNumber('memberName'); + }); + }); + }); }); describe('toHaveString', function() { - describeToHaveX('toHaveString', function() { - describe('when subject IS a string of any length', function() { - it('should confirm', function() { - expect({ - memberName: '' - }).toHaveString('memberName'); - expect({ - memberName: ' ' - }).toHaveString('memberName'); - }); - }); - describe('when subject is NOT a string of any length', function() { - it('should deny', function() { - expect({ - memberName: null - }).not.toHaveString('memberName'); - }); - }); + describeToHaveX('toHaveString', function() { + describe('when subject IS a string of any length', function() { + it('should confirm', function() { + expect({ + memberName: '' + }).toHaveString('memberName'); + expect({ + memberName: ' ' + }).toHaveString('memberName'); + }); }); + describe('when subject is NOT a string of any length', function() { + it('should deny', function() { + expect({ + memberName: null + }).not.toHaveString('memberName'); + }); + }); + }); }); describe('toHaveStringLongerThan', function() { - describeToHaveX('toHaveStringLongerThan', function() { - describe('when the subject and comparison ARE both strings', function() { - describe('when the subject IS longer than the comparision string', function() { - it('should confirm', function() { - expect({ - memberName: 'abc' - }).toHaveStringLongerThan('memberName', 'ab'); - expect({ - memberName: 'a' - }).toHaveStringLongerThan('memberName', ''); - }); - }); - describe('when the subject is NOT longer than the comparision string', function() { - it('should deny', function() { - expect({ - memberName: 'ab' - }).not.toHaveStringLongerThan('memberName', 'abc'); - expect({ - memberName: '' - }).not.toHaveStringLongerThan('memberName', 'a'); - }); - }); + describeToHaveX('toHaveStringLongerThan', function() { + describe('when the subject and comparison ARE both strings', function() { + describe('when the subject IS longer than the comparision string', function() { + it('should confirm', function() { + expect({ + memberName: 'abc' + }).toHaveStringLongerThan('memberName', 'ab'); + expect({ + memberName: 'a' + }).toHaveStringLongerThan('memberName', ''); }); - describe('when the subject and comparison are NOT both strings', function() { - it('should deny (we are asserting the relative lengths of two strings)', function() { - expect({ - memberName: 'truthy' - }).not.toHaveStringLongerThan('memberName', _undefined); - expect({ - memberName: _undefined - }).not.toHaveStringLongerThan('memberName', 'truthy'); - expect({ - memberName: '' - }).not.toHaveStringLongerThan('memberName', _undefined); - expect({ - memberName: _undefined - }).not.toHaveStringLongerThan('memberName', ''); - }); + }); + describe('when the subject is NOT longer than the comparision string', function() { + it('should deny', function() { + expect({ + memberName: 'ab' + }).not.toHaveStringLongerThan('memberName', 'abc'); + expect({ + memberName: '' + }).not.toHaveStringLongerThan('memberName', 'a'); }); + }); }); + describe('when the subject and comparison are NOT both strings', function() { + it('should deny (we are asserting the relative lengths of two strings)', function() { + expect({ + memberName: 'truthy' + }).not.toHaveStringLongerThan('memberName', _undefined); + expect({ + memberName: _undefined + }).not.toHaveStringLongerThan('memberName', 'truthy'); + expect({ + memberName: '' + }).not.toHaveStringLongerThan('memberName', _undefined); + expect({ + memberName: _undefined + }).not.toHaveStringLongerThan('memberName', ''); + }); + }); + }); }); describe('toHaveStringSameLengthAs', function() { - describeToHaveX('toHaveStringSameLengthAs', function() { - describe('when the subject and comparison ARE both strings', function() { - describe('when the subject IS the same length as the comparision string', function() { - it('should confirm', function() { - expect({ - memberName: 'ab' - }).toHaveStringSameLengthAs('memberName', 'ab'); - }); - }); - describe('when the subject is NOT the same length as the comparision string', function() { - it('should deny', function() { - expect({ - memberName: 'abc' - }).not.toHaveStringSameLengthAs('memberName', 'ab'); - expect({ - memberName: 'a' - }).not.toHaveStringSameLengthAs('memberName', ''); - expect({ - memberName: '' - }).not.toHaveStringSameLengthAs('memberName', 'a'); - }); - }); + describeToHaveX('toHaveStringSameLengthAs', function() { + describe('when the subject and comparison ARE both strings', function() { + describe('when the subject IS the same length as the comparision string', function() { + it('should confirm', function() { + expect({ + memberName: 'ab' + }).toHaveStringSameLengthAs('memberName', 'ab'); }); - describe('when the subject and comparison are NOT both strings', function() { - it('should deny (we are asserting the relative lengths of two strings)', function() { - expect({ - memberName: 'truthy' - }).not.toHaveStringSameLengthAs('memberName', _undefined); - expect({ - memberName: _undefined - }).not.toHaveStringSameLengthAs('memberName', 'truthy'); - expect({ - memberName: '' - }).not.toHaveStringSameLengthAs('memberName', _undefined); - expect({ - memberName: _undefined - }).not.toHaveStringSameLengthAs('memberName', ''); - }); + }); + describe('when the subject is NOT the same length as the comparision string', function() { + it('should deny', function() { + expect({ + memberName: 'abc' + }).not.toHaveStringSameLengthAs('memberName', 'ab'); + expect({ + memberName: 'a' + }).not.toHaveStringSameLengthAs('memberName', ''); + expect({ + memberName: '' + }).not.toHaveStringSameLengthAs('memberName', 'a'); }); + }); }); + describe('when the subject and comparison are NOT both strings', function() { + it('should deny (we are asserting the relative lengths of two strings)', function() { + expect({ + memberName: 'truthy' + }).not.toHaveStringSameLengthAs('memberName', _undefined); + expect({ + memberName: _undefined + }).not.toHaveStringSameLengthAs('memberName', 'truthy'); + expect({ + memberName: '' + }).not.toHaveStringSameLengthAs('memberName', _undefined); + expect({ + memberName: _undefined + }).not.toHaveStringSameLengthAs('memberName', ''); + }); + }); + }); }); describe('toHaveStringShorterThan', function() { - describeToHaveX('toHaveStringShorterThan', function() { - describe('when the subject and comparison ARE both strings', function() { - describe('when the subject IS shorter than the comparision string', function() { - it('should confirm', function() { - expect({ - memberName: 'ab' - }).toHaveStringShorterThan('memberName', 'abc'); - expect({ - memberName: '' - }).toHaveStringShorterThan('memberName', 'a'); - }); - }); - describe('when the subject is NOT shorter than the comparision string', function() { - it('should deny', function() { - expect({ - memberName: 'abc' - }).not.toHaveStringShorterThan('memberName', 'ab'); - expect({ - memberName: 'a' - }).not.toHaveStringShorterThan('memberName', ''); - }); - }); + describeToHaveX('toHaveStringShorterThan', function() { + describe('when the subject and comparison ARE both strings', function() { + describe('when the subject IS shorter than the comparision string', function() { + it('should confirm', function() { + expect({ + memberName: 'ab' + }).toHaveStringShorterThan('memberName', 'abc'); + expect({ + memberName: '' + }).toHaveStringShorterThan('memberName', 'a'); }); - describe('when the subject and comparison are NOT both strings', function() { - it('should deny (we are asserting the relative lengths of two strings)', function() { - expect({ - memberName: 'truthy' - }).not.toHaveStringShorterThan('memberName', _undefined); - expect({ - memberName: _undefined - }).not.toHaveStringShorterThan('memberName', 'truthy'); - expect({ - memberName: '' - }).not.toHaveStringShorterThan('memberName', _undefined); - expect({ - memberName: _undefined - }).not.toHaveStringShorterThan('memberName', ''); - }); + }); + describe('when the subject is NOT shorter than the comparision string', function() { + it('should deny', function() { + expect({ + memberName: 'abc' + }).not.toHaveStringShorterThan('memberName', 'ab'); + expect({ + memberName: 'a' + }).not.toHaveStringShorterThan('memberName', ''); }); + }); }); + describe('when the subject and comparison are NOT both strings', function() { + it('should deny (we are asserting the relative lengths of two strings)', function() { + expect({ + memberName: 'truthy' + }).not.toHaveStringShorterThan('memberName', _undefined); + expect({ + memberName: _undefined + }).not.toHaveStringShorterThan('memberName', 'truthy'); + expect({ + memberName: '' + }).not.toHaveStringShorterThan('memberName', _undefined); + expect({ + memberName: _undefined + }).not.toHaveStringShorterThan('memberName', ''); + }); + }); + }); }); describe('toHaveTrue', function() { - describeToHaveBooleanX('toHaveTrue', function() { - describe('when primitive', function() { - describe('when true', function() { - it('should confirm', function() { - expect({ - memberName: true - }).toHaveTrue('memberName'); - }); - }); - describe('when false', function() { - it('should deny', function() { - expect({ - memberName: false - }).not.toHaveTrue('memberName'); - }); - }); + describeToHaveBooleanX('toHaveTrue', function() { + describe('when primitive', function() { + describe('when true', function() { + it('should confirm', function() { + expect({ + memberName: true + }).toHaveTrue('memberName'); }); - describe('when Boolean object', function() { - describe('when true', function() { - it('should confirm', function() { - expect({ - memberName: new Boolean(true) - }).toHaveTrue('memberName'); - }); - }); - describe('when false', function() { - it('should deny', function() { - expect({ - memberName: new Boolean(false) - }).not.toHaveTrue('memberName'); - }); - }); + }); + describe('when false', function() { + it('should deny', function() { + expect({ + memberName: false + }).not.toHaveTrue('memberName'); }); + }); }); + describe('when Boolean object', function() { + describe('when true', function() { + it('should confirm', function() { + expect({ + memberName: new Boolean(true) + }).toHaveTrue('memberName'); + }); + }); + describe('when false', function() { + it('should deny', function() { + expect({ + memberName: new Boolean(false) + }).not.toHaveTrue('memberName'); + }); + }); + }); + }); }); describe('toHaveWhitespaceString', function() { - describeToHaveX('toHaveWhitespaceString', function() { - describe('when subject IS a string containing only tabs, spaces, returns etc', function() { - it('should confirm', function() { - expect({ - memberName: ' ' - }).toHaveWhitespaceString('memberName'); - expect({ - memberName: '' - }).toHaveWhitespaceString('memberName'); - }); - }); - describe('when subject is NOT a string containing only tabs, spaces, returns etc', function() { - it('should deny', function() { - expect({ - memberName: 'has-no-whitespace' - }).not.toHaveWhitespaceString('memberName'); - expect({ - memberName: 'has whitespace' - }).not.toHaveWhitespaceString('memberName'); - expect({ - memberName: null - }).not.toHaveWhitespaceString('memberName'); - }); - }); + describeToHaveX('toHaveWhitespaceString', function() { + describe('when subject IS a string containing only tabs, spaces, returns etc', function() { + it('should confirm', function() { + expect({ + memberName: ' ' + }).toHaveWhitespaceString('memberName'); + expect({ + memberName: '' + }).toHaveWhitespaceString('memberName'); + }); }); + describe('when subject is NOT a string containing only tabs, spaces, returns etc', function() { + it('should deny', function() { + expect({ + memberName: 'has-no-whitespace' + }).not.toHaveWhitespaceString('memberName'); + expect({ + memberName: 'has whitespace' + }).not.toHaveWhitespaceString('memberName'); + expect({ + memberName: null + }).not.toHaveWhitespaceString('memberName'); + }); + }); + }); }); describe('toHaveWholeNumber', function() { - describeToHaveX('toHaveWholeNumber', function() { - describe('when subject IS a number with no positive decimal places', function() { - it('should confirm', function() { - expect({ - memberName: 1 - }).toHaveWholeNumber('memberName'); - expect({ - memberName: 0 - }).toHaveWholeNumber('memberName'); - expect({ - memberName: 0.0 - }).toHaveWholeNumber('memberName'); - }); - }); - describe('when subject is NOT a number with no positive decimal places', function() { - it('should deny', function() { - expect({ - memberName: NaN - }).not.toHaveWholeNumber('memberName'); - expect({ - memberName: 1.1 - }).not.toHaveWholeNumber('memberName'); - expect({ - memberName: 0.1 - }).not.toHaveWholeNumber('memberName'); - }); - }); + describeToHaveX('toHaveWholeNumber', function() { + describe('when subject IS a number with no positive decimal places', function() { + it('should confirm', function() { + expect({ + memberName: 1 + }).toHaveWholeNumber('memberName'); + expect({ + memberName: 0 + }).toHaveWholeNumber('memberName'); + expect({ + memberName: 0.0 + }).toHaveWholeNumber('memberName'); + }); }); + describe('when subject is NOT a number with no positive decimal places', function() { + it('should deny', function() { + expect({ + memberName: NaN + }).not.toHaveWholeNumber('memberName'); + expect({ + memberName: 1.1 + }).not.toHaveWholeNumber('memberName'); + expect({ + memberName: 0.1 + }).not.toHaveWholeNumber('memberName'); + }); + }); + }); }); describe('toImplement', function() { - describe('when invoked', function() { - describe('when subject IS an Object containing all of the supplied members', function() { - it('should confirm', function() { - expect({ - a: 1, - b: 2 - }).toImplement({ - a: 1, - b: 2 - }); - expect({ - a: 1, - b: 2 - }).toImplement({ - a: 1 - }); - }); + describe('when invoked', function() { + describe('when subject IS an Object containing all of the supplied members', function() { + it('should confirm', function() { + expect({ + a: 1, + b: 2 + }).toImplement({ + a: 1, + b: 2 }); - describe('when subject is NOT an Object containing all of the supplied members', function() { - it('should deny', function() { - expect({ - a: 1 - }).not.toImplement({ - c: 3 - }); - expect(null).not.toImplement({ - a: 1 - }); - }); + expect({ + a: 1, + b: 2 + }).toImplement({ + a: 1 }); + }); }); + describe('when subject is NOT an Object containing all of the supplied members', function() { + it('should deny', function() { + expect({ + a: 1 + }).not.toImplement({ + c: 3 + }); + expect(null).not.toImplement({ + a: 1 + }); + }); + }); + }); }); describe('toStartWith', function() { - describe('when invoked', function() { - describe('when subject is NOT an undefined or empty string', function() { - describe('when subject is a string whose leading characters match the expected string', function() { - it('should confirm', function() { - expect('jamie').toStartWith('jam'); - }); - }); - describe('when subject is a string whose leading characters DO NOT match the expected string', function() { - it('should deny', function() { - expect(' jamie').not.toStartWith('jam'); - expect('Jamie').not.toStartWith('jam'); - }); - }); + describe('when invoked', function() { + describe('when subject is NOT an undefined or empty string', function() { + describe('when subject is a string whose leading characters match the expected string', function() { + it('should confirm', function() { + expect('jamie').toStartWith('jam'); }); - describe('when subject IS an undefined or empty string', function() { - it('should deny', function() { - expect('').not.toStartWith(''); - expect(_undefined).not.toStartWith(''); - expect(_undefined).not.toStartWith('undefined'); - expect('undefined').not.toStartWith(_undefined); - }); + }); + describe('when subject is a string whose leading characters DO NOT match the expected string', function() { + it('should deny', function() { + expect(' jamie').not.toStartWith('jam'); + expect('Jamie').not.toStartWith('jam'); }); + }); }); + describe('when subject IS an undefined or empty string', function() { + it('should deny', function() { + expect('').not.toStartWith(''); + expect(_undefined).not.toStartWith(''); + expect(_undefined).not.toStartWith('undefined'); + expect('undefined').not.toStartWith(_undefined); + }); + }); + }); }); describe('toThrowAnyError', function() { - describe('when supplied a function', function() { - describe('when function errors when invoked', function() { - beforeEach(function() { - this.throwError = function() { - throw new Error('wut?'); - }; - this.badReference = function() { - return badReference.someValue; - }; - }); - it('should confirm', function() { - expect(this.throwError).toThrowAnyError(); - expect(this.badReference).toThrowAnyError(); - }); - }); - describe('when function does NOT error when invoked', function() { - beforeEach(function() { - this.noErrors = function() {}; - }); - it('should deny', function() { - expect(this.noErrors).not.toThrowAnyError(); - }); - }); + describe('when supplied a function', function() { + describe('when function errors when invoked', function() { + beforeEach(function() { + this.throwError = function() { + throw new Error('wut?'); + }; + this.badReference = function() { + return badReference.someValue; + }; + }); + it('should confirm', function() { + expect(this.throwError).toThrowAnyError(); + expect(this.badReference).toThrowAnyError(); + }); }); + describe('when function does NOT error when invoked', function() { + beforeEach(function() { + this.noErrors = function() { }; + }); + it('should deny', function() { + expect(this.noErrors).not.toThrowAnyError(); + }); + }); + }); }); describe('toThrowErrorOfType', function() { - describe('when supplied a function', function() { - describe('when function errors when invoked', function() { - beforeEach(function() { - this.throwError = function() { - throw new Error('wut?'); - }; - this.badReference = function() { - return badReference.someValue; - }; - }); - describe('when the error is of the expected type', function() { - it('should confirm', function() { - expect(this.throwError).toThrowErrorOfType('Error'); - expect(this.badReference).toThrowErrorOfType('ReferenceError'); - }); - }); - describe('when the error is NOT of the expected type', function() { - it('should confirm', function() { - expect(this.throwError).not.toThrowErrorOfType('ReferenceError'); - expect(this.badReference).not.toThrowErrorOfType('Error'); - }); - }); + describe('when supplied a function', function() { + describe('when function errors when invoked', function() { + beforeEach(function() { + this.throwError = function() { + throw new Error('wut?'); + }; + this.badReference = function() { + return badReference.someValue; + }; + }); + describe('when the error is of the expected type', function() { + it('should confirm', function() { + expect(this.throwError).toThrowErrorOfType('Error'); + expect(this.badReference).toThrowErrorOfType('ReferenceError'); }); + }); + describe('when the error is NOT of the expected type', function() { + it('should confirm', function() { + expect(this.throwError).not.toThrowErrorOfType('ReferenceError'); + expect(this.badReference).not.toThrowErrorOfType('Error'); + }); + }); }); + }); }); From c4f6180ca5edb993ce567b90df47e95faf2f860f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Ewerl=C3=B6f?= Date: Mon, 23 Nov 2015 19:41:46 +0100 Subject: [PATCH 07/10] reformated the definition file to tab=2 --- .../jamiemason-jasmine-matchers.d.ts | 156 +++++++++--------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/jasmine-matchers/jamiemason-jasmine-matchers.d.ts b/jasmine-matchers/jamiemason-jasmine-matchers.d.ts index e293496c6..91b473a58 100644 --- a/jasmine-matchers/jamiemason-jasmine-matchers.d.ts +++ b/jasmine-matchers/jamiemason-jasmine-matchers.d.ts @@ -22,87 +22,87 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI /// declare module jasmine { - interface Matchers { - // These functions are written in the order defined in the src directory of jasmine-matchers - // The type system is used smartly whenever it can provide value (by looking at the code of every matcher) - toBeAfter(otherDate: Date): boolean; // - toBeArray(): boolean; // - toBeArrayOfBooleans(): boolean; // - toBeArrayOfNumbers(): boolean; - toBeArrayOfObjects(): boolean; - toBeArrayOfSize(size: number): boolean; - toBeArrayOfStrings(): boolean; - toBeBefore(otherDate: Date): boolean; // - toBeBoolean(): boolean; - toBeCalculable(): boolean; - toBeDate(): boolean; - toBeEmptyArray(): boolean; - toBeEmptyObject(): boolean; - toBeEmptyString(): boolean; - toBeEvenNumber(): boolean; - toBeFalse(): boolean; - toBeFunction(): boolean; - toBeHtmlString(): boolean; - toBeIso8601(): boolean; - toBeJsonString(): boolean; - toBeLongerThan(other: string): boolean; - toBeNonEmptyArray(): boolean; - toBeNonEmptyObject(): boolean; - toBeNonEmptyString(): boolean; - toBeNumber(): boolean; - toBeObject(): boolean; - toBeOddNumber(): boolean; - toBeSameLengthAs(other: string): boolean; - toBeShorterThan(other: string): boolean; - toBeString(): boolean; - toBeTrue(): boolean; - toBeWhitespace(): boolean; - toBeWholeNumber(): boolean; - toBeWithinRange(floor: number, ceiling: number): boolean; + interface Matchers { + // These functions are written in the order defined in the src directory of jasmine-matchers + // The type system is used smartly whenever it can provide value (by looking at the code of every matcher) + toBeAfter(otherDate: Date): boolean; // + toBeArray(): boolean; // + toBeArrayOfBooleans(): boolean; // + toBeArrayOfNumbers(): boolean; + toBeArrayOfObjects(): boolean; + toBeArrayOfSize(size: number): boolean; + toBeArrayOfStrings(): boolean; + toBeBefore(otherDate: Date): boolean; // + toBeBoolean(): boolean; + toBeCalculable(): boolean; + toBeDate(): boolean; + toBeEmptyArray(): boolean; + toBeEmptyObject(): boolean; + toBeEmptyString(): boolean; + toBeEvenNumber(): boolean; + toBeFalse(): boolean; + toBeFunction(): boolean; + toBeHtmlString(): boolean; + toBeIso8601(): boolean; + toBeJsonString(): boolean; + toBeLongerThan(other: string): boolean; + toBeNonEmptyArray(): boolean; + toBeNonEmptyObject(): boolean; + toBeNonEmptyString(): boolean; + toBeNumber(): boolean; + toBeObject(): boolean; + toBeOddNumber(): boolean; + toBeSameLengthAs(other: string): boolean; + toBeShorterThan(other: string): boolean; + toBeString(): boolean; + toBeTrue(): boolean; + toBeWhitespace(): boolean; + toBeWholeNumber(): boolean; + toBeWithinRange(floor: number, ceiling: number): boolean; - toEndWith(subString: string): boolean; + toEndWith(subString: string): boolean; - toHaveArray(key: string): boolean; - toHaveArrayOfBooleans(key: string): boolean; - toHaveArrayOfNumbers(key: string): boolean; - toHaveArrayOfObjects(key: string): boolean; - toHaveArrayOfSize(key: string, size?: number): boolean; - toHaveArrayOfStrings(key: string): boolean; - toHaveBoolean(key: string): boolean; - toHaveCalculable(key: string): boolean; - toHaveDate(key: string): boolean; - toHaveDateAfter(key: string, otherDate: Date): boolean; - toHaveDateBefore(key: string, otherDate: Date): boolean; - toHaveEmptyArray(key: string): boolean; - toHaveEmptyObject(key: string): boolean; - toHaveEmptyString(key: string): boolean; - toHaveEvenNumber(key: string): boolean; - toHaveFalse(key: string): boolean; - toHaveHtmlString(key: string): boolean; - toHaveIso8601(key: string): boolean; - toHaveJsonString(key: string): boolean; - toHaveMember(key: string): boolean; - toHaveMethod(key: string): boolean; - toHaveNonEmptyArray(key: string): boolean; - toHaveNonEmptyObject(key: string): boolean; - toHaveNonEmptyString(key: string): boolean; - toHaveNumber(key: string): boolean; - toHaveNumberWithinRange(key: string, floor: number, ceiling: number): boolean; - toHaveObject(key: string): boolean; - toHaveOddNumber(key: string): boolean; - toHaveString(key: string): boolean; - toHaveStringLongerThan(key: string, other: string): boolean; - toHaveStringSameLengthAs(key: string, other: string): boolean; - toHaveStringShorterThan(key: string, other: string): boolean; - toHaveTrue(key: string): boolean; - toHaveWhitespaceString(key: string): boolean; - toHaveWholeNumber(key: string): boolean; + toHaveArray(key: string): boolean; + toHaveArrayOfBooleans(key: string): boolean; + toHaveArrayOfNumbers(key: string): boolean; + toHaveArrayOfObjects(key: string): boolean; + toHaveArrayOfSize(key: string, size?: number): boolean; + toHaveArrayOfStrings(key: string): boolean; + toHaveBoolean(key: string): boolean; + toHaveCalculable(key: string): boolean; + toHaveDate(key: string): boolean; + toHaveDateAfter(key: string, otherDate: Date): boolean; + toHaveDateBefore(key: string, otherDate: Date): boolean; + toHaveEmptyArray(key: string): boolean; + toHaveEmptyObject(key: string): boolean; + toHaveEmptyString(key: string): boolean; + toHaveEvenNumber(key: string): boolean; + toHaveFalse(key: string): boolean; + toHaveHtmlString(key: string): boolean; + toHaveIso8601(key: string): boolean; + toHaveJsonString(key: string): boolean; + toHaveMember(key: string): boolean; + toHaveMethod(key: string): boolean; + toHaveNonEmptyArray(key: string): boolean; + toHaveNonEmptyObject(key: string): boolean; + toHaveNonEmptyString(key: string): boolean; + toHaveNumber(key: string): boolean; + toHaveNumberWithinRange(key: string, floor: number, ceiling: number): boolean; + toHaveObject(key: string): boolean; + toHaveOddNumber(key: string): boolean; + toHaveString(key: string): boolean; + toHaveStringLongerThan(key: string, other: string): boolean; + toHaveStringSameLengthAs(key: string, other: string): boolean; + toHaveStringShorterThan(key: string, other: string): boolean; + toHaveTrue(key: string): boolean; + toHaveWhitespaceString(key: string): boolean; + toHaveWholeNumber(key: string): boolean; - toImplement(api: {}): boolean; + toImplement(api: {}): boolean; - toStartWith(subString: string): boolean; + toStartWith(subString: string): boolean; - toThrowAnyError(): boolean; - toThrowErrorOfType(type: string): boolean; - } + toThrowAnyError(): boolean; + toThrowErrorOfType(type: string): boolean; + } } From b0131162f16e4aaad5f8ebdee592059f73cdb736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Ewerl=C3=B6f?= Date: Mon, 23 Nov 2015 19:44:01 +0100 Subject: [PATCH 08/10] fixed copyright formattings --- .../jamiemason-jasmine-matchers.d.ts | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/jasmine-matchers/jamiemason-jasmine-matchers.d.ts b/jasmine-matchers/jamiemason-jasmine-matchers.d.ts index 91b473a58..318a30917 100644 --- a/jasmine-matchers/jamiemason-jasmine-matchers.d.ts +++ b/jasmine-matchers/jamiemason-jasmine-matchers.d.ts @@ -3,22 +3,6 @@ // Definitions by: UserPixel // Definitions: https://github.com/borisyankov/DefinitelyTyped -/* -Typings 2015 UserPixel - -TypeScript tests auto-extracted from jasmine-matchers unit test. - -Original jasmine-matchers license applies: - -Copyright (C) 2013, uxebu Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - /// declare module jasmine { From c9203f8fdf5362b0ec24c6402060259ffda873f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Ewerl=C3=B6f?= Date: Mon, 23 Nov 2015 19:49:29 +0100 Subject: [PATCH 09/10] moved the files to jasmine-expect directory --- .../jasmine-expect-tests.ts | 0 .../jasmine-expect.d.ts | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename jasmine-matchers/jamiemason-jasmine-matchers-tests.ts => jasmine-expect/jasmine-expect-tests.ts (100%) rename jasmine-matchers/jamiemason-jasmine-matchers.d.ts => jasmine-expect/jasmine-expect.d.ts (100%) diff --git a/jasmine-matchers/jamiemason-jasmine-matchers-tests.ts b/jasmine-expect/jasmine-expect-tests.ts similarity index 100% rename from jasmine-matchers/jamiemason-jasmine-matchers-tests.ts rename to jasmine-expect/jasmine-expect-tests.ts diff --git a/jasmine-matchers/jamiemason-jasmine-matchers.d.ts b/jasmine-expect/jasmine-expect.d.ts similarity index 100% rename from jasmine-matchers/jamiemason-jasmine-matchers.d.ts rename to jasmine-expect/jasmine-expect.d.ts From 9d5078123140734d09aab2d9dbd672bdc579ae17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Ewerl=C3=B6f?= Date: Mon, 23 Nov 2015 19:50:50 +0100 Subject: [PATCH 10/10] updated the headers and file references --- jasmine-expect/jasmine-expect-tests.ts | 2 +- jasmine-expect/jasmine-expect.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jasmine-expect/jasmine-expect-tests.ts b/jasmine-expect/jasmine-expect-tests.ts index cd4914339..ec54269f4 100644 --- a/jasmine-expect/jasmine-expect-tests.ts +++ b/jasmine-expect/jasmine-expect-tests.ts @@ -1,5 +1,5 @@ /// -/// +/// // Taken directly from the test directory of the original repo diff --git a/jasmine-expect/jasmine-expect.d.ts b/jasmine-expect/jasmine-expect.d.ts index 318a30917..fe6238078 100644 --- a/jasmine-expect/jasmine-expect.d.ts +++ b/jasmine-expect/jasmine-expect.d.ts @@ -1,4 +1,4 @@ -// Type definitions for jasmine-matchers 2.0.0-beta2 +// Type definitions for jasmine-expect 2.0.0-beta2 // Project: https://github.com/JamieMason/Jasmine-Matchers // Definitions by: UserPixel // Definitions: https://github.com/borisyankov/DefinitelyTyped