Skip to content

Commit

Permalink
Fixed GitHub nickpicks
Browse files Browse the repository at this point in the history
  • Loading branch information
BicaniWolfie committed Dec 6, 2023
1 parent 16e71c4 commit 0a5b156
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 73 deletions.
117 changes: 48 additions & 69 deletions test/blocs/weekplan_bloc_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: flutter_style_todos

import 'package:api_client/api/activity_api.dart';
import 'package:api_client/api/api.dart';
import 'package:api_client/api/user_api.dart';
Expand Down Expand Up @@ -124,21 +126,16 @@ void main() {
// Create an ActivityModel, to add to the list of marked activites.
// Then looks for the marked activities within the list.
// Skips the first entry
final ActivityModel activityModel = ActivityModel(
pictograms: <PictogramModel>[
PictogramModel(
accessLevel: AccessLevel.PRIVATE,
id: null,
imageHash: null,
imageUrl: null,
lastEdit: null,
title: 'test')
],
id: 1,
isChoiceBoard: true,
order: 0,
state: ActivityState.Normal
);
final ActivityModel activityModel =
ActivityModel(pictograms: <PictogramModel>[
PictogramModel(
accessLevel: AccessLevel.PRIVATE,
id: null,
imageHash: null,
imageUrl: null,
lastEdit: null,
title: 'test')
], id: 1, isChoiceBoard: true, order: 0, state: ActivityState.Normal);

weekplanBloc.markedActivities
.skip(1)
Expand All @@ -153,39 +150,30 @@ void main() {

test('Removes an activity to a list of marked activities',
async((DoneFn done) {
//Creates two activities and addes them to a list.
//Creates a listener for activities on the list.
//Removes one activity, and checks that the list lenght is = 1
final ActivityModel firstActivityModel = ActivityModel(
pictograms: <PictogramModel>[
PictogramModel(
accessLevel: AccessLevel.PRIVATE,
id: null,
imageHash: null,
imageUrl: null,
lastEdit: null,
title: 'test')
],
id: 1,
isChoiceBoard: true,
order: 0,
state: ActivityState.Normal);

final ActivityModel secondActivityModel = ActivityModel(
pictograms: <PictogramModel>[
PictogramModel(
accessLevel: AccessLevel.PRIVATE,
id: null,
imageHash: null,
imageUrl: null,
lastEdit: null,
title: 'test123')
],
id: 2,
isChoiceBoard: true,
order: 0,
state: ActivityState.Normal);
//Creates two activities and addes them to a list.
//Creates a listener for activities on the list.
//Removes one activity, and checks that the list lenght is = 1
final ActivityModel firstActivityModel =
ActivityModel(pictograms: <PictogramModel>[
PictogramModel(
accessLevel: AccessLevel.PRIVATE,
id: null,
imageHash: null,
imageUrl: null,
lastEdit: null,
title: 'test')
], id: 1, isChoiceBoard: true, order: 0, state: ActivityState.Normal);

final ActivityModel secondActivityModel =
ActivityModel(pictograms: <PictogramModel>[
PictogramModel(
accessLevel: AccessLevel.PRIVATE,
id: null,
imageHash: null,
imageUrl: null,
lastEdit: null,
title: 'test123')
], id: 2, isChoiceBoard: true, order: 0, state: ActivityState.Normal);

// Add marked activities to the list to prepare for the removal
weekplanBloc.addMarkedActivity(firstActivityModel);
Expand Down Expand Up @@ -217,7 +205,6 @@ void main() {
title: 'test')
], id: 123, isChoiceBoard: true, order: 0, state: ActivityState.Normal));


weekplanBloc.markedActivities
.skip(1)
.listen((List<ActivityModel> markedActivitiesList) {
Expand All @@ -230,7 +217,7 @@ void main() {

test('Checks if the activity is in the list of marked activities',
async((DoneFn done) {
//Checks if an activity is added to a list of marked activities.
//Checks if an activity is added to a list of marked activities.

final ActivityModel activity = ActivityModel(pictograms: <PictogramModel>[
PictogramModel(
Expand Down Expand Up @@ -265,11 +252,11 @@ void main() {

test('Checks if marked activities are deleted from a users weekplan',
async((DoneFn done) {
//Test if the api.week.update function get called
//This test should propperly ensure that the activities are deleted
//though an expect, instead of just making sure that the function
//is called
// TODO:Add expect to ensure that the list is empty
//Test if the api.week.update function get called
//This test should propperly ensure that the activities are deleted
//though an expect, instead of just making sure that the function
//is called
// TODO:Add expect to ensure that the list is empty
final DisplayNameModel user = DisplayNameModel(
role: Role.Citizen.toString(), displayName: 'User', id: '1');

Expand All @@ -295,9 +282,8 @@ void main() {

test('Checks if marked activities are copied to a new day',
async((DoneFn done) {
// Creates a user
// Creates a user
final DisplayNameModel user = DisplayNameModel(

role: Role.Citizen.toString(), displayName: 'User', id: '1');

final ActivityModel activity = ActivityModel(pictograms: <PictogramModel>[
Expand Down Expand Up @@ -333,8 +319,7 @@ void main() {
// then copies that weekblock and verify that it is updated
//Lastly it picks the fourth weekday and creates a listener for it.
//When fired, it ensures that the length of its activities are = 1
weekplanBloc.getWeek(week, user).whenComplete((){

weekplanBloc.getWeek(week, user).whenComplete(() {
weekplanBloc.setDaysToDisplay(5, 0);
for (int i = 0; i < 5; i++) {
weekplanBloc.addWeekdayStream();
Expand All @@ -353,7 +338,6 @@ void main() {
test('Checks if marked activities are marked as cancel', async((DoneFn done) {
//Creates a user
final DisplayNameModel user = DisplayNameModel(

role: Role.Citizen.toString(), displayName: 'User', id: '1');

final ActivityModel activity = ActivityModel(pictograms: <PictogramModel>[
Expand All @@ -365,7 +349,7 @@ void main() {
lastEdit: null,
title: 'test123')
], id: 2, isChoiceBoard: true, order: 0, state: ActivityState.Normal);

week = WeekModel(
thumbnail: PictogramModel(
imageUrl: null,
Expand All @@ -390,8 +374,7 @@ void main() {
// Then cancel the marked activities, and verifies that they are updated.
// Creates a listener for monday, listening for weekday
// When fired it checks if the first activities state is Canceled
weekplanBloc.getWeek(week, user).whenComplete((){

weekplanBloc.getWeek(week, user).whenComplete(() {
weekplanBloc.setDaysToDisplay(5, 0);
for (int i = 0; i < 5; i++) {
weekplanBloc.addWeekdayStream();
Expand Down Expand Up @@ -447,7 +430,7 @@ void main() {
// Marks the activities and then unmarks them.
// Creates a listener for monday, listening for weekday
// When fired it checks if the first activities state is Active
weekplanBloc.getWeek(week, user).whenComplete((){
weekplanBloc.getWeek(week, user).whenComplete(() {
weekplanBloc.setDaysToDisplay(5, 0);
for (int i = 0; i < 5; i++) {
weekplanBloc.addWeekdayStream();
Expand Down Expand Up @@ -478,10 +461,7 @@ void main() {
test('Adds an activity to a given weekplan', async((DoneFn done) {
// Creates a user
final DisplayNameModel user = DisplayNameModel(
role: Role.Guardian.toString(),
displayName: 'User',
id: '1'
);
role: Role.Guardian.toString(), displayName: 'User', id: '1');
//Creates a Activity
final ActivityModel activity = ActivityModel(
order: 0,
Expand All @@ -494,8 +474,7 @@ void main() {
// Addes the activities and verify that they are updated
// Creates a listener for monday, when fired it compares the activities
// length and if it is the same activity as the one added
weekplanBloc.getWeek(week, user).whenComplete((){

weekplanBloc.getWeek(week, user).whenComplete(() {
weekplanBloc.setDaysToDisplay(2, 0);
for (int i = 0; i < 2; i++) {
weekplanBloc.addWeekdayStream();
Expand Down
5 changes: 3 additions & 2 deletions test/widgets/giraf_button_widget_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: flutter_style_todos

import 'dart:async';

import 'package:flutter/material.dart';
Expand Down Expand Up @@ -55,11 +57,10 @@ void main() {
expect(find.byWidget(acceptIcon), findsOneWidget);
});


testWidgets(
'GirafButton is pressed and'
' works when enabled', (WidgetTester tester) async {
// TODO; Skal revuderes, mange af disse ting er nok unødvendige
// TODO; Skal revuderes, mange af disse ting er nok unødvendige
final Completer<bool> done = Completer<bool>();
final MockScreen screen = MockScreen();
// Opens the MockScreen widget and enables the GirafButton
Expand Down
5 changes: 3 additions & 2 deletions test/widgets/loading_spinner_widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ void main() {
await tester.pumpWidget(MaterialApp(home: MockScreen()));
await tester.tap(find.byKey(const Key('FirstButton')));
await tester.pump();
//As the "FirstButton" is set to toggle the loading spinner (can be seen in the mock above),
//It is now expected that the loading spinner is being shown
// As the "FirstButton" is set to toggle the loading spinner
// (can be seen in the mock above),
// It is now expected that the loading spinner is being shown
expect(find.byType(CircularProgressIndicator), findsOneWidget);
});

Expand Down

0 comments on commit 0a5b156

Please sign in to comment.