-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix where the survey doesn't end with the first occurence of a com…
…pletion task (#153) Co-authored-by: MagginOne <[email protected]>
- Loading branch information
1 parent
93815b7
commit 86f840c
Showing
3 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:survey_kit/src/answer_format/boolean_answer_format.dart'; | ||
import 'package:survey_kit/src/navigator/navigable_task_navigator.dart'; | ||
import 'package:survey_kit/src/steps/identifier/step_identifier.dart'; | ||
import 'package:survey_kit/src/steps/predefined_steps/completion_step.dart'; | ||
import 'package:survey_kit/src/steps/predefined_steps/question_step.dart'; | ||
import 'package:survey_kit/src/task/navigable_task.dart'; | ||
import 'package:survey_kit/src/task/task.dart'; | ||
|
||
void main() { | ||
test('''Navigable task navigator completes | ||
after first occurence of completion step''', () { | ||
final Task task = NavigableTask( | ||
steps: [ | ||
QuestionStep( | ||
answerFormat: BooleanAnswerFormat( | ||
positiveAnswer: 'Yes', negativeAnswer: 'No')), | ||
CompletionStep( | ||
stepIdentifier: StepIdentifier(id: '111'), title: '', text: ''), | ||
CompletionStep( | ||
stepIdentifier: StepIdentifier(id: '222'), title: '', text: ''), | ||
], | ||
); | ||
final NavigableTaskNavigator navigator = NavigableTaskNavigator(task); | ||
final step0 = navigator.firstStep(); | ||
expect(step0, isNotNull); | ||
expect(step0, isA<QuestionStep>()); | ||
|
||
final completionStep0 = navigator.nextStep(step: step0!); | ||
expect(completionStep0, isNotNull); | ||
expect(completionStep0, isA<CompletionStep>()); | ||
|
||
final completionStep1 = navigator.nextStep(step: completionStep0!); | ||
expect(completionStep1, isNull); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:survey_kit/src/answer_format/boolean_answer_format.dart'; | ||
import 'package:survey_kit/src/navigator/ordered_task_navigator.dart'; | ||
import 'package:survey_kit/src/steps/identifier/step_identifier.dart'; | ||
import 'package:survey_kit/src/steps/predefined_steps/completion_step.dart'; | ||
import 'package:survey_kit/src/steps/predefined_steps/question_step.dart'; | ||
import 'package:survey_kit/src/task/identifier/task_identifier.dart'; | ||
import 'package:survey_kit/src/task/ordered_task.dart'; | ||
import 'package:survey_kit/src/task/task.dart'; | ||
|
||
void main() { | ||
test('''Ordered task navigator completes | ||
after first occurence of completion step''', () { | ||
final Task task = OrderedTask( | ||
id: TaskIdentifier(id: '100'), | ||
steps: [ | ||
QuestionStep( | ||
answerFormat: BooleanAnswerFormat( | ||
positiveAnswer: 'Yes', negativeAnswer: 'No')), | ||
CompletionStep( | ||
stepIdentifier: StepIdentifier(id: '111'), title: '', text: ''), | ||
CompletionStep( | ||
stepIdentifier: StepIdentifier(id: '222'), title: '', text: ''), | ||
], | ||
); | ||
final OrderedTaskNavigator navigator = OrderedTaskNavigator(task); | ||
final step0 = navigator.firstStep(); | ||
expect(step0, isNotNull); | ||
expect(step0, isA<QuestionStep>()); | ||
|
||
final completionStep0 = navigator.nextStep(step: step0!); | ||
expect(completionStep0, isNotNull); | ||
expect(completionStep0, isA<CompletionStep>()); | ||
|
||
final completionStep1 = navigator.nextStep(step: completionStep0!); | ||
expect(completionStep1, isNull); | ||
}); | ||
} |