Skip to content

Commit

Permalink
[Tests] Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed Feb 20, 2022
1 parent 4bddf0e commit ffa18f8
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 37 deletions.
93 changes: 61 additions & 32 deletions test/application/custom_build/custom_build_bloc_test.dart
Expand Up @@ -54,7 +54,7 @@ void main() {

Future<CustomBuildModel> _saveCustomBuild(String charKey) async {
final artifact = _genshinService.getArtifactForCard(_thunderingFuryKey);
final weapon = _genshinService.getWeaponForCard(_aquilaFavoniaKey);
final weapon = _genshinService.getWeapon(_aquilaFavoniaKey);
return _dataService.customBuilds.saveCustomBuild(
charKey,
'$charKey pro DPS',
Expand All @@ -69,11 +69,11 @@ void main() {
index: 0,
rarity: weapon.rarity,
refinement: 5,
baseAtk: weapon.baseAtk,
subStatType: weapon.subStatType,
subStatValue: weapon.subStatValue,
name: weapon.name,
subStatType: weapon.secondaryStat,
name: 'Aquila Favonia',
image: weapon.image,
stat: weapon.stats.last,
stats: weapon.stats,
),
],
[
Expand Down Expand Up @@ -593,6 +593,28 @@ void main() {
orElse: () => throw Exception('Invalid custom build state'),
),
);

blocTest<CustomBuildBloc, CustomBuildState>(
'stat changed',
build: () => _getBloc(),
act: (bloc) {
final weapon = _genshinService.getWeapon(_aquilaFavoniaKey);
return bloc
..add(const CustomBuildEvent.load(initialTitle: 'DPS PRO'))
..add(const CustomBuildEvent.characterChanged(newKey: _keqingKey))
..add(const CustomBuildEvent.addWeapon(key: _aquilaFavoniaKey))
..add(CustomBuildEvent.weaponStatChanged(key: _aquilaFavoniaKey, newValue: weapon.stats[3]));
},
verify: (bloc) => bloc.state.maybeMap(
loaded: (state) {
final stat = _genshinService.getWeapon(_aquilaFavoniaKey).stats[3];
expect(state.weapons.length == 1, true);
expect(state.weapons.first.key == _aquilaFavoniaKey, true);
expect(state.weapons.first.stat == stat, true);
},
orElse: () => throw Exception('Invalid custom build state'),
),
);
});

