doesRouteMatch method

bool doesRouteMatch(
  1. dynamic actual,
  2. dynamic expected
)

Check to see if route matches the mock specification Allows user to specify route as they intend rather than assuming string is a pattern. Route will be dynamic.

Implementation

bool doesRouteMatch(dynamic actual, dynamic expected) {
  // If null then fail. The route should never be null... ever.
  if (actual == null || expected == null) {
    return false;
  }

  // Ff strings, just compare.
  if (actual is String && expected is String) {
    return actual == expected;
  }

  // Allow regex match of route, expected should be provided via the mocking.
  if (expected is RegExp) {
    return expected.hasMatch(actual);
  }

  // Default to no match.
  return false;
}