-
-
Notifications
You must be signed in to change notification settings - Fork 628
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #433 from klavs/raw-operation-tests
test(client): add tests for `operationName` getter
- Loading branch information
Showing
1 changed file
with
126 additions
and
0 deletions.
There are no files selected for viewing
126 changes: 126 additions & 0 deletions
126
packages/graphql/test/core/raw_operation_data_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
import 'package:graphql/src/core/raw_operation_data.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group('operation name', () { | ||
group('single operation', () { | ||
test('query without name', () { | ||
final opData = RawOperationData( | ||
document: 'query {}', | ||
); | ||
|
||
expect(opData.operationName, null); | ||
}); | ||
|
||
test('query with explicit name', () { | ||
final opData = RawOperationData( | ||
document: 'query Operation {}', | ||
operationName: 'Operation', | ||
); | ||
|
||
expect(opData.operationName, 'Operation'); | ||
}); | ||
|
||
test('mutation with explicit name', () { | ||
final opData = RawOperationData( | ||
document: 'mutation Operation {}', | ||
operationName: 'Operation', | ||
); | ||
|
||
expect(opData.operationName, 'Operation'); | ||
}); | ||
|
||
test('subscription with explicit name', () { | ||
final opData = RawOperationData( | ||
document: 'subscription Operation {}', | ||
operationName: 'Operation', | ||
); | ||
|
||
expect(opData.operationName, 'Operation'); | ||
}); | ||
|
||
test('query with implicit name', () { | ||
final opData = RawOperationData( | ||
document: 'query Operation {}', | ||
); | ||
|
||
expect(opData.operationName, 'Operation'); | ||
}); | ||
|
||
test('mutation with implicit name', () { | ||
final opData = RawOperationData( | ||
document: 'mutation Operation {}', | ||
); | ||
|
||
expect(opData.operationName, 'Operation'); | ||
}); | ||
|
||
test('subscription with implicit name', () { | ||
final opData = RawOperationData( | ||
document: 'subscription Operation {}', | ||
); | ||
|
||
expect(opData.operationName, 'Operation'); | ||
}); | ||
}); | ||
|
||
group('multiple operations', () { | ||
const document = r''' | ||
query OperationQ {} | ||
mutation OperationM {} | ||
subscription OperationS {} | ||
'''; | ||
|
||
test('query with explicit name', () { | ||
final opData = RawOperationData( | ||
document: document, | ||
operationName: 'OperationQ', | ||
); | ||
|
||
expect(opData.operationName, 'OperationQ'); | ||
}); | ||
|
||
test('mutation with explicit name', () { | ||
final opData = RawOperationData( | ||
document: document, | ||
operationName: 'OperationM', | ||
); | ||
|
||
expect(opData.operationName, 'OperationM'); | ||
}); | ||
|
||
test('subscription with explicit name', () { | ||
final opData = RawOperationData( | ||
document: document, | ||
operationName: 'OperationS', | ||
); | ||
|
||
expect(opData.operationName, 'OperationS'); | ||
}); | ||
|
||
test('query with implicit name', () { | ||
final opData = RawOperationData( | ||
document: document, | ||
); | ||
|
||
expect(opData.operationName, 'OperationS'); | ||
}); | ||
|
||
test('mutation with implicit name', () { | ||
final opData = RawOperationData( | ||
document: document, | ||
); | ||
|
||
expect(opData.operationName, 'OperationS'); | ||
}); | ||
|
||
test('subscription with implicit name', () { | ||
final opData = RawOperationData( | ||
document: document, | ||
); | ||
|
||
expect(opData.operationName, 'OperationS'); | ||
}); | ||
}); | ||
}); | ||
} |