use mokito in the init tests
This commit is contained in:
@@ -4,11 +4,13 @@
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:args/args.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:sky_tools/src/init.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'src/common.dart';
|
||||
|
||||
main() => defineTests();
|
||||
|
||||
defineTests() {
|
||||
@@ -26,10 +28,11 @@ defineTests() {
|
||||
// Verify that we create a project that is well-formed.
|
||||
test('init sky-simple', () async {
|
||||
InitCommandHandler handler = new InitCommandHandler();
|
||||
_MockArgResults results = new _MockArgResults();
|
||||
results.values['help'] = false;
|
||||
results.values['pub'] = true;
|
||||
results.values['out'] = temp.path;
|
||||
MockArgResults results = new MockArgResults();
|
||||
when(results['help']).thenReturn(false);
|
||||
when(results['pub']).thenReturn(true);
|
||||
when(results.wasParsed('out')).thenReturn(true);
|
||||
when(results['out']).thenReturn(temp.path);
|
||||
await handler.processArgResults(results);
|
||||
String path = p.join(temp.path, 'lib/main.dart');
|
||||
expect(new File(path).existsSync(), true);
|
||||
@@ -40,14 +43,3 @@ defineTests() {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
class _MockArgResults implements ArgResults {
|
||||
Map values = {};
|
||||
operator [](String name) => values[name];
|
||||
List<String> get arguments => null;
|
||||
ArgResults get command => null;
|
||||
String get name => null;
|
||||
Iterable<String> get options => values.keys;
|
||||
List<String> get rest => null;
|
||||
bool wasParsed(String name) => values.containsKey(name);
|
||||
}
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
|
||||
library install_test;
|
||||
|
||||
import 'package:args/args.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:sky_tools/src/install.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'src/common.dart';
|
||||
|
||||
main() => defineTests();
|
||||
|
||||
defineTests() {
|
||||
@@ -23,9 +24,3 @@ defineTests() {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@proxy
|
||||
class MockArgResults extends Mock implements ArgResults {
|
||||
@override
|
||||
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
||||
}
|
||||
|
||||
12
packages/flutter_tools/test/src/common.dart
Normal file
12
packages/flutter_tools/test/src/common.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:args/args.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
|
||||
@proxy
|
||||
class MockArgResults extends Mock implements ArgResults {
|
||||
@override
|
||||
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
||||
}
|
||||
Reference in New Issue
Block a user