Skip to content

Commit

Permalink
test(client): explicitly skip non-VM
Browse files Browse the repository at this point in the history
Because we are using a workaround for running test on browser
we cannot rely only on `@TestOn("vm")`

```
# cannot `run pub run test test/.test_coverage.dart -p chromium`
# it randomly fails compiling some dart files to js
# test/.test_coverage.dart is a by product of running
# `pub run test_coverage`
pub run test test/.test_coverage.dart -p chromium
```
  • Loading branch information
truongsinh committed Jun 28, 2019
1 parent da49567 commit aa116a2
Showing 1 changed file with 48 additions and 40 deletions.
88 changes: 48 additions & 40 deletions packages/graphql/test/multipart_upload_io_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ void main() {
GraphQLClient graphQLClientClient;
MockHttpClient mockHttpClient;

group('upload', () {
const String uploadMutation = r'''
group(
'upload',
() {
const String uploadMutation = r'''
mutation($files: [Upload!]!) {
multipleUpload(files: $files) {
id
Expand All @@ -30,44 +32,45 @@ void main() {
}
''';

setUp(() {
mockHttpClient = MockHttpClient();
setUp(() {
mockHttpClient = MockHttpClient();

when(mockHttpClient.send(any)).thenAnswer((Invocation a) async {
return simpleResponse(body: '{"data": {}}');
});
when(mockHttpClient.send(any)).thenAnswer((Invocation a) async {
return simpleResponse(body: '{"data": {}}');
});

httpLink = HttpLink(
uri: 'http://localhost:3001/graphql', httpClient: mockHttpClient);
httpLink = HttpLink(
uri: 'http://localhost:3001/graphql', httpClient: mockHttpClient);

authLink = AuthLink(
getToken: () async => 'Bearer my-special-bearer-token',
);
authLink = AuthLink(
getToken: () async => 'Bearer my-special-bearer-token',
);

link = authLink.concat(httpLink);
link = authLink.concat(httpLink);

graphQLClientClient = GraphQLClient(
cache: getTestCache(),
link: link,
);
});
graphQLClientClient = GraphQLClient(
cache: getTestCache(),
link: link,
);
});

test('upload with io.File instance deprecation warning',
test(
'upload with io.File instance deprecation warning',
overridePrint((log) async {
final MutationOptions _options = MutationOptions(
document: uploadMutation,
variables: <String, dynamic>{
'files': [
io.File('pubspec.yaml'),
],
},
);
final QueryResult r = await graphQLClientClient.mutate(_options);

expect(r.errors, isNull);
expect(r.data, isNotNull);
expect(log, hasLength(5));
final warningMessage = r'''
final MutationOptions _options = MutationOptions(
document: uploadMutation,
variables: <String, dynamic>{
'files': [
io.File('pubspec.yaml'),
],
},
);
final QueryResult r = await graphQLClientClient.mutate(_options);

expect(r.errors, isNull);
expect(r.data, isNotNull);
expect(log, hasLength(5));
final warningMessage = r'''
⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️ DEPRECATION WARNING ⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️
Please do not use `File` direcly anymore. Instead, use
Expand All @@ -76,11 +79,16 @@ Please do not use `File` direcly anymore. Instead, use
⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️ DEPRECATION WARNING ⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️
''';
expect(log[0], warningMessage);
expect(log[1], warningMessage);
expect(log[2], warningMessage);
expect(log[3], warningMessage);
expect(log[4], warningMessage);
}));
});
expect(log[0], warningMessage);
expect(log[1], warningMessage);
expect(log[2], warningMessage);
expect(log[3], warningMessage);
expect(log[4], warningMessage);
}),
);
},
onPlatform: {
"!vm": Skip("This test is only for VM"),
},
);
}

0 comments on commit aa116a2

Please sign in to comment.