Skip to content

Commit

Permalink
PR suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzanardo committed Mar 8, 2024
1 parent 313b114 commit 18a1e7e
Show file tree
Hide file tree
Showing 18 changed files with 98 additions and 264 deletions.
2 changes: 0 additions & 2 deletions api/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,3 @@ String get _initialsBlacklistId {
bool get _useEmulator => Platform.environment['USE_EMULATOR'] == 'true';

String get projectId => _appId;

bool get _useEmulator => Platform.environment['USE_EMULATOR'] == 'true';
29 changes: 0 additions & 29 deletions api/packages/board_renderer/.github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

14 changes: 0 additions & 14 deletions api/packages/board_renderer/.github/ISSUE_TEMPLATE/build.md

This file was deleted.

14 changes: 0 additions & 14 deletions api/packages/board_renderer/.github/ISSUE_TEMPLATE/chore.md

This file was deleted.

14 changes: 0 additions & 14 deletions api/packages/board_renderer/.github/ISSUE_TEMPLATE/ci.md

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

14 changes: 0 additions & 14 deletions api/packages/board_renderer/.github/ISSUE_TEMPLATE/performance.md

This file was deleted.

14 changes: 0 additions & 14 deletions api/packages/board_renderer/.github/ISSUE_TEMPLATE/refactor.md

This file was deleted.

16 changes: 0 additions & 16 deletions api/packages/board_renderer/.github/ISSUE_TEMPLATE/revert.md

This file was deleted.

14 changes: 0 additions & 14 deletions api/packages/board_renderer/.github/ISSUE_TEMPLATE/style.md

This file was deleted.

14 changes: 0 additions & 14 deletions api/packages/board_renderer/.github/ISSUE_TEMPLATE/test.md

This file was deleted.

27 changes: 0 additions & 27 deletions api/packages/board_renderer/.github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

21 changes: 0 additions & 21 deletions api/packages/board_renderer/.github/cspell.json

This file was deleted.

11 changes: 0 additions & 11 deletions api/packages/board_renderer/.github/dependabot.yaml

This file was deleted.

27 changes: 0 additions & 27 deletions api/packages/board_renderer/.github/workflows/main.yaml

This file was deleted.

98 changes: 98 additions & 0 deletions api/test/routes/board/full_render_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import 'dart:io';
import 'dart:typed_data';

import 'package:board_renderer/board_renderer.dart';
import 'package:crossword_repository/crossword_repository.dart';
import 'package:dart_frog/dart_frog.dart';
import 'package:game_domain/game_domain.dart';
import 'package:mocktail/mocktail.dart';
import 'package:test/test.dart';
import '../../../routes/board/full_render.dart' as route;

class _MockRequestContext extends Mock implements RequestContext {}

class _MockRequest extends Mock implements Request {}

class _MockCrosswordRepository extends Mock implements CrosswordRepository {}

class _MockBoardRenderer extends Mock implements BoardRenderer {}

void main() {
group('GET /board/full_render', () {
late RequestContext requestContext;
late Request request;
late CrosswordRepository crosswordRepository;
late BoardRenderer boardRenderer;

setUp(() {
requestContext = _MockRequestContext();
request = _MockRequest();
crosswordRepository = _MockCrosswordRepository();
boardRenderer = _MockBoardRenderer();

when(() => request.method).thenReturn(HttpMethod.get);
when(() => requestContext.read<BoardRenderer>())
.thenReturn(boardRenderer);
when(() => requestContext.request).thenReturn(request);
when(() => requestContext.read<CrosswordRepository>())
.thenReturn(crosswordRepository);
});

test('returns the image of the rendered board', () async {
final board1 = BoardSection(
id: '1',
position: const Point(1, 1),
size: 100,
words: [
Word(
position: const Point(1, 1),
axis: Axis.vertical,
answer: 'flutter',
clue: '',
hints: const [],
visible: true,
solvedTimestamp: null,
),
],
borderWords: const [],
);

final board2 = BoardSection(
id: '2',
position: const Point(2, 1),
size: 100,
words: [
Word(
position: const Point(2, 1),
axis: Axis.vertical,
answer: 'firebase',
clue: '',
hints: const [],
visible: true,
solvedTimestamp: null,
),
],
borderWords: const [],
);

when(crosswordRepository.listAllSections).thenAnswer(
(_) async => [board1, board2],
);

when(
() => boardRenderer.renderBoard(
[
board1.words.first,
board2.words.first,
],
),
).thenAnswer((_) async {
return Uint8List(0);
});

final response = await route.onRequest(requestContext);

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

0 comments on commit 18a1e7e

Please sign in to comment.