Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyokone committed Dec 18, 2024
1 parent ab406e1 commit 296f3e0
Showing 1 changed file with 25 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,18 @@ void runVectorValueTests() {
DocumentReference<Map<String, dynamic>> doc =
await initializeTest('vector-value-empty');

await doc.set({
'foo': const VectorValue([]),
});

DocumentSnapshot<Map<String, dynamic>> snapshot = await doc.get();

VectorValue vectorValue = snapshot.data()!['foo'];
expect(vectorValue, isA<VectorValue>());
expect(vectorValue.toArray(), equals([]));
try {
await doc.set({
'foo': const VectorValue([]),
});
fail('Should have thrown an exception');
} catch (e) {
expect(e, isA<FirebaseException>());
expect(
(e as FirebaseException).code.contains('invalid-argument'),
isTrue,
);
}
});

testWidgets('handles single dimension vector', (_) async {
Expand Down Expand Up @@ -106,15 +109,19 @@ void runVectorValueTests() {
DocumentReference<Map<String, dynamic>> doc =
await initializeTest('vector-value-max-plus-one');

await doc.set({
'foo': VectorValue(maxPlusOneDimensions),
});

DocumentSnapshot<Map<String, dynamic>> snapshot = await doc.get();

VectorValue vectorValue = snapshot.data()!['foo'];
expect(vectorValue, isA<VectorValue>());
expect(vectorValue.toArray(), equals(maxPlusOneDimensions));
try {
await doc.set({
'foo': VectorValue(maxPlusOneDimensions),
});

fail('Should have thrown an exception');
} catch (e) {
expect(e, isA<FirebaseException>());
expect(
(e as FirebaseException).code.contains('invalid-argument'),
isTrue,
);
}
});

testWidgets('handles very large values in vector', (_) async {
Expand Down

0 comments on commit 296f3e0

Please sign in to comment.