From 2e331f9d05116e02b3839a90dcd05db10beaa00f Mon Sep 17 00:00:00 2001 From: wtgtybhertgeghgtwtg Date: Sun, 10 Jun 2018 16:17:08 -0700 Subject: [PATCH] chore: update repo structure --- __tests__/getCertain.test.js | 5 +- .../npm/{jest_v22.x.x.js => jest_v23.x.x.js} | 387 +++++++++++++++++- package.json | 15 +- renovate.json | 3 + scripts/build.js | 15 - 5 files changed, 387 insertions(+), 38 deletions(-) rename flow-typed/npm/{jest_v22.x.x.js => jest_v23.x.x.js} (65%) delete mode 100644 scripts/build.js diff --git a/__tests__/getCertain.test.js b/__tests__/getCertain.test.js index 496b486..d82bf11 100644 --- a/__tests__/getCertain.test.js +++ b/__tests__/getCertain.test.js @@ -1,15 +1,18 @@ -// flow +// @flow import getCertain from '../src'; describe('getCertain', () => { describe('invariants', () => { it('throws if "map" is undefined.', () => { + // $FlowFixMe expect(() => getCertain()).toThrow('"map" must be a Map.'); }); it('throws if "map" is not a Map-like object.', () => { + // $FlowFixMe expect(() => getCertain({has: 3})).toThrow('"map" must be a Map.'); }); it('throws if "message" is not a string or undefined.', () => { + // $FlowFixMe expect(() => getCertain(new Map(), 1, 1)).toThrow( '"message" must be a string or undefined.', ); diff --git a/flow-typed/npm/jest_v22.x.x.js b/flow-typed/npm/jest_v23.x.x.js similarity index 65% rename from flow-typed/npm/jest_v22.x.x.js rename to flow-typed/npm/jest_v23.x.x.js index d91f48e..653840a 100644 --- a/flow-typed/npm/jest_v22.x.x.js +++ b/flow-typed/npm/jest_v23.x.x.js @@ -1,5 +1,5 @@ -// flow-typed signature: 17c6ca97e1e560b9bc0d3400f8b2882f -// flow-typed version: a5bbe16c29/jest_v22.x.x/flow_>=v0.39.x +// flow-typed signature: bc9e644ba43fa1c4d1fccc5fd47f65e9 +// flow-typed version: d37e775f89/jest_v23.x.x/flow_>=v0.39.x type JestMockFn, TReturn> = { (...args: TArguments): TReturn, @@ -156,8 +156,335 @@ type DomTestingLibraryType = { toHaveAttribute(name: string, expectedValue?: string): void }; -type JestExpectType = { - not: JestExpectType & EnzymeMatchersType & DomTestingLibraryType, +// Jest JQuery Matchers: https://github.com/unindented/custom-jquery-matchers +type JestJQueryMatchersType = { + toExist(): void, + toHaveLength(len: number): void, + toHaveId(id: string): void, + toHaveClass(className: string): void, + toHaveTag(tag: string): void, + toHaveAttr(key: string, val?: any): void, + toHaveProp(key: string, val?: any): void, + toHaveText(text: string | RegExp): void, + toHaveData(key: string, val?: any): void, + toHaveValue(val: any): void, + toHaveCss(css: {[key: string]: any}): void, + toBeChecked(): void, + toBeDisabled(): void, + toBeEmpty(): void, + toBeHidden(): void, + toBeSelected(): void, + toBeVisible(): void, + toBeFocused(): void, + toBeInDom(): void, + toBeMatchedBy(sel: string): void, + toHaveDescendant(sel: string): void, + toHaveDescendantWithText(sel: string, text: string | RegExp): void +}; + + +// Jest Extended Matchers: https://github.com/jest-community/jest-extended +type JestExtendedMatchersType = { + /** + * Note: Currently unimplemented + * Passing assertion + * + * @param {String} message + */ + // pass(message: string): void; + + /** + * Note: Currently unimplemented + * Failing assertion + * + * @param {String} message + */ + // fail(message: string): void; + + /** + * Use .toBeEmpty when checking if a String '', Array [] or Object {} is empty. + */ + toBeEmpty(): void; + + /** + * Use .toBeOneOf when checking if a value is a member of a given Array. + * @param {Array.<*>} members + */ + toBeOneOf(members: any[]): void; + + /** + * Use `.toBeNil` when checking a value is `null` or `undefined`. + */ + toBeNil(): void; + + /** + * Use `.toSatisfy` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean`. + * @param {Function} predicate + */ + toSatisfy(predicate: (n: any) => boolean): void; + + /** + * Use `.toBeArray` when checking if a value is an `Array`. + */ + toBeArray(): void; + + /** + * Use `.toBeArrayOfSize` when checking if a value is an `Array` of size x. + * @param {Number} x + */ + toBeArrayOfSize(x: number): void; + + /** + * Use `.toIncludeAllMembers` when checking if an `Array` contains all of the same members of a given set. + * @param {Array.<*>} members + */ + toIncludeAllMembers(members: any[]): void; + + /** + * Use `.toIncludeAnyMembers` when checking if an `Array` contains any of the members of a given set. + * @param {Array.<*>} members + */ + toIncludeAnyMembers(members: any[]): void; + + /** + * Use `.toSatisfyAll` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean` for all values in an array. + * @param {Function} predicate + */ + toSatisfyAll(predicate: (n: any) => boolean): void; + + /** + * Use `.toBeBoolean` when checking if a value is a `Boolean`. + */ + toBeBoolean(): void; + + /** + * Use `.toBeTrue` when checking a value is equal (===) to `true`. + */ + toBeTrue(): void; + + /** + * Use `.toBeFalse` when checking a value is equal (===) to `false`. + */ + toBeFalse(): void; + + /** + * Use .toBeDate when checking if a value is a Date. + */ + toBeDate(): void; + + /** + * Use `.toBeFunction` when checking if a value is a `Function`. + */ + toBeFunction(): void; + + /** + * Use `.toHaveBeenCalledBefore` when checking if a `Mock` was called before another `Mock`. + * + * Note: Required Jest version >22 + * Note: Your mock functions will have to be asynchronous to cause the timestamps inside of Jest to occur in a differentJS event loop, otherwise the mock timestamps will all be the same + * + * @param {Mock} mock + */ + toHaveBeenCalledBefore(mock: JestMockFn): void; + + /** + * Use `.toBeNumber` when checking if a value is a `Number`. + */ + toBeNumber(): void; + + /** + * Use `.toBeNaN` when checking a value is `NaN`. + */ + toBeNaN(): void; + + /** + * Use `.toBeFinite` when checking if a value is a `Number`, not `NaN` or `Infinity`. + */ + toBeFinite(): void; + + /** + * Use `.toBePositive` when checking if a value is a positive `Number`. + */ + toBePositive(): void; + + /** + * Use `.toBeNegative` when checking if a value is a negative `Number`. + */ + toBeNegative(): void; + + /** + * Use `.toBeEven` when checking if a value is an even `Number`. + */ + toBeEven(): void; + + /** + * Use `.toBeOdd` when checking if a value is an odd `Number`. + */ + toBeOdd(): void; + + /** + * Use `.toBeWithin` when checking if a number is in between the given bounds of: start (inclusive) and end (exclusive). + * + * @param {Number} start + * @param {Number} end + */ + toBeWithin(start: number, end: number): void; + + /** + * Use `.toBeObject` when checking if a value is an `Object`. + */ + toBeObject(): void; + + /** + * Use `.toContainKey` when checking if an object contains the provided key. + * + * @param {String} key + */ + toContainKey(key: string): void; + + /** + * Use `.toContainKeys` when checking if an object has all of the provided keys. + * + * @param {Array.} keys + */ + toContainKeys(keys: string[]): void; + + /** + * Use `.toContainAllKeys` when checking if an object only contains all of the provided keys. + * + * @param {Array.} keys + */ + toContainAllKeys(keys: string[]): void; + + /** + * Use `.toContainAnyKeys` when checking if an object contains at least one of the provided keys. + * + * @param {Array.} keys + */ + toContainAnyKeys(keys: string[]): void; + + /** + * Use `.toContainValue` when checking if an object contains the provided value. + * + * @param {*} value + */ + toContainValue(value: any): void; + + /** + * Use `.toContainValues` when checking if an object contains all of the provided values. + * + * @param {Array.<*>} values + */ + toContainValues(values: any[]): void; + + /** + * Use `.toContainAllValues` when checking if an object only contains all of the provided values. + * + * @param {Array.<*>} values + */ + toContainAllValues(values: any[]): void; + + /** + * Use `.toContainAnyValues` when checking if an object contains at least one of the provided values. + * + * @param {Array.<*>} values + */ + toContainAnyValues(values: any[]): void; + + /** + * Use `.toContainEntry` when checking if an object contains the provided entry. + * + * @param {Array.} entry + */ + toContainEntry(entry: [string, string]): void; + + /** + * Use `.toContainEntries` when checking if an object contains all of the provided entries. + * + * @param {Array.>} entries + */ + toContainEntries(entries: [string, string][]): void; + + /** + * Use `.toContainAllEntries` when checking if an object only contains all of the provided entries. + * + * @param {Array.>} entries + */ + toContainAllEntries(entries: [string, string][]): void; + + /** + * Use `.toContainAnyEntries` when checking if an object contains at least one of the provided entries. + * + * @param {Array.>} entries + */ + toContainAnyEntries(entries: [string, string][]): void; + + /** + * Use `.toBeExtensible` when checking if an object is extensible. + */ + toBeExtensible(): void; + + /** + * Use `.toBeFrozen` when checking if an object is frozen. + */ + toBeFrozen(): void; + + /** + * Use `.toBeSealed` when checking if an object is sealed. + */ + toBeSealed(): void; + + /** + * Use `.toBeString` when checking if a value is a `String`. + */ + toBeString(): void; + + /** + * Use `.toEqualCaseInsensitive` when checking if a string is equal (===) to another ignoring the casing of both strings. + * + * @param {String} string + */ + toEqualCaseInsensitive(string: string): void; + + /** + * Use `.toStartWith` when checking if a `String` starts with a given `String` prefix. + * + * @param {String} prefix + */ + toStartWith(prefix: string): void; + + /** + * Use `.toEndWith` when checking if a `String` ends with a given `String` suffix. + * + * @param {String} suffix + */ + toEndWith(suffix: string): void; + + /** + * Use `.toInclude` when checking if a `String` includes the given `String` substring. + * + * @param {String} substring + */ + toInclude(substring: string): void; + + /** + * Use `.toIncludeRepeated` when checking if a `String` includes the given `String` substring the correct number of times. + * + * @param {String} substring + * @param {Number} times + */ + toIncludeRepeated(substring: string, times: number): void; + + /** + * Use `.toIncludeMultiple` when checking if a `String` includes all of the given substrings. + * + * @param {Array.} substring + */ + toIncludeMultiple(substring: string[]): void; +}; + +interface JestExpectType { + not: JestExpectType & EnzymeMatchersType & DomTestingLibraryType & JestJQueryMatchersType & JestExtendedMatchersType, /** * If you have a mock function, you can use .lastCalledWith to test what * arguments it was last called with. @@ -168,10 +495,6 @@ type JestExpectType = { * strict equality. */ toBe(value: any): void, - /** - * Use .toHaveBeenCalled to ensure that a mock function got called. - */ - toBeCalled(): void, /** * Use .toBeCalledWith to ensure that a mock function was called with * specific arguments. @@ -247,21 +570,55 @@ type JestExpectType = { * Use .toHaveBeenCalled to ensure that a mock function got called. */ toHaveBeenCalled(): void, + toBeCalled(): void; /** * Use .toHaveBeenCalledTimes to ensure that a mock function got called exact * number of times. */ toHaveBeenCalledTimes(number: number): void, + toBeCalledTimes(number: number): void; + /** + * + */ + toHaveBeenNthCalledWith(nthCall: number, ...args: Array): void; + nthCalledWith(nthCall: number, ...args: Array): void; + /** + * + */ + toHaveReturned(): void; + toReturn(): void; + /** + * + */ + toHaveReturnedTimes(number: number): void; + toReturnTimes(number: number): void; + /** + * + */ + toHaveReturnedWith(value: any): void; + toReturnWith(value: any): void; + /** + * + */ + toHaveLastReturnedWith(value: any): void; + lastReturnedWith(value: any): void; + /** + * + */ + toHaveNthReturnedWith(nthCall: number, value: any): void; + nthReturnedWith(nthCall: number, value: any): void; /** * Use .toHaveBeenCalledWith to ensure that a mock function was called with * specific arguments. */ toHaveBeenCalledWith(...args: Array): void, + toBeCalledWith(...args: Array): void, /** * Use .toHaveBeenLastCalledWith to ensure that a mock function was last called * with specific arguments. */ toHaveBeenLastCalledWith(...args: Array): void, + lastCalledWith(...args: Array): void, /** * Check that an object has a .length property and it is set to a certain * numeric value. @@ -280,9 +637,13 @@ type JestExpectType = { */ toMatchObject(object: Object | Array): void, /** - * This ensures that a React component matches the most recent snapshot. + * This ensures that an Object matches the most recent snapshot. */ - toMatchSnapshot(name?: string): void, + toMatchSnapshot(propertyMatchers?: {[key: string]: JestAsymmetricEqualityType}, name?: string): void, + /** + * This ensures that an Object matches the most recent snapshot. + */ + toMatchSnapshot(name: string): void, /** * Use .toThrow to test that a function throws when it is called. * If you want to test that a specific error gets thrown, you can provide an @@ -298,7 +659,7 @@ type JestExpectType = { * matching the most recent snapshot when it is called. */ toThrowErrorMatchingSnapshot(): void -}; +} type JestObjectType = { /** @@ -451,7 +812,7 @@ type JestObjectType = { * Creates a mock function similar to jest.fn but also tracks calls to * object[methodName]. */ - spyOn(object: Object, methodName: string): JestMockFn, + spyOn(object: Object, methodName: string, accessType?: "get" | "set"): JestMockFn, /** * Set the default timeout interval for tests and before/after hooks in milliseconds. * Note: The default timeout interval is 5 seconds if this method is not called. @@ -618,7 +979,7 @@ type JestPrettyFormatPlugins = Array; /** The expect function is used every time you want to test a value */ declare var expect: { /** The object that you want to make assertions against */ - (value: any): JestExpectType & JestPromiseType & EnzymeMatchersType & DomTestingLibraryType, + (value: any): JestExpectType & JestPromiseType & EnzymeMatchersType & DomTestingLibraryType & JestJQueryMatchersType & JestExtendedMatchersType, /** Add additional Jasmine matchers to Jest's roster */ extend(matchers: { [name: string]: JestMatcher }): void, /** Add a module that formats application-specific data structures. */ diff --git a/package.json b/package.json index 0ddab57..3d30b81 100644 --- a/package.json +++ b/package.json @@ -11,15 +11,15 @@ }, "description": "Assert a Map has a given key and return the value for it.", "devDependencies": { - "@babel/core": "^7.0.0-beta.44", - "@babel/preset-env": "^7.0.0-beta.44", - "@babel/preset-flow": "^7.0.0-beta.44", + "@babel/core": "^7.0.0-beta.46", + "@babel/preset-env": "^7.0.0-beta.46", + "@babel/preset-flow": "^7.0.0-beta.46", "@commitlint/cli": "^7.0.0", "@commitlint/config-conventional": "^7.0.0", + "@wtg/scripts": "^1.1.2", "babel-core": "7.0.0-bridge.0", "babel-eslint": "^8.2.3", "babel-jest": "^23.0.0", - "builtin-modules": "^2.0.0", "eslint": "^4.19.1", "eslint-config-airbnb-base": "^12.1.0", "eslint-config-prettier": "^2.9.0", @@ -30,10 +30,7 @@ "jest": "^23.0.0", "lint-staged": "^7.0.4", "prettier": "1.13.5", - "rimraf": "^2.6.2", - "rollup": "^0.58.1", - "rollup-plugin-babel": "^4.0.0-beta.4", - "write": "^1.0.3" + "rimraf": "^2.6.2" }, "engines": { "node": ">=6" @@ -51,7 +48,7 @@ "url": "https://github.com/wtgtybhertgeghgtwtg/get-certain" }, "scripts": { - "build": "node scripts/build", + "build": "wtg build", "clean": "rimraf coverage dist", "lint": "flow && eslint . && prettier --l \"{__tests__,src}/**/*.js\"", "test": "yarn test:src && yarn build && yarn test:dist", diff --git a/renovate.json b/renovate.json index 2047292..18dddee 100644 --- a/renovate.json +++ b/renovate.json @@ -1,4 +1,7 @@ { "extends": ["config:base", "docker:disable"], + "devDependencies": { + "automerge": true + }, "pinVersions": false } diff --git a/scripts/build.js b/scripts/build.js deleted file mode 100644 index 24b49e2..0000000 --- a/scripts/build.js +++ /dev/null @@ -1,15 +0,0 @@ -const builtinModules = require('builtin-modules'); -const {rollup} = require('rollup'); -const babel = require('rollup-plugin-babel'); -const write = require('write'); -const pkg = require('../package.json'); - -rollup({ - external: [...builtinModules, ...Object.keys(pkg.dependencies)], - input: 'src/index.js', - plugins: [babel()], -}).then(async bundle => { - await bundle.write({file: pkg.main, format: 'cjs', sourcemap: true}); - await write(`${pkg.main}.flow`, "// @flow\nexport * from '../src';"); - await bundle.write({file: pkg.module, format: 'es', sourcemap: true}); -});