This repository has been archived by the owner on Jul 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Textfield_test.dart
64 lines (46 loc) · 1.96 KB
/
Textfield_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
@TestOn("chrome")
import 'package:test/test.dart';
import 'dart:html' as dom;
import "package:mdl/mdl.dart";
// import 'package:logging/logging.dart';
import '../config.dart';
main() async {
// final Logger _logger = new Logger("test.Formatter.Textfield");
configLogging();
final DomRenderer renderer = new DomRenderer();
final dom.DivElement parent = new dom.DivElement();
final String html = '''
<div class="mdl-textfield">
<input class="mdl-textfield__input" type="text" id="sample1" >
<label class="mdl-textfield__label" for="sample1" mdl-formatter="uppercase(value)">Type Something...</label>
</div>
'''.trim().replaceAll(new RegExp(r"\s+")," ");
group('Textfield', () {
setUp(() async {
await prepareMdlTest( () async {
await registerMaterialTextfield();
await registerMdlFormatterComponents();
});
});
test('> Uppercase', () async {
final dom.HtmlElement element = await renderer.render(parent,html);
await componentHandler().upgradeElement(element);
final MaterialTextfield widget = MaterialTextfield.widget(element);
expect(widget,isNotNull);
widget.value = "Mike";
expect(widget.value,"Mike");
}); // end of 'Uppercase' test
test('> Label', () async {
final dom.HtmlElement element = await renderer.render(parent,html);
await componentHandler().upgradeElement(element);
final MaterialTextfield widget = MaterialTextfield.widget(element);
expect(widget,isNotNull);
widget.label = "Name1";
expect(widget.label,"NAME1");
widget.value = "Mike";
expect(widget.value,"Mike");
}); // end of 'Label' test
});
// End of 'Textfield' group
}
// - Helper --------------------------------------------------------------------------------------