Skip to content

Commit

Permalink
chore(all): formatted dart files
Browse files Browse the repository at this point in the history
  • Loading branch information
tyllark committed Mar 4, 2025
1 parent 0f709a0 commit cd88a83
Show file tree
Hide file tree
Showing 1,696 changed files with 87,546 additions and 81,941 deletions.
101 changes: 57 additions & 44 deletions packages/amplify_datastore/test/amplify_datastore_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,61 +12,74 @@ void main() {
const mockSyncMaxRecords = 60000;
const mockSyncPagesize = 1000;

const MethodChannel dataStoreChannel =
MethodChannel('com.amazonaws.amplify/datastore');
const MethodChannel dataStoreChannel = MethodChannel(
'com.amazonaws.amplify/datastore',
);

AmplifyDataStore dataStore = AmplifyDataStore(
modelProvider: ModelProvider.instance,
options: DataStorePluginOptions(
syncExpressions: [
DataStoreSyncExpression(Blog.classType, () => Blog.NAME.eq('foo')),
DataStoreSyncExpression(Post.classType, () => Post.TITLE.eq('bar'))
],
syncInterval: mockSyncInterval,
syncMaxRecords: mockSyncMaxRecords,
syncPageSize: mockSyncPagesize));
modelProvider: ModelProvider.instance,
options: DataStorePluginOptions(
syncExpressions: [
DataStoreSyncExpression(Blog.classType, () => Blog.NAME.eq('foo')),
DataStoreSyncExpression(Post.classType, () => Post.TITLE.eq('bar')),
],
syncInterval: mockSyncInterval,
syncMaxRecords: mockSyncMaxRecords,
syncPageSize: mockSyncPagesize,
),
);

final binding = TestWidgetsFlutterBinding.ensureInitialized();

tearDown(() {
binding.defaultBinaryMessenger
.setMockMethodCallHandler(dataStoreChannel, null);
});

test('DataStore custom configuration should be passed via MethodChannel',
() async {
var expectedBlogExpression =
await getJsonFromFile('sync_expressions/blog_name.json');
var expectedPostExpression =
await getJsonFromFile('sync_expressions/post_title.json');
binding.defaultBinaryMessenger.setMockMethodCallHandler(
dataStoreChannel,
(MethodCall methodCall) async {
if (methodCall.method == "configureDataStore") {
final modelSchemas = methodCall.arguments['modelSchemas'];
final syncExpressions = methodCall.arguments['syncExpressions'];
final syncInterval = methodCall.arguments['syncInterval'];
final syncMaxRecords = methodCall.arguments['syncMaxRecords'];
final syncPageSize = methodCall.arguments['syncPageSize'];
null,
);
});

expect(
test(
'DataStore custom configuration should be passed via MethodChannel',
() async {
var expectedBlogExpression = await getJsonFromFile(
'sync_expressions/blog_name.json',
);
var expectedPostExpression = await getJsonFromFile(
'sync_expressions/post_title.json',
);
binding.defaultBinaryMessenger.setMockMethodCallHandler(
dataStoreChannel,
(MethodCall methodCall) async {
if (methodCall.method == "configureDataStore") {
final modelSchemas = methodCall.arguments['modelSchemas'];
final syncExpressions = methodCall.arguments['syncExpressions'];
final syncInterval = methodCall.arguments['syncInterval'];
final syncMaxRecords = methodCall.arguments['syncMaxRecords'];
final syncPageSize = methodCall.arguments['syncPageSize'];

expect(
modelSchemas,
ModelProvider.instance.modelSchemas
.map((schema) => schema.toMap())
.toList());
expect(syncExpressions.map((expression) {
// Ignore generated ID
(expression as Map).remove("id");
return expression;
}), [expectedBlogExpression, expectedPostExpression]);
expect(syncInterval, mockSyncInterval);
expect(syncMaxRecords, mockSyncMaxRecords);
expect(syncPageSize, mockSyncPagesize);
}
return null;
},
);
.toList(),
);
expect(
syncExpressions.map((expression) {
// Ignore generated ID
(expression as Map).remove("id");
return expression;
}),
[expectedBlogExpression, expectedPostExpression],
);
expect(syncInterval, mockSyncInterval);
expect(syncMaxRecords, mockSyncMaxRecords);
expect(syncPageSize, mockSyncPagesize);
}
return null;
},
);

await dataStore.configureDataStore();
});
await dataStore.configureDataStore();
},
);
}
Loading

0 comments on commit cd88a83

Please sign in to comment.