Skip to content

Commit

Permalink
missing test
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzanardo committed Mar 11, 2024
1 parent 5621f0b commit ac112b4
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions api/test/routes/board/sections/[sectionId]_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ void main() {
late CrosswordRepository crosswordRepository;
late BoardRenderer boardRenderer;

setUpAll(() {
registerFallbackValue(
BoardSection(
id: '',
position: Point(0, 0),
size: 10,
words: const [],
borderWords: const [],
),
);
});

setUp(() {
requestContext = _MockRequestContext();
request = _MockRequest();
Expand Down Expand Up @@ -73,6 +85,22 @@ void main() {
expect(response.statusCode, HttpStatus.ok);
});

test('returns 404 when the board is not found', () async {
when(() => crosswordRepository.findSectionByPosition(0, 0)).thenAnswer(
(_) async => null,
);

when(
() => boardRenderer.renderSection(any()),
).thenAnswer((_) async {
return Uint8List(0);
});

final response = await route.onRequest(requestContext, '0,0');

expect(response.statusCode, HttpStatus.notFound);
});

test('returns method not allowed when not a get method', () async {
when(() => request.method).thenReturn(HttpMethod.post);
final response = await route.onRequest(requestContext, '0,0');
Expand All @@ -86,5 +114,12 @@ void main() {

expect(response.statusCode, HttpStatus.badRequest);
});

test('returns bad request when the id is incomplete', () async {
when(() => request.method).thenReturn(HttpMethod.get);
final response = await route.onRequest(requestContext, ',0');

expect(response.statusCode, HttpStatus.badRequest);
});
});
}

0 comments on commit ac112b4

Please sign in to comment.