group('Artifacts', () {
Expand Down Expand Up @@ -863,41 +885,48 @@ void main() {
blocTest<CustomBuildBloc, CustomBuildState>(
'all stuff was set',
build: () => _getBloc(),
act: (bloc) => bloc
..add(const CustomBuildEvent.load(initialTitle: 'DPS PRO'))
..add(const CustomBuildEvent.characterChanged(newKey: _keqingKey))
..add(const CustomBuildEvent.isRecommendedChanged(newValue: true))
..add(const CustomBuildEvent.showOnCharacterDetailChanged(newValue: false))
..add(const CustomBuildEvent.addNote(note: 'You need C6'))
..add(const CustomBuildEvent.addSkillPriority(type: CharacterSkillType.elementalBurst))
..add(const CustomBuildEvent.addArtifact(key: _thunderingFuryKey, type: ArtifactType.flower, statType: StatType.hp))
..add(const CustomBuildEvent.addArtifact(key: _thunderingFuryKey, type: ArtifactType.plume, statType: StatType.atk))
..add(const CustomBuildEvent.addArtifact(key: _thunderingFuryKey, type: ArtifactType.clock, statType: StatType.atkPercentage))
..add(const CustomBuildEvent.addArtifact(key: _thunderingFuryKey, type: ArtifactType.goblet, statType: StatType.electroDmgBonusPercentage))
..add(const CustomBuildEvent.addArtifact(key: _thunderingFuryKey, type: ArtifactType.crown, statType: StatType.critDmgPercentage))
..add(
const CustomBuildEvent.addArtifactSubStats(
type: ArtifactType.crown,
subStats: [
StatType.critRatePercentage,
StatType.atkPercentage,
StatType.atk,
],
),
)
..add(const CustomBuildEvent.addWeapon(key: _aquilaFavoniaKey))
..add(
const CustomBuildEvent.addTeamCharacter(key: _ganyuKey, roleType: CharacterRoleType.offFieldDps, subType: CharacterRoleSubType.cryo),
)
..add(const CustomBuildEvent.saveChanges()),
act: (bloc) {
final weapon = _genshinService.getWeapon(_aquilaFavoniaKey);
return bloc
..add(const CustomBuildEvent.load(initialTitle: 'DPS PRO'))
..add(const CustomBuildEvent.characterChanged(newKey: _keqingKey))
..add(const CustomBuildEvent.isRecommendedChanged(newValue: true))
..add(const CustomBuildEvent.showOnCharacterDetailChanged(newValue: false))
..add(const CustomBuildEvent.addNote(note: 'You need C6'))
..add(const CustomBuildEvent.addSkillPriority(type: CharacterSkillType.elementalBurst))
..add(const CustomBuildEvent.addArtifact(key: _thunderingFuryKey, type: ArtifactType.flower, statType: StatType.hp))
..add(const CustomBuildEvent.addArtifact(key: _thunderingFuryKey, type: ArtifactType.plume, statType: StatType.atk))
..add(const CustomBuildEvent.addArtifact(key: _thunderingFuryKey, type: ArtifactType.clock, statType: StatType.atkPercentage))
..add(const CustomBuildEvent.addArtifact(key: _thunderingFuryKey, type: ArtifactType.goblet, statType: StatType.electroDmgBonusPercentage))
..add(const CustomBuildEvent.addArtifact(key: _thunderingFuryKey, type: ArtifactType.crown, statType: StatType.critDmgPercentage))
..add(
const CustomBuildEvent.addArtifactSubStats(
type: ArtifactType.crown,
subStats: [
StatType.critRatePercentage,
StatType.atkPercentage,
StatType.atk,
],
),
)
..add(const CustomBuildEvent.addWeapon(key: _aquilaFavoniaKey))
..add(CustomBuildEvent.weaponStatChanged(key: _aquilaFavoniaKey, newValue: weapon.stats.first))
..add(
const CustomBuildEvent.addTeamCharacter(key: _ganyuKey, roleType: CharacterRoleType.offFieldDps, subType: CharacterRoleSubType.cryo),
)
..add(const CustomBuildEvent.saveChanges());
},
verify: (bloc) => bloc.state.maybeMap(
loaded: (state) {
final stat = _genshinService.getWeapon(_aquilaFavoniaKey).stats.first;
expect(state.character.key, _keqingKey);
expect(state.isRecommended, true);
expect(state.showOnCharacterDetail, false);
expect(state.skillPriorities.length == 1, true);
expect(state.notes.length == 1, true);
expect(state.weapons.length == 1, true);
expect(state.weapons.first.stat.level, stat.level);
expect(state.weapons.first.stat.isAnAscension, stat.isAnAscension);
expect(state.artifacts.length == 5, true);
expect(state.subStatsSummary.isNotEmpty, true);
expect(state.teamCharacters.length == 1, true);
Expand Down
10 changes: 5 additions & 5 deletions test/application/custom_builds/custom_builds_bloc_test.dart
Expand Up @@ -43,7 +43,7 @@ void main() {

Future<CustomBuildModel> _saveCustomBuild(String charKey) async {
final artifact = _genshinService.getArtifactForCard(_thunderingFuryKey);
final weapon = _genshinService.getWeaponForCard(_aquilaFavoniaKey);
final weapon = _genshinService.getWeapon(_aquilaFavoniaKey);
return _dataService.customBuilds.saveCustomBuild(
charKey,
'$charKey pro DPS',
Expand All @@ -58,11 +58,11 @@ void main() {
index: 0,
rarity: weapon.rarity,
refinement: 5,
baseAtk: weapon.baseAtk,
subStatType: weapon.subStatType,
subStatValue: weapon.subStatValue,
name: weapon.name,
subStatType: weapon.secondaryStat,
name: 'Aquila Favonia',
image: weapon.image,
stat: weapon.stats.last,
stats: weapon.stats,
),
],
[
Expand Down

0 comments on commit ffa18f8

Please sign in to comment.