Skip to content

Commit

Permalink
Fix rollup build by using export for jest-matchers
Browse files Browse the repository at this point in the history
  • Loading branch information
skovhus committed Jun 27, 2017
1 parent 4f09124 commit 411c89e
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 47 deletions.
18 changes: 10 additions & 8 deletions packages/jest-matchers/src/asymmetric_matchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,13 @@ class StringMatching extends AsymmetricMatcher {
}
}

module.exports = {
any: (expectedObject: any) => new Any(expectedObject),
anything: () => new Anything(),
arrayContaining: (sample: Array<any>) => new ArrayContaining(sample),
objectContaining: (sample: Object) => new ObjectContaining(sample),
stringContaining: (expected: string) => new StringContaining(expected),
stringMatching: (expected: string | RegExp) => new StringMatching(expected),
};
export const any = (expectedObject: any) => new Any(expectedObject);
export const anything = () => new Anything();
export const arrayContaining = (sample: Array<any>) =>
new ArrayContaining(sample);
export const objectContaining = (sample: Object) =>
new ObjectContaining(sample);
export const stringContaining = (expected: string) =>
new StringContaining(expected);
export const stringMatching = (expected: string | RegExp) =>
new StringMatching(expected);
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ const extractExpectedAssertionsErrors = () => {
return result;
};

module.exports = extractExpectedAssertionsErrors;
export default extractExpectedAssertionsErrors;
18 changes: 5 additions & 13 deletions packages/jest-matchers/src/jasmine_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
type Tester = (a: any, b: any) => boolean | typeof undefined;

// Extracted out of jasmine 2.5.2
function equals(a: any, b: any, customTesters?: Array<Tester>): boolean {
export function equals(a: any, b: any, customTesters?: Array<Tester>): boolean {
customTesters = customTesters || [];
return eq(a, b, [], [], customTesters);
}
Expand Down Expand Up @@ -229,15 +229,15 @@ function has(obj, key) {
);
}

function isA(typeName: string, value: any) {
export function isA(typeName: string, value: any) {
return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
}

function isDomNode(obj) {
return obj.nodeType > 0;
}

function fnNameFor(func: Function) {
export function fnNameFor(func: Function) {
if (func.name) {
return func.name;
}
Expand All @@ -246,7 +246,7 @@ function fnNameFor(func: Function) {
return matches ? matches[1] : '<anonymous>';
}

function isUndefined(obj: any) {
export function isUndefined(obj: any) {
return obj === void 0;
}

Expand All @@ -262,7 +262,7 @@ function getPrototype(obj) {
return obj.constructor.prototype;
}

function hasProperty(obj: Object | null, property: string) {
export function hasProperty(obj: Object | null, property: string) {
if (!obj) {
return false;
}
Expand All @@ -273,11 +273,3 @@ function hasProperty(obj: Object | null, property: string) {

return hasProperty(getPrototype(obj), property);
}

module.exports = {
equals,
fnNameFor,
hasProperty,
isA,
isUndefined,
};
15 changes: 4 additions & 11 deletions packages/jest-matchers/src/jest_matchers_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,14 @@ if (!global[JEST_MATCHERS_OBJECT]) {
});
}

const getState = () => global[JEST_MATCHERS_OBJECT].state;
export const getState = () => global[JEST_MATCHERS_OBJECT].state;

const setState = (state: Object) => {
export const setState = (state: Object) => {
Object.assign(global[JEST_MATCHERS_OBJECT].state, state);
};

const getMatchers = () => global[JEST_MATCHERS_OBJECT].matchers;
export const getMatchers = () => global[JEST_MATCHERS_OBJECT].matchers;

const setMatchers = (matchers: MatchersObject) => {
export const setMatchers = (matchers: MatchersObject) => {
Object.assign(global[JEST_MATCHERS_OBJECT].matchers, matchers);
};

module.exports = {
getMatchers,
getState,
setMatchers,
setState,
};
2 changes: 1 addition & 1 deletion packages/jest-matchers/src/matchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,4 +654,4 @@ const matchers: MatchersObject = {
},
};

module.exports = matchers;
export default matchers;
2 changes: 1 addition & 1 deletion packages/jest-matchers/src/spy_matchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,4 @@ const formatReceivedCalls = (calls, limit, options) => {
}
};

module.exports = spyMatchers;
export default spyMatchers;
2 changes: 1 addition & 1 deletion packages/jest-matchers/src/to_throw_matchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,4 @@ const printActualErrorMessage = error => {
return `But it didn't throw anything.`;
};

module.exports = matchers;
export default matchers;
15 changes: 4 additions & 11 deletions packages/jest-matchers/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ type GetPath = {
value?: any,
};

const hasOwnProperty = (object: Object, value: string) =>
export const hasOwnProperty = (object: Object, value: string) =>
Object.prototype.hasOwnProperty.call(object, value);

const getPath = (
export const getPath = (
object: Object,
propertyPath: string | Array<string>,
): GetPath => {
Expand Down Expand Up @@ -66,7 +66,7 @@ const getPath = (

// Strip properties from object that are not present in the subset. Useful for
// printing the diff for toMatchObject() without adding unrelated noise.
const getObjectSubset = (object: Object, subset: Object) => {
export const getObjectSubset = (object: Object, subset: Object) => {
if (Array.isArray(object)) {
if (Array.isArray(subset) && subset.length === object.length) {
return subset.map((sub, i) => getObjectSubset(object[i], sub));
Expand Down Expand Up @@ -96,7 +96,7 @@ const getObjectSubset = (object: Object, subset: Object) => {
const IteratorSymbol = Symbol.iterator;

const hasIterator = object => !!(object != null && object[IteratorSymbol]);
const iterableEquality = (a: any, b: any) => {
export const iterableEquality = (a: any, b: any) => {
if (
typeof a !== 'object' ||
typeof b !== 'object' ||
Expand All @@ -123,10 +123,3 @@ const iterableEquality = (a: any, b: any) => {
}
return true;
};

module.exports = {
getObjectSubset,
getPath,
hasOwnProperty,
iterableEquality,
};

0 comments on commit 411c89e

Please sign in to comment.