diff --git a/.github/README_CONTENT.md b/.github/README_CONTENT.md index 4c388f5..bacb716 100644 --- a/.github/README_CONTENT.md +++ b/.github/README_CONTENT.md @@ -50,24 +50,38 @@ The [Jasmine testing framework](http://jasmine.github.io/) from [default set of matchers](http://jasmine.github.io/edge/introduction.html#section-Expectations): ```js -expect(instance).toBe(instance); -expect(number).toBeCloseTo(number, decimalPlaces); -expect(mixed).toBeDefined(); -expect(mixed).toBeFalsy(); -expect(number).toBeGreaterThan(number); -expect(number).toBeLessThan(number); -expect(number).toBeNaN(); -expect(mixed).toBeNull(); -expect(mixed).toBeTruthy(); -expect(mixed).toBeUndefined(); -expect(array).toContain(member); -expect(mixed).toEqual(mixed); -expect(spy).toHaveBeenCalled(); -expect(spy).toHaveBeenCalledTimes(number); -expect(spy).toHaveBeenCalledWith(...arguments); -expect(mixed).toMatch(pattern); -expect(fn).toThrow(string); -expect(fn).toThrowError(string); +expect().nothing() +expect().toBe(expected) +expect().toBeCloseTo(expected, precisionopt) +expect().toBeDefined() +expect().toBeFalse() +expect().toBeFalsy() +expect().toBeGreaterThan(expected) +expect().toBeGreaterThanOrEqual(expected) +expect().toBeInstanceOf(expected) +expect().toBeLessThan(expected) +expect().toBeLessThanOrEqual(expected) +expect().toBeNaN() +expect().toBeNegativeInfinity() +expect().toBeNull() +expect().toBePositiveInfinity() +expect().toBeTrue() +expect().toBeTruthy() +expect().toBeUndefined() +expect().toContain(expected) +expect().toEqual(expected) +expect().toHaveBeenCalled() +expect().toHaveBeenCalledBefore(expected) +expect().toHaveBeenCalledOnceWith() +expect().toHaveBeenCalledTimes(expected) +expect().toHaveBeenCalledWith() +expect().toHaveClass(expected) +expect().toHaveSize(expected) +expect().toMatch(expected) +expect().toThrow(expectedopt) +expect().toThrowError(expectedopt, messageopt) +expect().toThrowMatching(predicate) +expect().withContext(message) ``` and this @@ -96,8 +110,6 @@ expect(array).toBeArrayOfStrings(); expect(array).toBeEmptyArray(); expect(array).toBeNonEmptyArray(); expect(boolean).toBeBoolean(); -expect(boolean).toBeFalse(); -expect(boolean).toBeTrue(); expect(date).toBeAfter(otherDate); expect(date).toBeBefore(otherDate); expect(date).toBeDate(); diff --git a/README.md b/README.md index 3ed208a..045274a 100644 --- a/README.md +++ b/README.md @@ -54,24 +54,38 @@ Downloads are available on the [releases](https://github.com/JamieMason/Jasmine- The [Jasmine testing framework](http://jasmine.github.io/) from [Pivotal Labs](http://pivotallabs.com/) comes with this [default set of matchers](http://jasmine.github.io/edge/introduction.html#section-Expectations): ```js -expect(instance).toBe(instance); -expect(number).toBeCloseTo(number, decimalPlaces); -expect(mixed).toBeDefined(); -expect(mixed).toBeFalsy(); -expect(number).toBeGreaterThan(number); -expect(number).toBeLessThan(number); -expect(number).toBeNaN(); -expect(mixed).toBeNull(); -expect(mixed).toBeTruthy(); -expect(mixed).toBeUndefined(); -expect(array).toContain(member); -expect(mixed).toEqual(mixed); -expect(spy).toHaveBeenCalled(); -expect(spy).toHaveBeenCalledTimes(number); -expect(spy).toHaveBeenCalledWith(...arguments); -expect(mixed).toMatch(pattern); -expect(fn).toThrow(string); -expect(fn).toThrowError(string); +expect().nothing() +expect().toBe(expected) +expect().toBeCloseTo(expected, precisionopt) +expect().toBeDefined() +expect().toBeFalse() +expect().toBeFalsy() +expect().toBeGreaterThan(expected) +expect().toBeGreaterThanOrEqual(expected) +expect().toBeInstanceOf(expected) +expect().toBeLessThan(expected) +expect().toBeLessThanOrEqual(expected) +expect().toBeNaN() +expect().toBeNegativeInfinity() +expect().toBeNull() +expect().toBePositiveInfinity() +expect().toBeTrue() +expect().toBeTruthy() +expect().toBeUndefined() +expect().toContain(expected) +expect().toEqual(expected) +expect().toHaveBeenCalled() +expect().toHaveBeenCalledBefore(expected) +expect().toHaveBeenCalledOnceWith() +expect().toHaveBeenCalledTimes(expected) +expect().toHaveBeenCalledWith() +expect().toHaveClass(expected) +expect().toHaveSize(expected) +expect().toMatch(expected) +expect().toThrow(expectedopt) +expect().toThrowError(expectedopt, messageopt) +expect().toThrowMatching(predicate) +expect().withContext(message) ``` and this [default set of asymmetric matchers](http://jasmine.github.io/2.4/introduction.html#section-Matching_Anything_with_%3Ccode%3Ejasmine.any%3C/code%3E); @@ -98,8 +112,6 @@ expect(array).toBeArrayOfStrings(); expect(array).toBeEmptyArray(); expect(array).toBeNonEmptyArray(); expect(boolean).toBeBoolean(); -expect(boolean).toBeFalse(); -expect(boolean).toBeTrue(); expect(date).toBeAfter(otherDate); expect(date).toBeBefore(otherDate); expect(date).toBeDate(); diff --git a/src/matchersByName.ts b/src/matchersByName.ts index 60a5125..19a23f2 100644 --- a/src/matchersByName.ts +++ b/src/matchersByName.ts @@ -13,7 +13,6 @@ export { toBeEmptyArray } from './toBeEmptyArray'; export { toBeEmptyObject } from './toBeEmptyObject'; export { toBeEmptyString } from './toBeEmptyString'; export { toBeEvenNumber } from './toBeEvenNumber'; -export { toBeFalse } from './toBeFalse'; export { toBeFunction } from './toBeFunction'; export { toBeGreaterThanOrEqualTo } from './toBeGreaterThanOrEqualTo'; export { toBeHtmlString } from './toBeHtmlString'; @@ -32,7 +31,6 @@ export { toBeRegExp } from './toBeRegExp'; export { toBeSameLengthAs } from './toBeSameLengthAs'; export { toBeShorterThan } from './toBeShorterThan'; export { toBeString } from './toBeString'; -export { toBeTrue } from './toBeTrue'; export { toBeValidDate } from './toBeValidDate'; export { toBeWhitespace } from './toBeWhitespace'; export { toBeWholeNumber } from './toBeWholeNumber'; @@ -53,7 +51,6 @@ export { toHaveEmptyArray } from './toHaveEmptyArray'; export { toHaveEmptyObject } from './toHaveEmptyObject'; export { toHaveEmptyString } from './toHaveEmptyString'; export { toHaveEvenNumber } from './toHaveEvenNumber'; -export { toHaveFalse } from './toHaveFalse'; export { toHaveHtmlString } from './toHaveHtmlString'; export { toHaveIso8601 } from './toHaveIso8601'; export { toHaveJsonString } from './toHaveJsonString'; @@ -70,7 +67,6 @@ export { toHaveString } from './toHaveString'; export { toHaveStringLongerThan } from './toHaveStringLongerThan'; export { toHaveStringSameLengthAs } from './toHaveStringSameLengthAs'; export { toHaveStringShorterThan } from './toHaveStringShorterThan'; -export { toHaveTrue } from './toHaveTrue'; export { toHaveUndefined } from './toHaveUndefined'; export { toHaveWhitespaceString } from './toHaveWhitespaceString'; export { toHaveWholeNumber } from './toHaveWholeNumber'; diff --git a/src/toBeFalse.ts b/src/toBeFalse.ts deleted file mode 100644 index 2f1f844..0000000 --- a/src/toBeFalse.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { is } from './lib/is'; - -export type ToBeFalse = (expectationFailOutput?: any) => boolean; - -declare global { - namespace jasmine { - interface Matchers { - toBeFalse: ToBeFalse; - } - } -} - -export const toBeFalse: ToBeFalse = (actual) => - actual === false || is.False(actual); diff --git a/src/toBeTrue.ts b/src/toBeTrue.ts deleted file mode 100644 index be5d52d..0000000 --- a/src/toBeTrue.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { is } from './lib/is'; - -export type ToBeTrue = (expectationFailOutput?: any) => boolean; - -declare global { - namespace jasmine { - interface Matchers { - toBeTrue: ToBeTrue; - } - } -} - -export const toBeTrue: ToBeTrue = (actual) => - actual === true || is.True(actual); diff --git a/src/toHaveFalse.ts b/src/toHaveFalse.ts deleted file mode 100644 index 2f23ea8..0000000 --- a/src/toHaveFalse.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { memberMatcherFor } from './lib/memberMatcherFor'; -import { toBeFalse } from './toBeFalse'; - -export type ToHaveFalse = (key: string, expectationFailOutput?: any) => boolean; - -declare global { - namespace jasmine { - interface Matchers { - toHaveFalse: ToHaveFalse; - } - } -} - -export const toHaveFalse: ToHaveFalse = memberMatcherFor(toBeFalse); diff --git a/src/toHaveTrue.ts b/src/toHaveTrue.ts deleted file mode 100644 index 4d2c026..0000000 --- a/src/toHaveTrue.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { memberMatcherFor } from './lib/memberMatcherFor'; -import { toBeTrue } from './toBeTrue'; - -export type ToHaveTrue = (key: string, expectationFailOutput?: any) => boolean; - -declare global { - namespace jasmine { - interface Matchers { - toHaveTrue: ToHaveTrue; - } - } -} - -export const toHaveTrue: ToHaveTrue = memberMatcherFor(toBeTrue); diff --git a/test/optionalMessages.spec.js b/test/optionalMessages.spec.js index 3c98506..5248d2a 100644 --- a/test/optionalMessages.spec.js +++ b/test/optionalMessages.spec.js @@ -18,7 +18,6 @@ it('should handle optional messages', () => { expect({}).toBeEmptyObject(MSG); expect('').toBeEmptyString(MSG); expect(2).toBeEvenNumber(MSG); - expect(false).toBeFalse(MSG); expect(() => {}).toBeFunction(MSG); expect('text').toBeHtmlString(MSG); expect('2013-07-08T07:29:15.863Z').toBeIso8601(MSG); @@ -35,7 +34,6 @@ it('should handle optional messages', () => { expect('ab').toBeSameLengthAs('ab', MSG); expect('ab').toBeShorterThan('abc', MSG); expect('').toBeString(MSG); - expect(true).toBeTrue(MSG); expect(new Date()).toBeValidDate(MSG); expect(' ').toBeWhitespace(MSG); expect(1).toBeWholeNumber(MSG); diff --git a/test/toBeFalse.spec.js b/test/toBeFalse.spec.js deleted file mode 100644 index 423c80e..0000000 --- a/test/toBeFalse.spec.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('toBeFalse', () => { - describe('when invoked', () => { - describe('when subject is not only falsy, but a boolean false', () => { - it('should confirm', () => { - expect(false).toBeFalse(); - expect(new Boolean(false)).toBeFalse(); - }); - }); - describe('when subject is falsy', () => { - it('should deny', () => { - expect(1).not.toBeFalse(); - }); - }); - }); -}); diff --git a/test/toBeTrue.spec.js b/test/toBeTrue.spec.js deleted file mode 100644 index b9d81d7..0000000 --- a/test/toBeTrue.spec.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('toBeTrue', () => { - describe('when invoked', () => { - describe('when subject is not only truthy, but a boolean true', () => { - it('should confirm', () => { - expect(true).toBeTrue(); - expect(new Boolean(true)).toBeTrue(); - }); - }); - describe('when subject is truthy', () => { - it('should deny', () => { - expect(1).not.toBeTrue(); - }); - }); - }); -}); diff --git a/test/toHaveFalse.spec.js b/test/toHaveFalse.spec.js deleted file mode 100644 index fd08137..0000000 --- a/test/toHaveFalse.spec.js +++ /dev/null @@ -1,38 +0,0 @@ -const describeToHaveBooleanX = require('./lib/describeToHaveBooleanX'); - -describe('toHaveFalse', () => { - describeToHaveBooleanX('toHaveFalse', () => { - describe('when primitive', () => { - describe('when true', () => { - it('should deny', () => { - expect({ - memberName: true - }).not.toHaveFalse('memberName'); - }); - }); - describe('when false', () => { - it('should confirm', () => { - expect({ - memberName: false - }).toHaveFalse('memberName'); - }); - }); - }); - describe('when Boolean object', () => { - describe('when true', () => { - it('should deny', () => { - expect({ - memberName: new Boolean(true) - }).not.toHaveFalse('memberName'); - }); - }); - describe('when false', () => { - it('should confirm', () => { - expect({ - memberName: new Boolean(false) - }).toHaveFalse('memberName'); - }); - }); - }); - }); -}); diff --git a/test/toHaveTrue.spec.js b/test/toHaveTrue.spec.js deleted file mode 100644 index 21d1407..0000000 --- a/test/toHaveTrue.spec.js +++ /dev/null @@ -1,38 +0,0 @@ -const describeToHaveBooleanX = require('./lib/describeToHaveBooleanX'); - -describe('toHaveTrue', () => { - describeToHaveBooleanX('toHaveTrue', () => { - describe('when primitive', () => { - describe('when true', () => { - it('should confirm', () => { - expect({ - memberName: true - }).toHaveTrue('memberName'); - }); - }); - describe('when false', () => { - it('should deny', () => { - expect({ - memberName: false - }).not.toHaveTrue('memberName'); - }); - }); - }); - describe('when Boolean object', () => { - describe('when true', () => { - it('should confirm', () => { - expect({ - memberName: new Boolean(true) - }).toHaveTrue('memberName'); - }); - }); - describe('when false', () => { - it('should deny', () => { - expect({ - memberName: new Boolean(false) - }).not.toHaveTrue('memberName'); - }); - }); - }); - }); -});