forked from eatvio/eatvio_app
feat(video_calls, welcome_screen): ios mic fix, welcome scrin layoute fix
This commit is contained in:
@@ -82,12 +82,65 @@ void main() {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setPrice(1500.0);
|
||||
expect(cubit.state.planData.options[0].price, 1500.0);
|
||||
expect(cubit.state.validationState.optionsValidationState[0].priceHasError, false);
|
||||
expect(
|
||||
cubit.state.validationState.optionsValidationState[0].priceHasError,
|
||||
false,
|
||||
);
|
||||
|
||||
cubit.setPrice(1000.0);
|
||||
expect(cubit.state.validationState.optionsValidationState[0].priceHasError, true);
|
||||
expect(
|
||||
cubit.state.validationState.optionsValidationState[0].priceHasError,
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
test(
|
||||
'option title, description, price and content stay independent per option',
|
||||
() {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionTitle('Economy');
|
||||
cubit.setPrice(1500.0);
|
||||
cubit.setOptionDescription('Economy description');
|
||||
cubit.setOptionContent('Economy item', 0);
|
||||
|
||||
cubit.setSelectedOptionIndex(1);
|
||||
cubit.setOptionTitle('Standard');
|
||||
cubit.setPrice(2500.0);
|
||||
cubit.setOptionDescription('Standard description');
|
||||
cubit.setOptionContent('Standard item', 0);
|
||||
|
||||
cubit.setSelectedOptionIndex(2);
|
||||
cubit.setOptionTitle('Comfort');
|
||||
cubit.setPrice(3500.0);
|
||||
cubit.setOptionDescription('Comfort description');
|
||||
cubit.setOptionContent('Comfort item', 0);
|
||||
|
||||
expect(cubit.state.planData.options[0].short, 'Economy');
|
||||
expect(cubit.state.planData.options[0].price, 1500.0);
|
||||
expect(
|
||||
cubit.state.planData.options[0].description,
|
||||
'Economy description',
|
||||
);
|
||||
expect(cubit.state.planData.options[0].items, ['Economy item']);
|
||||
|
||||
expect(cubit.state.planData.options[1].short, 'Standard');
|
||||
expect(cubit.state.planData.options[1].price, 2500.0);
|
||||
expect(
|
||||
cubit.state.planData.options[1].description,
|
||||
'Standard description',
|
||||
);
|
||||
expect(cubit.state.planData.options[1].items, ['Standard item']);
|
||||
|
||||
expect(cubit.state.planData.options[2].short, 'Comfort');
|
||||
expect(cubit.state.planData.options[2].price, 3500.0);
|
||||
expect(
|
||||
cubit.state.planData.options[2].description,
|
||||
'Comfort description',
|
||||
);
|
||||
expect(cubit.state.planData.options[2].items, ['Comfort item']);
|
||||
},
|
||||
);
|
||||
|
||||
test('setOptionDescription updates description and validates', () {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionDescription('Test description');
|
||||
@@ -129,11 +182,17 @@ void main() {
|
||||
test('validateSelectedOptionItems validates items', () {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
expect(cubit.validateSelectedOptionItems(), false);
|
||||
expect(cubit.state.validationState.optionsValidationState[0].isItemsEmpty, true);
|
||||
expect(
|
||||
cubit.state.validationState.optionsValidationState[0].isItemsEmpty,
|
||||
true,
|
||||
);
|
||||
|
||||
cubit.setOptionContent('Valid item', 0);
|
||||
expect(cubit.validateSelectedOptionItems(), true);
|
||||
expect(cubit.state.validationState.optionsValidationState[0].isItemsEmpty, false);
|
||||
expect(
|
||||
cubit.state.validationState.optionsValidationState[0].isItemsEmpty,
|
||||
false,
|
||||
);
|
||||
|
||||
cubit.setOptionContent('AB', 1);
|
||||
expect(cubit.validateSelectedOptionItems(), false);
|
||||
@@ -225,18 +284,27 @@ void main() {
|
||||
expect(cubit.state.validationState.imageHasError, false);
|
||||
});
|
||||
|
||||
test('validateSelectedOptionPrice returns false for price less than 1200', () {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setPrice(1000.0);
|
||||
expect(cubit.validateSelectedOptionPrice(), false);
|
||||
expect(cubit.state.validationState.optionsValidationState[0].priceHasError, true);
|
||||
});
|
||||
test(
|
||||
'validateSelectedOptionPrice returns false for price less than 1200',
|
||||
() {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setPrice(1000.0);
|
||||
expect(cubit.validateSelectedOptionPrice(), false);
|
||||
expect(
|
||||
cubit.state.validationState.optionsValidationState[0].priceHasError,
|
||||
true,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
test('validateSelectedOptionPrice returns true for price >= 1200', () {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setPrice(1200.0);
|
||||
expect(cubit.validateSelectedOptionPrice(), true);
|
||||
expect(cubit.state.validationState.optionsValidationState[0].priceHasError, false);
|
||||
expect(
|
||||
cubit.state.validationState.optionsValidationState[0].priceHasError,
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test('setImage updates image and validates', () {
|
||||
@@ -260,28 +328,37 @@ void main() {
|
||||
expect(cubit.state.planData.options[0].items[0], 'Item 1');
|
||||
});
|
||||
|
||||
test('validatePriceOfAllFilledOptions returns false when some prices are invalid', () {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setPrice(1500.0);
|
||||
cubit.setSelectedOptionIndex(1);
|
||||
cubit.setPrice(1000.0); // Invalid
|
||||
cubit.setSelectedOptionIndex(2);
|
||||
cubit.setPrice(1500.0);
|
||||
expect(cubit.validatePriceOfAllFilledOptions(), false);
|
||||
});
|
||||
test(
|
||||
'validatePriceOfAllFilledOptions returns false when some prices are invalid',
|
||||
() {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setPrice(1500.0);
|
||||
cubit.setSelectedOptionIndex(1);
|
||||
cubit.setPrice(1000.0); // Invalid
|
||||
cubit.setSelectedOptionIndex(2);
|
||||
cubit.setPrice(1500.0);
|
||||
expect(cubit.validatePriceOfAllFilledOptions(), false);
|
||||
},
|
||||
);
|
||||
|
||||
test('validateSelectedOptionTitle returns false for short title', () {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionTitle('AB');
|
||||
expect(cubit.validateSelectedOptionTitle(), false);
|
||||
expect(cubit.state.validationState.optionsValidationState[0].titleHasError, true);
|
||||
expect(
|
||||
cubit.state.validationState.optionsValidationState[0].titleHasError,
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
test('validateSelectedOptionTitle returns true for valid title', () {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionTitle('Valid Title');
|
||||
expect(cubit.validateSelectedOptionTitle(), true);
|
||||
expect(cubit.state.validationState.optionsValidationState[0].titleHasError, false);
|
||||
expect(
|
||||
cubit.state.validationState.optionsValidationState[0].titleHasError,
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test('validateTitlesOfAllFilledOptions validates all options', () {
|
||||
@@ -294,37 +371,63 @@ void main() {
|
||||
expect(cubit.validateTitlesOfAllFilledOptions(), true);
|
||||
});
|
||||
|
||||
test('validateTitlesOfAllFilledOptions returns false when some titles are invalid', () {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionTitle('Valid Title');
|
||||
cubit.setSelectedOptionIndex(1);
|
||||
cubit.setOptionTitle('AB'); // Invalid
|
||||
cubit.setSelectedOptionIndex(2);
|
||||
cubit.setOptionTitle('Valid Title');
|
||||
expect(cubit.validateTitlesOfAllFilledOptions(), false);
|
||||
});
|
||||
test(
|
||||
'validateTitlesOfAllFilledOptions returns false when some titles are invalid',
|
||||
() {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionTitle('Valid Title');
|
||||
cubit.setSelectedOptionIndex(1);
|
||||
cubit.setOptionTitle('AB'); // Invalid
|
||||
cubit.setSelectedOptionIndex(2);
|
||||
cubit.setOptionTitle('Valid Title');
|
||||
expect(cubit.validateTitlesOfAllFilledOptions(), false);
|
||||
},
|
||||
);
|
||||
|
||||
test('validateTitlesOfAllFilledOptions returns early when selectedOptionIndex is null', () {
|
||||
cubit.setSelectedOptionIndex(null);
|
||||
cubit.setOptionTitle('Title 1');
|
||||
final result = cubit.validateTitlesOfAllFilledOptions();
|
||||
// Should only validate first option when selectedOptionIndex is null
|
||||
expect(result, isA<bool>());
|
||||
});
|
||||
test(
|
||||
'validateTitlesOfAllFilledOptions returns early when selectedOptionIndex is null',
|
||||
() {
|
||||
cubit.setSelectedOptionIndex(null);
|
||||
cubit.setOptionTitle('Title 1');
|
||||
final result = cubit.validateTitlesOfAllFilledOptions();
|
||||
// Should only validate first option when selectedOptionIndex is null
|
||||
expect(result, isA<bool>());
|
||||
},
|
||||
);
|
||||
|
||||
test('validateSelectedOptionDescription returns false for short description', () {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionDescription('AB');
|
||||
expect(cubit.validateSelectedOptionDescription(), false);
|
||||
expect(cubit.state.validationState.optionsValidationState[0].descriptionHasError, true);
|
||||
});
|
||||
test(
|
||||
'validateSelectedOptionDescription returns false for short description',
|
||||
() {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionDescription('AB');
|
||||
expect(cubit.validateSelectedOptionDescription(), false);
|
||||
expect(
|
||||
cubit
|
||||
.state
|
||||
.validationState
|
||||
.optionsValidationState[0]
|
||||
.descriptionHasError,
|
||||
true,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
test('validateSelectedOptionDescription returns true for valid description', () {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionDescription('Valid description');
|
||||
expect(cubit.validateSelectedOptionDescription(), true);
|
||||
expect(cubit.state.validationState.optionsValidationState[0].descriptionHasError, false);
|
||||
});
|
||||
test(
|
||||
'validateSelectedOptionDescription returns true for valid description',
|
||||
() {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionDescription('Valid description');
|
||||
expect(cubit.validateSelectedOptionDescription(), true);
|
||||
expect(
|
||||
cubit
|
||||
.state
|
||||
.validationState
|
||||
.optionsValidationState[0]
|
||||
.descriptionHasError,
|
||||
false,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
test('validateDescriptionsOfAllOptions validates all options', () {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
@@ -336,23 +439,29 @@ void main() {
|
||||
expect(cubit.validateDescriptionsOfAllOptions(), true);
|
||||
});
|
||||
|
||||
test('validateDescriptionsOfAllOptions returns false when some descriptions are invalid', () {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionDescription('Valid description');
|
||||
cubit.setSelectedOptionIndex(1);
|
||||
cubit.setOptionDescription('AB'); // Invalid
|
||||
cubit.setSelectedOptionIndex(2);
|
||||
cubit.setOptionDescription('Valid description');
|
||||
expect(cubit.validateDescriptionsOfAllOptions(), false);
|
||||
});
|
||||
test(
|
||||
'validateDescriptionsOfAllOptions returns false when some descriptions are invalid',
|
||||
() {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionDescription('Valid description');
|
||||
cubit.setSelectedOptionIndex(1);
|
||||
cubit.setOptionDescription('AB'); // Invalid
|
||||
cubit.setSelectedOptionIndex(2);
|
||||
cubit.setOptionDescription('Valid description');
|
||||
expect(cubit.validateDescriptionsOfAllOptions(), false);
|
||||
},
|
||||
);
|
||||
|
||||
test('validateDescriptionsOfAllOptions returns early when selectedOptionIndex is null', () {
|
||||
cubit.setSelectedOptionIndex(null);
|
||||
cubit.setOptionDescription('Description 1');
|
||||
final result = cubit.validateDescriptionsOfAllOptions();
|
||||
// Should only validate first option when selectedOptionIndex is null
|
||||
expect(result, isA<bool>());
|
||||
});
|
||||
test(
|
||||
'validateDescriptionsOfAllOptions returns early when selectedOptionIndex is null',
|
||||
() {
|
||||
cubit.setSelectedOptionIndex(null);
|
||||
cubit.setOptionDescription('Description 1');
|
||||
final result = cubit.validateDescriptionsOfAllOptions();
|
||||
// Should only validate first option when selectedOptionIndex is null
|
||||
expect(result, isA<bool>());
|
||||
},
|
||||
);
|
||||
|
||||
test('validateItemsOfAllFilledOptions validates all options', () {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
@@ -364,29 +473,41 @@ void main() {
|
||||
expect(cubit.validateItemsOfAllFilledOptions(), true);
|
||||
});
|
||||
|
||||
test('validateItemsOfAllFilledOptions returns false when some items are invalid', () {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionContent('Valid item', 0);
|
||||
cubit.setSelectedOptionIndex(1);
|
||||
cubit.setOptionContent('AB', 0); // Invalid
|
||||
cubit.setSelectedOptionIndex(2);
|
||||
cubit.setOptionContent('Valid item', 0);
|
||||
expect(cubit.validateItemsOfAllFilledOptions(), false);
|
||||
});
|
||||
test(
|
||||
'validateItemsOfAllFilledOptions returns false when some items are invalid',
|
||||
() {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionContent('Valid item', 0);
|
||||
cubit.setSelectedOptionIndex(1);
|
||||
cubit.setOptionContent('AB', 0); // Invalid
|
||||
cubit.setSelectedOptionIndex(2);
|
||||
cubit.setOptionContent('Valid item', 0);
|
||||
expect(cubit.validateItemsOfAllFilledOptions(), false);
|
||||
},
|
||||
);
|
||||
|
||||
test('validateItemsOfAllFilledOptions returns false when items are empty', () {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
expect(cubit.validateItemsOfAllFilledOptions(), false);
|
||||
expect(cubit.state.validationState.optionsValidationState[0].isItemsEmpty, true);
|
||||
});
|
||||
test(
|
||||
'validateItemsOfAllFilledOptions returns false when items are empty',
|
||||
() {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
expect(cubit.validateItemsOfAllFilledOptions(), false);
|
||||
expect(
|
||||
cubit.state.validationState.optionsValidationState[0].isItemsEmpty,
|
||||
true,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
test('validateItemsOfAllFilledOptions returns early when selectedOptionIndex is null', () {
|
||||
cubit.setSelectedOptionIndex(null);
|
||||
cubit.setOptionContent('Item 1', 0);
|
||||
final result = cubit.validateItemsOfAllFilledOptions();
|
||||
// Should only validate first option when selectedOptionIndex is null
|
||||
expect(result, isA<bool>());
|
||||
});
|
||||
test(
|
||||
'validateItemsOfAllFilledOptions returns early when selectedOptionIndex is null',
|
||||
() {
|
||||
cubit.setSelectedOptionIndex(null);
|
||||
cubit.setOptionContent('Item 1', 0);
|
||||
final result = cubit.validateItemsOfAllFilledOptions();
|
||||
// Should only validate first option when selectedOptionIndex is null
|
||||
expect(result, isA<bool>());
|
||||
},
|
||||
);
|
||||
|
||||
test('validateAllFields returns false when name is invalid', () {
|
||||
cubit.setName('AB');
|
||||
@@ -456,20 +577,20 @@ void main() {
|
||||
cubit.setPlanType([true, false, false, false]);
|
||||
final image = XFile('test_image.jpg');
|
||||
cubit.setImage(image);
|
||||
|
||||
|
||||
// Заполняем все три опции, так как validateItemsOfAllFilledOptions проверяет все
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionTitle('Valid Title 1');
|
||||
cubit.setPrice(1500.0);
|
||||
cubit.setOptionDescription('Valid description 1');
|
||||
cubit.setOptionContent('Valid item 1', 0);
|
||||
|
||||
|
||||
cubit.setSelectedOptionIndex(1);
|
||||
cubit.setOptionTitle('Valid Title 2');
|
||||
cubit.setPrice(2000.0);
|
||||
cubit.setOptionDescription('Valid description 2');
|
||||
cubit.setOptionContent('Valid item 2', 0);
|
||||
|
||||
|
||||
cubit.setSelectedOptionIndex(2);
|
||||
cubit.setOptionTitle('Valid Title 3');
|
||||
cubit.setPrice(2500.0);
|
||||
@@ -527,21 +648,24 @@ void main() {
|
||||
expect(cubit.validateAllFields(), false);
|
||||
});
|
||||
|
||||
test('validateAllFields returns false when option description is invalid', () {
|
||||
cubit.setName('Valid Name');
|
||||
cubit.setDetails('Valid description');
|
||||
cubit.setDuration(0);
|
||||
cubit.setPlanType([true, false, false, false]);
|
||||
final image = XFile('test_image.jpg');
|
||||
cubit.setImage(image);
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionTitle('Valid Title');
|
||||
cubit.setPrice(1500.0);
|
||||
cubit.setOptionDescription('AB'); // Invalid
|
||||
cubit.setOptionContent('Valid item', 0);
|
||||
test(
|
||||
'validateAllFields returns false when option description is invalid',
|
||||
() {
|
||||
cubit.setName('Valid Name');
|
||||
cubit.setDetails('Valid description');
|
||||
cubit.setDuration(0);
|
||||
cubit.setPlanType([true, false, false, false]);
|
||||
final image = XFile('test_image.jpg');
|
||||
cubit.setImage(image);
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionTitle('Valid Title');
|
||||
cubit.setPrice(1500.0);
|
||||
cubit.setOptionDescription('AB'); // Invalid
|
||||
cubit.setOptionContent('Valid item', 0);
|
||||
|
||||
expect(cubit.validateAllFields(), false);
|
||||
});
|
||||
expect(cubit.validateAllFields(), false);
|
||||
},
|
||||
);
|
||||
|
||||
test('validateAllFields returns false when option items are invalid', () {
|
||||
cubit.setName('Valid Name');
|
||||
@@ -611,115 +735,143 @@ void main() {
|
||||
expect(cubit.state.planData.options[0].items.length, 1);
|
||||
});
|
||||
|
||||
test('setOptionContent - добавляет новый элемент когда индекс больше длины', () {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
expect(cubit.state.planData.options[0].items.length, 0);
|
||||
test(
|
||||
'setOptionContent - добавляет новый элемент когда индекс больше длины',
|
||||
() {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
expect(cubit.state.planData.options[0].items.length, 0);
|
||||
|
||||
cubit.setOptionContent('Item 1', 0);
|
||||
expect(cubit.state.planData.options[0].items.length, 1);
|
||||
cubit.setOptionContent('Item 1', 0);
|
||||
expect(cubit.state.planData.options[0].items.length, 1);
|
||||
|
||||
cubit.setOptionContent('Item 2', 1);
|
||||
expect(cubit.state.planData.options[0].items.length, 2);
|
||||
});
|
||||
cubit.setOptionContent('Item 2', 1);
|
||||
expect(cubit.state.planData.options[0].items.length, 2);
|
||||
},
|
||||
);
|
||||
|
||||
test('validateTitlesOfAllFilledOptions - возвращает true когда selectedOptionIndex == null и все опции валидны', () {
|
||||
cubit.setSelectedOptionIndex(null);
|
||||
cubit.setOptionTitle('Valid Title 1');
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionTitle('Valid Title 1');
|
||||
cubit.setSelectedOptionIndex(1);
|
||||
cubit.setOptionTitle('Valid Title 2');
|
||||
cubit.setSelectedOptionIndex(2);
|
||||
cubit.setOptionTitle('Valid Title 3');
|
||||
test(
|
||||
'validateTitlesOfAllFilledOptions - возвращает true когда selectedOptionIndex == null и все опции валидны',
|
||||
() {
|
||||
cubit.setSelectedOptionIndex(null);
|
||||
cubit.setOptionTitle('Valid Title 1');
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionTitle('Valid Title 1');
|
||||
cubit.setSelectedOptionIndex(1);
|
||||
cubit.setOptionTitle('Valid Title 2');
|
||||
cubit.setSelectedOptionIndex(2);
|
||||
cubit.setOptionTitle('Valid Title 3');
|
||||
|
||||
cubit.setSelectedOptionIndex(null);
|
||||
final result = cubit.validateTitlesOfAllFilledOptions();
|
||||
expect(result, true);
|
||||
});
|
||||
cubit.setSelectedOptionIndex(null);
|
||||
final result = cubit.validateTitlesOfAllFilledOptions();
|
||||
expect(result, true);
|
||||
},
|
||||
);
|
||||
|
||||
test('validateTitlesOfAllFilledOptions - возвращает false когда selectedOptionIndex == null и опция 0 невалидна', () {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionTitle('AB'); // невалидное название
|
||||
cubit.setSelectedOptionIndex(null);
|
||||
test(
|
||||
'validateTitlesOfAllFilledOptions - возвращает false когда selectedOptionIndex == null и опция 0 невалидна',
|
||||
() {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionTitle('AB'); // невалидное название
|
||||
cubit.setSelectedOptionIndex(null);
|
||||
|
||||
final result = cubit.validateTitlesOfAllFilledOptions();
|
||||
expect(result, false);
|
||||
});
|
||||
final result = cubit.validateTitlesOfAllFilledOptions();
|
||||
expect(result, false);
|
||||
},
|
||||
);
|
||||
|
||||
test('validateDescriptionsOfAllOptions - возвращает true когда selectedOptionIndex == null и все описания валидны', () {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionDescription('Valid Description 1');
|
||||
cubit.setSelectedOptionIndex(1);
|
||||
cubit.setOptionDescription('Valid Description 2');
|
||||
cubit.setSelectedOptionIndex(2);
|
||||
cubit.setOptionDescription('Valid Description 3');
|
||||
test(
|
||||
'validateDescriptionsOfAllOptions - возвращает true когда selectedOptionIndex == null и все описания валидны',
|
||||
() {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionDescription('Valid Description 1');
|
||||
cubit.setSelectedOptionIndex(1);
|
||||
cubit.setOptionDescription('Valid Description 2');
|
||||
cubit.setSelectedOptionIndex(2);
|
||||
cubit.setOptionDescription('Valid Description 3');
|
||||
|
||||
cubit.setSelectedOptionIndex(null);
|
||||
final result = cubit.validateDescriptionsOfAllOptions();
|
||||
expect(result, true);
|
||||
});
|
||||
cubit.setSelectedOptionIndex(null);
|
||||
final result = cubit.validateDescriptionsOfAllOptions();
|
||||
expect(result, true);
|
||||
},
|
||||
);
|
||||
|
||||
test('validateDescriptionsOfAllOptions - возвращает false когда selectedOptionIndex == null и опция 0 невалидна', () {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionDescription('AB'); // невалидное описание
|
||||
cubit.setSelectedOptionIndex(null);
|
||||
test(
|
||||
'validateDescriptionsOfAllOptions - возвращает false когда selectedOptionIndex == null и опция 0 невалидна',
|
||||
() {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionDescription('AB'); // невалидное описание
|
||||
cubit.setSelectedOptionIndex(null);
|
||||
|
||||
final result = cubit.validateDescriptionsOfAllOptions();
|
||||
expect(result, false);
|
||||
});
|
||||
final result = cubit.validateDescriptionsOfAllOptions();
|
||||
expect(result, false);
|
||||
},
|
||||
);
|
||||
|
||||
test('validateItemsOfAllFilledOptions - возвращает true когда selectedOptionIndex == null и все items валидны', () {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionContent('Valid Item 1', 0);
|
||||
cubit.setSelectedOptionIndex(1);
|
||||
cubit.setOptionContent('Valid Item 2', 0);
|
||||
cubit.setSelectedOptionIndex(2);
|
||||
cubit.setOptionContent('Valid Item 3', 0);
|
||||
test(
|
||||
'validateItemsOfAllFilledOptions - возвращает true когда selectedOptionIndex == null и все items валидны',
|
||||
() {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setOptionContent('Valid Item 1', 0);
|
||||
cubit.setSelectedOptionIndex(1);
|
||||
cubit.setOptionContent('Valid Item 2', 0);
|
||||
cubit.setSelectedOptionIndex(2);
|
||||
cubit.setOptionContent('Valid Item 3', 0);
|
||||
|
||||
cubit.setSelectedOptionIndex(null);
|
||||
final result = cubit.validateItemsOfAllFilledOptions();
|
||||
expect(result, true);
|
||||
});
|
||||
cubit.setSelectedOptionIndex(null);
|
||||
final result = cubit.validateItemsOfAllFilledOptions();
|
||||
expect(result, true);
|
||||
},
|
||||
);
|
||||
|
||||
test('validateItemsOfAllFilledOptions - возвращает false когда selectedOptionIndex == null и опция 0 имеет пустые items', () {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
// items пустые
|
||||
cubit.setSelectedOptionIndex(null);
|
||||
test(
|
||||
'validateItemsOfAllFilledOptions - возвращает false когда selectedOptionIndex == null и опция 0 имеет пустые items',
|
||||
() {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
// items пустые
|
||||
cubit.setSelectedOptionIndex(null);
|
||||
|
||||
final result = cubit.validateItemsOfAllFilledOptions();
|
||||
expect(result, false);
|
||||
});
|
||||
final result = cubit.validateItemsOfAllFilledOptions();
|
||||
expect(result, false);
|
||||
},
|
||||
);
|
||||
|
||||
test('validatePriceOfAllFilledOptions - возвращает true когда все цены валидны', () {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setPrice(1500.0);
|
||||
cubit.setSelectedOptionIndex(1);
|
||||
cubit.setPrice(2000.0);
|
||||
cubit.setSelectedOptionIndex(2);
|
||||
cubit.setPrice(2500.0);
|
||||
test(
|
||||
'validatePriceOfAllFilledOptions - возвращает true когда все цены валидны',
|
||||
() {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setPrice(1500.0);
|
||||
cubit.setSelectedOptionIndex(1);
|
||||
cubit.setPrice(2000.0);
|
||||
cubit.setSelectedOptionIndex(2);
|
||||
cubit.setPrice(2500.0);
|
||||
|
||||
final result = cubit.validatePriceOfAllFilledOptions();
|
||||
expect(result, true);
|
||||
});
|
||||
final result = cubit.validatePriceOfAllFilledOptions();
|
||||
expect(result, true);
|
||||
},
|
||||
);
|
||||
|
||||
test('validatePriceOfAllFilledOptions - возвращает false когда опция 1 имеет невалидную цену', () {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setPrice(1500.0);
|
||||
cubit.setSelectedOptionIndex(1);
|
||||
cubit.setPrice(1000.0); // невалидная цена
|
||||
cubit.setSelectedOptionIndex(2);
|
||||
cubit.setPrice(2500.0);
|
||||
|
||||
final result = cubit.validatePriceOfAllFilledOptions();
|
||||
expect(result, false);
|
||||
});
|
||||
|
||||
test('setPlanType - не валидирует когда type.any((elem) => elem) == false', () {
|
||||
cubit.setPlanType([false, false, false, false]);
|
||||
expect(cubit.state.planData.type, [false, false, false, false]);
|
||||
// Валидация не должна вызываться, так как все элементы false
|
||||
});
|
||||
test(
|
||||
'validatePriceOfAllFilledOptions - возвращает false когда опция 1 имеет невалидную цену',
|
||||
() {
|
||||
cubit.setSelectedOptionIndex(0);
|
||||
cubit.setPrice(1500.0);
|
||||
cubit.setSelectedOptionIndex(1);
|
||||
cubit.setPrice(1000.0); // невалидная цена
|
||||
cubit.setSelectedOptionIndex(2);
|
||||
cubit.setPrice(2500.0);
|
||||
|
||||
final result = cubit.validatePriceOfAllFilledOptions();
|
||||
expect(result, false);
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'setPlanType - не валидирует когда type.any((elem) => elem) == false',
|
||||
() {
|
||||
cubit.setPlanType([false, false, false, false]);
|
||||
expect(cubit.state.planData.type, [false, false, false, false]);
|
||||
// Валидация не должна вызываться, так как все элементы false
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user