expo-router
Version:
Expo Router is a file-based router for React Native and web applications.
66 lines (64 loc) • 2.65 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function printMatcherDiff(context, expected, received) {
if (context.isNot) {
return printMatcherValues(context, expected, received);
}
return context.utils.printDiffOrStringify(expected, received, 'Expected', 'Received', context.expand !== false);
}
function getMatcherHint(context, matcherName) {
return context.utils.matcherHint(matcherName, undefined, undefined, {
isNot: context.isNot,
promise: context.promise
});
}
function printMatcherValues(context, expected, received) {
return `Expected: ${context.isNot ? 'not ' : ''}${context.utils.printExpected(expected)}\n` + `Received: ${context.utils.printReceived(received)}`;
}
expect.extend({
toHavePathname (screen, expected) {
const received = screen.getPathname();
const pass = this.equals(received, expected);
return {
pass,
// Diffs add value for structured data, but are noise for short strings, so print raw values here.
message: ()=>getMatcherHint(this, 'toHavePathname') + '\n\n' + printMatcherValues(this, expected, received)
};
},
toHavePathnameWithParams (screen, expected) {
const received = screen.getPathnameWithParams();
const pass = this.equals(received, expected);
return {
pass,
// Diffs add value for structured data, but are noise for short strings, so print raw values here.
message: ()=>getMatcherHint(this, 'toHavePathnameWithParams') + '\n\n' + printMatcherValues(this, expected, received)
};
},
toHaveSegments (screen, expected) {
const received = screen.getSegments();
const pass = this.equals(received, expected);
return {
pass,
message: ()=>getMatcherHint(this, 'toHaveSegments') + '\n\n' + printMatcherDiff(this, expected, received)
};
},
toHaveSearchParams (screen, expected) {
const received = screen.getSearchParams();
const pass = this.equals(received, expected);
return {
pass,
message: ()=>getMatcherHint(this, 'toHaveSearchParams') + '\n\n' + printMatcherDiff(this, expected, received)
};
},
toHaveRouterState (screen, expected) {
const received = screen.getRouterState();
const pass = this.equals(received, expected);
return {
pass,
message: ()=>getMatcherHint(this, 'toHaveRouterState') + '\n\n' + printMatcherDiff(this, expected, received)
};
}
});
//# sourceMappingURL=expect.js.map