You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pinball/test/leaderboard/bloc/leaderboard_state_test.dart

73 lines
1.9 KiB

feat: leaderboard bloc (#57) * feat: added bloc for request ranking * feat: added empty repository * test: tests for bloc * refactor: adapt bloc events and models to what leaderboard repository has * feat: extension to convert between CharacterTheme and CharacterType * doc: documented leaderboard bloc * refactor: merge with leaderboard_repository * doc: completed doc * chore: unused import, trailing comma * chore: removed ios files * Update lib/leaderboard/bloc/leaderboard_bloc.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update lib/leaderboard/bloc/leaderboard_bloc.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * refactor: remove props from abstract event class to force childs to implement it * Update lib/leaderboard/bloc/leaderboard_bloc.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_event.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_event.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_event.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * chore: ignore doc for file * chore: wrong reference at doc * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * refactor: leaderboard state initial method Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Alejandro Santiago <dev@alestiago.com>
3 years ago
// ignore_for_file: prefer_const_constructors
import 'package:flutter_test/flutter_test.dart';
import 'package:leaderboard_repository/leaderboard_repository.dart';
import 'package:pinball/leaderboard/leaderboard.dart';
import 'package:pinball_theme/pinball_theme.dart';
feat: leaderboard bloc (#57) * feat: added bloc for request ranking * feat: added empty repository * test: tests for bloc * refactor: adapt bloc events and models to what leaderboard repository has * feat: extension to convert between CharacterTheme and CharacterType * doc: documented leaderboard bloc * refactor: merge with leaderboard_repository * doc: completed doc * chore: unused import, trailing comma * chore: removed ios files * Update lib/leaderboard/bloc/leaderboard_bloc.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update lib/leaderboard/bloc/leaderboard_bloc.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * refactor: remove props from abstract event class to force childs to implement it * Update lib/leaderboard/bloc/leaderboard_bloc.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_event.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_event.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_event.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * chore: ignore doc for file * chore: wrong reference at doc * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * refactor: leaderboard state initial method Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Alejandro Santiago <dev@alestiago.com>
3 years ago
void main() {
group('LeaderboardState', () {
test('supports value equality', () {
expect(
LeaderboardState.initial(),
equals(
LeaderboardState.initial(),
),
);
});
group('constructor', () {
test('can be instantiated', () {
expect(
LeaderboardState.initial(),
isNotNull,
);
});
});
group('copyWith', () {
final leaderboardEntry = LeaderboardEntry(
rank: '1',
feat: leaderboard bloc (#57) * feat: added bloc for request ranking * feat: added empty repository * test: tests for bloc * refactor: adapt bloc events and models to what leaderboard repository has * feat: extension to convert between CharacterTheme and CharacterType * doc: documented leaderboard bloc * refactor: merge with leaderboard_repository * doc: completed doc * chore: unused import, trailing comma * chore: removed ios files * Update lib/leaderboard/bloc/leaderboard_bloc.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update lib/leaderboard/bloc/leaderboard_bloc.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * refactor: remove props from abstract event class to force childs to implement it * Update lib/leaderboard/bloc/leaderboard_bloc.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_event.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_event.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_event.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * chore: ignore doc for file * chore: wrong reference at doc * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * refactor: leaderboard state initial method Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Alejandro Santiago <dev@alestiago.com>
3 years ago
playerInitials: 'ABC',
score: 1500,
character: DashTheme().character,
feat: leaderboard bloc (#57) * feat: added bloc for request ranking * feat: added empty repository * test: tests for bloc * refactor: adapt bloc events and models to what leaderboard repository has * feat: extension to convert between CharacterTheme and CharacterType * doc: documented leaderboard bloc * refactor: merge with leaderboard_repository * doc: completed doc * chore: unused import, trailing comma * chore: removed ios files * Update lib/leaderboard/bloc/leaderboard_bloc.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update lib/leaderboard/bloc/leaderboard_bloc.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * refactor: remove props from abstract event class to force childs to implement it * Update lib/leaderboard/bloc/leaderboard_bloc.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_event.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_event.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_event.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * chore: ignore doc for file * chore: wrong reference at doc * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * refactor: leaderboard state initial method Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Alejandro Santiago <dev@alestiago.com>
3 years ago
);
test(
'copies correctly '
'when no argument specified',
() {
const leaderboardState = LeaderboardState.initial();
expect(
leaderboardState.copyWith(),
equals(leaderboardState),
);
},
);
test(
'copies correctly '
'when all arguments specified',
() {
const leaderboardState = LeaderboardState.initial();
final otherLeaderboardState = LeaderboardState(
status: LeaderboardStatus.success,
ranking: LeaderboardRanking(ranking: 0, outOf: 0),
leaderboard: [leaderboardEntry],
feat: leaderboard bloc (#57) * feat: added bloc for request ranking * feat: added empty repository * test: tests for bloc * refactor: adapt bloc events and models to what leaderboard repository has * feat: extension to convert between CharacterTheme and CharacterType * doc: documented leaderboard bloc * refactor: merge with leaderboard_repository * doc: completed doc * chore: unused import, trailing comma * chore: removed ios files * Update lib/leaderboard/bloc/leaderboard_bloc.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update lib/leaderboard/bloc/leaderboard_bloc.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * refactor: remove props from abstract event class to force childs to implement it * Update lib/leaderboard/bloc/leaderboard_bloc.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_event.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_event.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_event.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * chore: ignore doc for file * chore: wrong reference at doc * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * Update lib/leaderboard/bloc/leaderboard_state.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * refactor: leaderboard state initial method Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Alejandro Santiago <dev@alestiago.com>
3 years ago
);
expect(leaderboardState, isNot(equals(otherLeaderboardState)));
expect(
leaderboardState.copyWith(
status: otherLeaderboardState.status,
ranking: otherLeaderboardState.ranking,
leaderboard: otherLeaderboardState.leaderboard,
),
equals(otherLeaderboardState),
);
},
);
});
});
}