Skip to content

Commit 2cccc6f

Browse files
committed
fix tests
1 parent adf4ba1 commit 2cccc6f

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

test/model_test.dart

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -635,36 +635,45 @@ void main() {
635635
});
636636

637637
group('Parameter', () {
638-
Class c, f;
638+
Class c, fClass;
639639
Method isGreaterThan, asyncM, methodWithGenericParam, paramFromExportLib;
640-
Parameter p1;
640+
Parameter intNumber, intCheckOptional;
641641

642642
setUp(() {
643643
c = exLibrary.classes.firstWhere((c) => c.name == 'Apple');
644-
isGreaterThan = c.instanceMethods[2]; // isGreaterThan
645-
paramFromExportLib = c.instanceMethods[3];
644+
paramFromExportLib =
645+
c.instanceMethods.singleWhere((m) => m.name == 'paramFromExportLib');
646+
isGreaterThan =
647+
c.instanceMethods.singleWhere((m) => m.name == 'isGreaterThan');
646648
asyncM = exLibrary.classes
647649
.firstWhere((c) => c.name == 'Dog').instanceMethods
648650
.firstWhere((m) => m.name == 'foo');
649-
p1 = isGreaterThan.parameters[1]; // {int check:5}
650-
f = exLibrary.classes.firstWhere((c) => c.name == 'F');
651-
methodWithGenericParam = f.instanceMethods[0];
651+
intNumber = isGreaterThan.parameters.first;
652+
intCheckOptional = isGreaterThan.parameters.last;
653+
fClass = exLibrary.classes.firstWhere((c) => c.name == 'F');
654+
methodWithGenericParam = fClass.instanceMethods
655+
.singleWhere((m) => m.name == 'methodWithGenericParam');
656+
});
657+
658+
test('has parameters', () {
659+
expect(isGreaterThan.parameters, hasLength(2));
652660
});
653661

654662
test('is optional', () {
655-
expect(p1.isOptional, isTrue);
663+
expect(intCheckOptional.isOptional, isTrue);
664+
expect(intNumber.isOptional, isFalse);
656665
});
657666

658667
test('default value', () {
659-
expect(p1.defaultValue, '5');
668+
expect(intCheckOptional.defaultValue, '5');
660669
});
661670

662671
test('is named', () {
663-
expect(p1.isOptionalNamed, isTrue);
672+
expect(intCheckOptional.isOptionalNamed, isTrue);
664673
});
665674

666675
test('linkedName', () {
667-
expect(p1.modelType.linkedName, 'int');
676+
expect(intCheckOptional.modelType.linkedName, 'int');
668677
});
669678

670679
test('async return type', () {
@@ -678,6 +687,7 @@ void main() {
678687

679688
test('param exported in library', () {
680689
var param = paramFromExportLib.parameters[0];
690+
expect(param.name, equals('helper'));
681691
expect(param.library.name, equals('ex'));
682692
});
683693
});
@@ -754,7 +764,9 @@ void main() {
754764
});
755765

756766
test('methods has the right annotation', () {
757-
expect(dog.instanceMethods.first.annotations.first, equals('deprecated'));
767+
var m = dog.instanceMethods.singleWhere((m) => m.name == 'getClassA');
768+
expect(m.hasAnnotations, isTrue);
769+
expect(m.annotations.first, equals('deprecated'));
758770
});
759771
});
760772
}

0 commit comments

Comments
 (0)