Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Unified Diff: pkg/dev_compiler/test/codegen/lib/html/localstorage_test.dart

Issue 2419863002: Remove uses of unittest in the HTML tests where possible. (Closed)
Patch Set: Remove TODO. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/dev_compiler/test/codegen/lib/html/localstorage_test.dart
diff --git a/pkg/dev_compiler/test/codegen/lib/html/localstorage_test.dart b/pkg/dev_compiler/test/codegen/lib/html/localstorage_test.dart
index 3e92b10dc7e0ad6256c8455418b22ae6b8e20629..2ed126ec93e235553abaa24d2876bea32d1057ac 100644
--- a/pkg/dev_compiler/test/codegen/lib/html/localstorage_test.dart
+++ b/pkg/dev_compiler/test/codegen/lib/html/localstorage_test.dart
@@ -2,49 +2,42 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-library LocalStorageTest;
-import 'package:unittest/unittest.dart';
-import 'package:unittest/html_config.dart';
import 'dart:html';
+import 'package:expect/minitest.dart';
+
main() {
- useHtmlConfiguration();
-
- void testWithLocalStorage(String name, fn()) {
- test(name, () {
- window.localStorage['key1'] = 'val1';
- window.localStorage['key2'] = 'val2';
- window.localStorage['key3'] = 'val3';
-
- try {
- fn();
- } finally {
- window.localStorage.clear();
- }
- });
- }
+ setUp(() {
+ window.localStorage['key1'] = 'val1';
+ window.localStorage['key2'] = 'val2';
+ window.localStorage['key3'] = 'val3';
+ });
+
+ tearDown(() {
+ window.localStorage.clear();
+ });
- testWithLocalStorage('containsValue', () {
+ test('containsValue', () {
expect(window.localStorage.containsValue('does not exist'), isFalse);
expect(window.localStorage.containsValue('key1'), isFalse);
expect(window.localStorage.containsValue('val1'), isTrue);
expect(window.localStorage.containsValue('val3'), isTrue);
});
- testWithLocalStorage('containsKey', () {
+ test('containsKey', () {
expect(window.localStorage.containsKey('does not exist'), isFalse);
expect(window.localStorage.containsKey('val1'), isFalse);
expect(window.localStorage.containsKey('key1'), isTrue);
expect(window.localStorage.containsKey('key3'), isTrue);
});
- testWithLocalStorage('[]', () {
+ test('[]', () {
expect(window.localStorage['does not exist'], isNull);
expect(window.localStorage['key1'], 'val1');
expect(window.localStorage['key3'], 'val3');
});
- testWithLocalStorage('[]=', () {
+ test('[]=', () {
expect(window.localStorage['key4'], isNull);
window.localStorage['key4'] = 'val4';
expect(window.localStorage['key4'], 'val4');
@@ -54,29 +47,32 @@ main() {
expect(window.localStorage['key3'], 'val3-new');
});
- testWithLocalStorage('putIfAbsent', () {
+ test('putIfAbsent', () {
expect(window.localStorage['key4'], isNull);
expect(window.localStorage.putIfAbsent('key4', () => 'val4'), 'val4');
expect(window.localStorage['key4'], 'val4');
expect(window.localStorage['key3'], 'val3');
expect(window.localStorage.putIfAbsent('key3',
- () => expect(false, isTrue, reason: 'should not be called')), 'val3');
+ () {
+ fail('should not be called');
+ return 'unused';
+ }), 'val3');
expect(window.localStorage['key3'], 'val3');
});
- testWithLocalStorage('remove', () {
+ test('remove', () {
expect(window.localStorage.remove('does not exist'), isNull);
expect(window.localStorage.remove('key3'), 'val3');
expect(window.localStorage, equals({'key1': 'val1', 'key2': 'val2'}));
});
- testWithLocalStorage('clear', () {
+ test('clear', () {
window.localStorage.clear();
expect(window.localStorage, equals({}));
});
- testWithLocalStorage('forEach', () {
+ test('forEach', () {
Map<String, String> results = {};
window.localStorage.forEach((k, v) {
results[k] = v;
@@ -84,23 +80,23 @@ main() {
expect(results, equals({'key1': 'val1', 'key2': 'val2', 'key3': 'val3'}));
});
- testWithLocalStorage('getKeys', () {
+ test('getKeys', () {
expect(window.localStorage.keys.toList(),
unorderedEquals(['key1', 'key2', 'key3']));
});
- testWithLocalStorage('getVals', () {
+ test('getVals', () {
expect(window.localStorage.values.toList(),
unorderedEquals(['val1', 'val2', 'val3']));
});
- testWithLocalStorage('length', () {
+ test('length', () {
expect(window.localStorage.length, 3);
window.localStorage.clear();
expect(window.localStorage.length, 0);
});
- testWithLocalStorage('isEmpty', () {
+ test('isEmpty', () {
expect(window.localStorage.isEmpty, isFalse);
window.localStorage.clear();
expect(window.localStorage.isEmpty, isTrue);

Powered by Google App Engine
This is Rietveld 408576698