Skip to content

Commit 17e4ef3

Browse files
committed
Fix firestore tests
1 parent 322d629 commit 17e4ef3

File tree

7 files changed

+16
-16
lines changed
  • firebase-common/src/jsMain/kotlin/dev/gitlive/firebase/externals
  • firebase-firestore/src

7 files changed

+16
-16
lines changed

firebase-common/src/jsMain/kotlin/dev/gitlive/firebase/externals/app/app.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ external fun initializeApp(options: Any, name: String = definedExternally): Fire
77

88
external fun getApp(name: String = definedExternally): FirebaseApp
99

10-
external fun getApps(): List<FirebaseApp>
10+
external fun getApps(): Array<FirebaseApp>
1111

1212
external interface FirebaseApp {
1313
val automaticDataCollectionEnabled: Boolean

firebase-common/src/jsMain/kotlin/dev/gitlive/firebase/externals/firestore/firestore.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ external fun getDoc(
6666
options: Any? = definedExternally
6767
): Promise<DocumentSnapshot>
6868

69-
external fun get(query: Query): Promise<QuerySnapshot>
69+
external fun getDocs(query: Query): Promise<QuerySnapshot>
7070

7171
external fun getFirestore(app: FirebaseApp? = definedExternally): Firestore
7272

@@ -125,16 +125,16 @@ external fun startAt(document: DocumentSnapshot): QueryConstraint
125125

126126
external fun startAt(vararg fieldValues: Any): QueryConstraint
127127

128-
external fun update(reference: DocumentReference, data: Any): Promise<Unit>
128+
external fun updateDoc(reference: DocumentReference, data: Any): Promise<Unit>
129129

130-
external fun update(
130+
external fun updateDoc(
131131
reference: DocumentReference,
132132
field: String,
133133
value: Any?,
134134
vararg moreFieldsAndValues: Any?
135135
): Promise<Unit>
136136

137-
external fun update(
137+
external fun updateDoc(
138138
reference: DocumentReference,
139139
field: FieldPath,
140140
value: Any?,
@@ -173,9 +173,9 @@ external interface DocumentReference {
173173
external interface DocumentSnapshot {
174174
val id: String
175175
val ref: DocumentReference
176-
val exists: Boolean
177176
val metadata: SnapshotMetadata
178177
fun data(options: Any? = definedExternally): Any?
178+
fun exists(): Boolean
179179
fun get(fieldPath: String, options: Any? = definedExternally): Any?
180180
fun get(fieldPath: FieldPath, options: Any? = definedExternally): Any?
181181
}

firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ actual class FieldPath private constructor(val android: com.google.firebase.fire
471471
}
472472

473473
actual object FieldValue {
474-
actual val serverTimestamp: Any = Double.POSITIVE_INFINITY
474+
actual val serverTimestamp: Double = Double.POSITIVE_INFINITY
475475
actual val delete: Any get() = FieldValue.delete()
476476
actual fun increment(value: Int): Any = FieldValue.increment(value.toDouble())
477477
actual fun arrayUnion(vararg elements: Any): Any = FieldValue.arrayUnion(*elements)

firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ expect class FieldPath(vararg fieldNames: String) {
241241
}
242242

243243
expect object FieldValue {
244-
val serverTimestamp: Any
244+
val serverTimestamp: Double
245245
val delete: Any
246246
fun increment(value: Int): Any
247247
fun arrayUnion(vararg elements: Any): Any

firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ class FirebaseFirestoreTest {
3232

3333
@Serializable
3434
data class FirestoreTest(
35-
val prop1: String,
35+
val prop1: String,
3636
val time: Double = 0.0,
37-
val count: Int = 0,
37+
val count: Int = 0,
3838
val list: List<String> = emptyList(),
3939
)
4040

firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ actual class FieldPath private constructor(val ios: FIRFieldPath) {
444444
}
445445

446446
actual object FieldValue {
447-
actual val serverTimestamp: Any = Double.POSITIVE_INFINITY
447+
actual val serverTimestamp: Double = Double.POSITIVE_INFINITY
448448
actual val delete: Any get() = FIRFieldValue.fieldValueForDelete()
449449
actual fun increment(value: Int): Any = FIRFieldValue.fieldValueForIntegerIncrement(value.toLong())
450450
actual fun arrayUnion(vararg elements: Any): Any = FIRFieldValue.fieldValueForArrayUnion(elements.asList())

firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import dev.gitlive.firebase.externals.firestore.arrayUnion as jsArrayUnion
2929
import dev.gitlive.firebase.externals.firestore.endAt as jsEndAt
3030
import dev.gitlive.firebase.externals.firestore.endBefore as jsEndBefore
3131
import dev.gitlive.firebase.externals.firestore.increment as jsIncrement
32-
import dev.gitlive.firebase.externals.firestore.update as jsUpdate
32+
import dev.gitlive.firebase.externals.firestore.updateDoc as jsUpdate
3333
import dev.gitlive.firebase.externals.firestore.limit as jsLimit
3434
import dev.gitlive.firebase.externals.firestore.startAfter as jsStartAfter
3535
import dev.gitlive.firebase.externals.firestore.startAt as jsStartAt
@@ -284,7 +284,7 @@ actual class DocumentReference(val js: JsDocumentReference) {
284284
actual suspend fun update(vararg fieldsAndValues: Pair<FieldPath, Any?>) = rethrow {
285285
js.takeUnless { fieldsAndValues.isEmpty() }?.let {
286286
jsUpdate(
287-
js,
287+
it,
288288
fieldsAndValues[0].first.js,
289289
fieldsAndValues[0].second,
290290
*fieldsAndValues.flatMap { (field, value) ->
@@ -310,7 +310,7 @@ actual class DocumentReference(val js: JsDocumentReference) {
310310

311311
actual open class Query(open val js: JsQuery) {
312312

313-
actual suspend fun get() = rethrow { QuerySnapshot(get(js).await()) }
313+
actual suspend fun get() = rethrow { QuerySnapshot(getDocs(js).await()) }
314314

315315
actual fun limit(limit: Number) = Query(query(js, jsLimit(limit)))
316316

@@ -462,7 +462,7 @@ actual class DocumentSnapshot(val js: JsDocumentSnapshot) {
462462
rethrow { decode(strategy, js.get(field, getTimestampsOptions(serverTimestampBehavior))) }
463463

464464
actual fun contains(field: String) = rethrow { js.get(field) != undefined }
465-
actual val exists get() = rethrow { js.exists }
465+
actual val exists get() = rethrow { js.exists() }
466466
actual val metadata: SnapshotMetadata get() = SnapshotMetadata(js.metadata)
467467

468468
fun getTimestampsOptions(serverTimestampBehavior: ServerTimestampBehavior) =
@@ -482,7 +482,7 @@ actual class FieldPath private constructor(val js: JsFieldPath) {
482482
}
483483

484484
actual object FieldValue {
485-
actual val serverTimestamp: Any = serverTimestamp()
485+
actual val serverTimestamp: Double = Double.POSITIVE_INFINITY
486486
actual val delete: Any get() = rethrow { deleteField() }
487487
actual fun increment(value: Int): Any = rethrow { jsIncrement(value) }
488488
actual fun arrayUnion(vararg elements: Any): Any = rethrow { jsArrayUnion(*elements) }

0 commit comments

Comments
 (0)