expect-type
Advanced tools
Comparing version 0.4.1-master-2020-03-06-00-05-12.11 to 0.4.1
@@ -6,2 +6,10 @@ # Change Log | ||
## [0.4.1](https://github.com/mmkal/ts/compare/expect-type@0.4.0...expect-type@0.4.1) (2020-03-06) | ||
**Note:** Version bump only for package expect-type | ||
# 0.4.0 (2020-03-05) | ||
@@ -8,0 +16,0 @@ |
export {}; | ||
//# sourceMappingURL=index.test.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const __1 = require(".."); | ||
test('Type-check object references', () => { | ||
it('tests types', () => { | ||
__1.expectTypeOf({ a: 1 }).toEqualTypeOf({ a: 1 }); | ||
__1.expectTypeOf({ a: 1, b: 1 }).toMatchTypeOf({ a: 1 }); | ||
__1.expectTypeOf({ a: 1 }).not.toMatchTypeOf({ b: 1 }); | ||
__1.expectTypeOf({ a: 1 }).toEqualTypeOf({ a: 2 }); | ||
}); | ||
test('Assertions can be inverted', () => { | ||
__1.expectTypeOf({ a: 1 }).not.toMatchTypeOf({ b: 1 }); | ||
}); | ||
test('Catch any/unknown/never types', () => { | ||
__1.expectTypeOf().toBeUnknown(); | ||
__1.expectTypeOf().toBeAny(); | ||
__1.expectTypeOf().toBeNever(); | ||
}); | ||
test('Test for basic javascript types', () => { | ||
__1.expectTypeOf(() => 1).toBeFunction(); | ||
@@ -26,4 +20,2 @@ __1.expectTypeOf({}).toBeObject(); | ||
__1.expectTypeOf(Symbol(1)).toBeSymbol(); | ||
}); | ||
test('Nullable types', () => { | ||
__1.expectTypeOf(undefined).toBeUndefined(); | ||
@@ -38,4 +30,2 @@ __1.expectTypeOf(undefined).toBeNullable(); | ||
__1.expectTypeOf().toBeNullable(); | ||
}); | ||
test('Assertions can be inverted with `.not`', () => { | ||
__1.expectTypeOf(1).not.toBeUnknown(); | ||
@@ -47,4 +37,2 @@ __1.expectTypeOf(1).not.toBeAny(); | ||
__1.expectTypeOf(1).not.toBeNullable(); | ||
}); | ||
test('Make assertions about object properties', () => { | ||
const obj = { a: 1, b: '' }; | ||
@@ -57,6 +45,5 @@ __1.expectTypeOf(obj) | ||
.toEqualTypeOf(); | ||
}); | ||
test('Assert on function parameters (using `.parameter(n)` or `.parameters`) and return values (using `.return`)', () => { | ||
const f = (a) => [a, a]; | ||
__1.expectTypeOf(f).toBeFunction(); | ||
__1.expectTypeOf('hi').not.toBeFunction(); | ||
__1.expectTypeOf(f).toBeCallableWith(1); | ||
@@ -78,12 +65,4 @@ __1.expectTypeOf(f).not.toBeAny(); | ||
__1.expectTypeOf(twoArgFunc).parameters.toEqualTypeOf(); | ||
}); | ||
test('Promise resolution types can be checked with `.resolves`', () => { | ||
const asyncFunc = async () => 123; | ||
__1.expectTypeOf(asyncFunc).returns.resolves.toBeNumber(); | ||
}); | ||
test('Array items can be checked with `.items`', () => { | ||
__1.expectTypeOf([1, 2, 3]).items.toBeNumber(); | ||
__1.expectTypeOf([1, 2, 3]).items.not.toBeString(); | ||
}); | ||
test('Check that functions never return', () => { | ||
const thrower = () => { | ||
@@ -93,4 +72,4 @@ throw Error(); | ||
__1.expectTypeOf(thrower).returns.toBeNever(); | ||
}); | ||
test('Generics can be used rather than references', () => { | ||
__1.expectTypeOf([1, 2, 3]).items.toBeNumber(); | ||
__1.expectTypeOf([1, 2, 3]).items.not.toBeString(); | ||
__1.expectTypeOf().not.toEqualTypeOf(); | ||
@@ -100,2 +79,40 @@ __1.expectTypeOf().not.toEqualTypeOf(); | ||
}); | ||
it('can do boolean type logic', () => { | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
__1.expectTypeOf().toEqualTypeOf(); | ||
}); | ||
//# sourceMappingURL=index.test.js.map |
@@ -42,16 +42,4 @@ export declare type Not<T extends boolean> = T extends true ? false : true; | ||
} | ||
/** | ||
* Similar to Jest's `expect`, but with type-awareness. | ||
* Gives you access to a number of type-matchers that let you make assertions about the | ||
* form of a reference or generic type parameter. | ||
* | ||
* @example | ||
* expectTypeOf({a: 1}).toMatchTypeOf({a: 2}) | ||
* expectTypeOf({a: 1}).property('a').toBeNumber() | ||
* | ||
* @description | ||
* See the [full docs](https://npmjs.com/package/expect-type#documentation) for lots more examples. | ||
*/ | ||
export declare const expectTypeOf: <Actual>(actual?: Actual | undefined) => ExpectTypeOf<Actual, true>; | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -5,14 +5,2 @@ "use strict"; | ||
const fn = () => true; | ||
/** | ||
* Similar to Jest's `expect`, but with type-awareness. | ||
* Gives you access to a number of type-matchers that let you make assertions about the | ||
* form of a reference or generic type parameter. | ||
* | ||
* @example | ||
* expectTypeOf({a: 1}).toMatchTypeOf({a: 2}) | ||
* expectTypeOf({a: 1}).property('a').toBeNumber() | ||
* | ||
* @description | ||
* See the [full docs](https://npmjs.com/package/expect-type#documentation) for lots more examples. | ||
*/ | ||
exports.expectTypeOf = (actual) => { | ||
@@ -19,0 +7,0 @@ const nonFunctionProperties = ['parameters', 'returns', 'resolves', 'not', 'items']; |
{ | ||
"name": "expect-type", | ||
"version": "0.4.1-master-2020-03-06-00-05-12.11+b7ba300", | ||
"version": "0.4.1", | ||
"repository": "https://github.com/mmkal/ts", | ||
@@ -16,3 +16,3 @@ "homepage": "https://github.com/mmkal/ts/tree/master/packages/expect-type#readme", | ||
}, | ||
"gitHead": "b7ba300cebbe6cf58dd989c404b9a6cfd757e748" | ||
"gitHead": "7ada63d995dad1d5077e8d60de725381a4ae4f4f" | ||
} |
@@ -0,0 +0,0 @@ # expect-type |
@@ -0,0 +0,0 @@ import * as a from '..' |
@@ -0,0 +0,0 @@ import {expectTypeOf} from '..' |
@@ -0,0 +0,0 @@ export type Not<T extends boolean> = T extends true ? false : true |
@@ -0,0 +0,0 @@ { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
0
188305
17
2909