|
| 1 | +import 'package:emailjs/src/utils/validate_params.dart'; |
| 2 | +import 'package:flutter_test/flutter_test.dart'; |
| 3 | + |
| 4 | +void main() { |
| 5 | + group('should fail on the public key', () { |
| 6 | + test('no key', () { |
| 7 | + expect( |
| 8 | + () => validateParams('', 'default_service', 'my_test_template'), |
| 9 | + throwsA(startsWith('The public key is required')), |
| 10 | + ); |
| 11 | + }); |
| 12 | + |
| 13 | + test('no string', () { |
| 14 | + expect( |
| 15 | + () => validateParams(null, 'default_service', 'my_test_template'), |
| 16 | + throwsA(startsWith('The public key is required')), |
| 17 | + ); |
| 18 | + }); |
| 19 | + }); |
| 20 | + |
| 21 | + group('should fail on the service ID', () { |
| 22 | + test('no key', () { |
| 23 | + expect( |
| 24 | + () => validateParams('d2JWGTestKeySomething', '', 'my_test_template'), |
| 25 | + throwsA(startsWith('The service ID is required')), |
| 26 | + ); |
| 27 | + }); |
| 28 | + |
| 29 | + test('no string', () { |
| 30 | + expect( |
| 31 | + () => validateParams('d2JWGTestKeySomething', null, 'my_test_template'), |
| 32 | + throwsA(startsWith('The service ID is required')), |
| 33 | + ); |
| 34 | + }); |
| 35 | + }); |
| 36 | + |
| 37 | + group('should fail on the service ID', () { |
| 38 | + test('no key', () { |
| 39 | + expect( |
| 40 | + () => validateParams('d2JWGTestKeySomething', 'default_service', ''), |
| 41 | + throwsA(startsWith('The template ID is required')), |
| 42 | + ); |
| 43 | + }); |
| 44 | + |
| 45 | + test('no string', () { |
| 46 | + expect( |
| 47 | + () => validateParams('d2JWGTestKeySomething', 'default_service', null), |
| 48 | + throwsA(startsWith('The template ID is required')), |
| 49 | + ); |
| 50 | + }); |
| 51 | + }); |
| 52 | + |
| 53 | + test('should successfully pass the validation', () { |
| 54 | + expect( |
| 55 | + () => validateParams('d2JWGTestKeySomething', 'default_service', 'my_test_template'), |
| 56 | + returnsNormally, |
| 57 | + ); |
| 58 | + }); |
| 59 | +} |
0 commit comments