forked from larryaasen/upgrader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upgrade_messages_test.dart
76 lines (67 loc) · 2.81 KB
/
upgrade_messages_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Copyright (c) 2020 Larry Aasen. All rights reserved.
*/
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:upgrader/upgrader.dart';
void main() {
test('testing UpgraderMessages valid', () async {
expect(UpgraderMessages(), isNotNull);
expect(() => UpgraderMessages(code: null), isNotNull);
expect(() => UpgraderMessages(code: ''), throwsAssertionError);
expect(() => UpgraderMessages(code: '0'), isNotNull);
});
testWidgets('test UpgraderMessages context', (WidgetTester tester) async {
final messages = UpgraderMessages();
expect(messages, isNotNull);
var expectationMet = false;
var widget = const Text('Tester');
await tester.pumpWidget(
StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
final code = UpgraderMessages.findLanguageCode(context: context);
expect(code, 'en');
expectationMet = true;
return MaterialApp(
home: Material(
child: Center(
child: widget,
),
),
);
},
),
);
expect(find.byWidget(widget), findsOneWidget);
expect(expectationMet, isTrue);
});
testWidgets('test UpgraderMessages es', (WidgetTester tester) async {
final messages = UpgraderMessages(code: 'es');
expect(messages, isNotNull);
expect(messages.body,
'¡Una nueva versión de {{appName}} está disponible! La versión {{currentAppStoreVersion}} ya está disponible-usted tiene {{currentInstalledVersion}}.');
expect(messages.buttonTitleIgnore, 'IGNORAR');
expect(messages.buttonTitleLater, 'MÁS TARDE');
expect(messages.buttonTitleUpdate, 'ACTUALIZAR');
expect(messages.prompt, '¿Le gustaría actualizar ahora?');
expect(messages.releaseNotes, 'Notas De Lanzamiento');
expect(messages.title, '¿Actualizar la aplicación?');
});
test('test UpgraderMessages unknown language code', () {
final bb = UpgraderMessages(code: 'bb'); // unknown language code
final en = UpgraderMessages(code: 'en'); // English language code
expect(bb.message(UpgraderMessage.body), en.message(UpgraderMessage.body));
expect(bb.message(UpgraderMessage.buttonTitleIgnore),
en.message(UpgraderMessage.buttonTitleIgnore));
expect(bb.message(UpgraderMessage.buttonTitleLater),
en.message(UpgraderMessage.buttonTitleLater));
expect(bb.message(UpgraderMessage.buttonTitleUpdate),
en.message(UpgraderMessage.buttonTitleUpdate));
expect(
bb.message(UpgraderMessage.prompt), en.message(UpgraderMessage.prompt));
expect(bb.message(UpgraderMessage.releaseNotes),
en.message(UpgraderMessage.releaseNotes));
expect(
bb.message(UpgraderMessage.title), en.message(UpgraderMessage.title));
});
}