Skip to content

Commit

Permalink
Address deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronlademann-wf committed Jul 10, 2017
1 parent bc46e9c commit ba42767
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 17 deletions.
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ dev_dependencies:
coverage: "^0.7.2"
dart_dev: "^1.7.6"
mockito: "^0.11.0"
over_react_test: "^1.0.0"
test: "^0.12.6+2"
over_react_test: "^1.0.1"
test: "^0.12.24"

transformers:
- over_react:
Expand Down
4 changes: 3 additions & 1 deletion test/over_react/component/prop_mixins_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ library prop_mixins_test;
import 'dart:collection' show MapView;

import 'package:over_react/over_react.dart';
import 'package:over_react_test/over_react_test.dart';
import 'package:test/test.dart';

import '../../wsd_test_util/prop_utils.dart';
Expand Down Expand Up @@ -68,7 +69,8 @@ main() {
group('AriaProps', () {
test('cannot set / read values that are not its prop map', () {
var instance = new AriaPropMixinsTest({});
expect(() {instance['notThere'];}, throws);
expect(() {instance['notThere'];},
throwsA(hasToStringValue(contains('Map does not contain this key'))));
});

for (var propKey in const $PropKeys(AriaPropsMixin)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ main() {
});

test('when a single non-invoked builder child is passed in', () {
expect(() => Dom.div()(Dom.div()), throws);
expect(() => Dom.div()(Dom.div()), throwsArgumentError);
verifyValidationWarning(contains('It looks like you are trying to use a non-invoked builder as a child.'));
});

Expand Down Expand Up @@ -158,7 +158,7 @@ main() {
Dom.div(),
Dom.p()(),
Dom.div()
]), throws);
]), throwsArgumentError);
verifyValidationWarning(contains('It looks like you are trying to use a non-invoked builder as a child.'));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ library over_react.transformer_generation.helpers_test;
import 'package:over_react/src/component_declaration/transformer_helpers.dart';
import 'package:test/test.dart';

const Matcher throwsUngeneratedError = const Throws(const isInstanceOf<UngeneratedError>());
const Matcher throwsIllegalInstantiationError = const Throws(const isInstanceOf<IllegalInstantiationError>());
final Matcher throwsUngeneratedError = throwsA(const isInstanceOf<UngeneratedError>());
final Matcher throwsIllegalInstantiationError = throwsA(const isInstanceOf<IllegalInstantiationError>());

main() {
group('transformation generation helpers:', () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ main() {
test('state class cannot be instantiated directly', () {
expect(() {
new StatefulComponentTestState();
}, throws);
}, throwsA(const isInstanceOf<IllegalInstantiationError>()));
});

test('renders a component from end to end, successfully reading state via typed getters', () {
Expand Down
9 changes: 6 additions & 3 deletions test/over_react/util/handler_chain_util_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ main() {

var chained = callbackUtil.chain(a, b);

expect(() => Function.apply(chained, generateBadTypeArgs()), throws);
expect(() => Function.apply(chained, generateBadTypeArgs()),
throwsA(const isInstanceOf<TypeError>()));
}, testOn: 'dart-vm');
}
});
Expand Down Expand Up @@ -245,7 +246,8 @@ main() {

var chained = callbackUtil.chainFromList(functions);

expect(() => Function.apply(chained, generateBadTypeArgs()), throws);
expect(() => Function.apply(chained, generateBadTypeArgs()),
throwsA(const isInstanceOf<TypeError>()));
}, testOn: 'dart-vm');
}
});
Expand All @@ -257,7 +259,8 @@ main() {

if (arity != 0) {
test('with arguments typed to the specified generic parameters', () {
expect(() => Function.apply(callbackUtil.noop, generateBadTypeArgs()), throws);
expect(() => Function.apply(callbackUtil.noop, generateBadTypeArgs()),
throwsA(const isInstanceOf<TypeError>()));
}, testOn: 'dart-vm');
}
});
Expand Down
8 changes: 5 additions & 3 deletions test/wsd_test_util/prop_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,22 @@ library test_util.prop_utils;
])
import 'dart:mirrors';

import 'package:over_react_test/over_react_test.dart';
import 'package:test/test.dart';

void testProp (Symbol name, dynamic expectedKey, instance, testValue) {
void testProp(Symbol name, dynamic expectedKey, instance, testValue) {
InstanceMirror mirror = reflect(instance);

mirror.setField(name, testValue);
expect(instance[expectedKey], equals(testValue));
expect(mirror.getField(name).reflectee, equals(testValue));
}

void testKeys (List<String> keys, dynamic instanceBuilder()) {
void testKeys(List<String> keys, dynamic instanceBuilder()) {
test('cannot set / read values that are not its prop map', () {
var instance = instanceBuilder();
expect(() {instance['notThere'];}, throws);
expect(() {instance['notThere'];},
throwsA(hasToStringValue(contains('Map does not contain this key'))));
});
for (var propKey in keys) {
test('prop: $propKey can have its value set / read', () {
Expand Down
10 changes: 7 additions & 3 deletions test/wsd_test_util/zone.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ void storeZone([Zone zone]) {
/// Calls [expect] in package:test/test.dart in the zone stored in [setZone].
///
/// Useful for expectations in blocks called in other zones.
void zonedExpect(actual, matcher,
{String reason, bool verbose: false, ErrorFormatter formatter}) {
void zonedExpect(actual, matcher, {
String reason,
@Deprecated("Will be removed when we upgrade to dart-lang/test 0.13.0.") bool verbose: false,
// ignore: deprecated_member_use
@Deprecated("Will be removed when we upgrade to dart-lang/test 0.13.0.") ErrorFormatter formatter
}) {
validateZone();

return _zone.run(() {
expect(actual, matcher, verbose: verbose, formatter: formatter);
expect(actual, matcher, verbose: verbose, formatter: formatter); // ignore: deprecated_member_use
});
}

0 comments on commit ba42767

Please sign in to comment.