Skip to content

Commit

Permalink
test: add test for jsonListMatch
Browse files Browse the repository at this point in the history
  • Loading branch information
eseidel committed Oct 10, 2023
1 parent 6d24e06 commit ad960de
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions packages/cli/test/cache/response_cache_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import 'package:cli/cache/response_cache.dart';
import 'package:cli/logger.dart';
import 'package:mocktail/mocktail.dart';
import 'package:test/test.dart';

class _MockLogger extends Mock implements Logger {}

void main() {
test('jsonListMatch smoke test', () {
final logger = _MockLogger();
final a = {'a': 1, 'b': 2};
final b = {'a': 1, 'b': 2};
final c = {'a': 1, 'b': 3};
expect(jsonListMatch([a, b], [a, b], (t) => t), true);
expect(jsonListMatch([a, b], [b, a], (t) => t), true);
expect(
runWithLogger(logger, () => jsonListMatch([a, b], [a, c], (t) => t)),
false,
);
verify(
() => logger.info(
any(that: startsWith('Map<String, int> list differs at index 1')),
),
).called(1);

reset(logger);
expect(
runWithLogger(logger, () => jsonListMatch([a, b], [a, b, b], (t) => t)),
false,
);
verify(
() => logger.info("Map<String, int> list lengths don't match: 2 != 3"),
).called(1);
});
}

0 comments on commit ad960de

Please sign in to comment.