From e1c5db7a1ad04ba5bac6ef564bf253131adf743b Mon Sep 17 00:00:00 2001 From: Popotojs Date: Sat, 29 Jun 2024 15:54:10 +0200 Subject: [PATCH] update snapshots --- e2e/cats.e2e.spec.ts | 16 +++---- lib/service/auth/auth.service.spec.ts | 12 ++--- .../firestore/firestore.service.spec.ts | 48 +++++++++---------- lib/service/storage/storage.service.spec.ts | 46 +++++++++--------- 4 files changed, 61 insertions(+), 61 deletions(-) diff --git a/e2e/cats.e2e.spec.ts b/e2e/cats.e2e.spec.ts index 71b194e..da865a3 100644 --- a/e2e/cats.e2e.spec.ts +++ b/e2e/cats.e2e.spec.ts @@ -77,7 +77,7 @@ xdescribe.each(testCase)("Module - %s", (_, dynamicModule) => { afterEach(async () => { return await axios .delete( - "http://localhost:8080/emulator/v1/projects/demo-nhogs-nestjs-firebase/databases/(default)/documents" + "http://localhost:8080/emulator/v1/projects/demo-nhogs-nestjs-firebase/databases/(default)/documents", ) .then(function (response) { expect(response.status).toMatchInlineSnapshot(`200`); @@ -112,7 +112,7 @@ xdescribe.each(testCase)("Module - %s", (_, dynamicModule) => { "name": "Snowflake", "url": "http://localhost:9199/v0/b/default-bucket/o/cats%2Fsnowflake.jpg?alt=media&token=1f6f9332-150b-4a91-80e7-8732ac84265e", } - ` + `, ); done(); }); @@ -132,36 +132,36 @@ xdescribe.each(testCase)("Module - %s", (_, dynamicModule) => { .expect(200) .then((res) => { expect(res.body).toMatchInlineSnapshot(` - Array [ - Object { + [ + { "_id": "jellybean", "age": 1, "breed": "Birman", "name": "Jellybean", "url": "http://localhost:9199/v0/b/default-bucket/o/cats%2Fjellybean.jpg?alt=media&token=e56ec9d7-af49-4f67-af8c-e5cbf3ecfee9", }, - Object { + { "_id": "marshmallow", "age": 4, "breed": "Bengal", "name": "Marshmallow", "url": "http://localhost:9199/v0/b/default-bucket/o/cats%2Fmarshmallow.jpg?alt=media&token=7a1dd7bf-7ca0-4f49-a56b-e8ef66dc985a", }, - Object { + { "_id": "minnie", "age": 2, "breed": "Scottish Fold", "name": "Minnie", "url": "http://localhost:9199/v0/b/default-bucket/o/cats%2Fminnie.jpg?alt=media&token=d6d2d862-1739-47ef-82ec-7fdfee938766", }, - Object { + { "_id": "puffin", "age": 8, "breed": "Siamese", "name": "Puffin", "url": "http://localhost:9199/v0/b/default-bucket/o/cats%2Fpuffin.jpg?alt=media&token=75095f8f-e184-44d9-bcbf-be1f467bd5e9", }, - Object { + { "_id": "snowflake", "age": 3, "breed": "Maine coon", diff --git a/lib/service/auth/auth.service.spec.ts b/lib/service/auth/auth.service.spec.ts index 84bc318..d84c510 100644 --- a/lib/service/auth/auth.service.spec.ts +++ b/lib/service/auth/auth.service.spec.ts @@ -38,11 +38,11 @@ describe("Firebase Auth Service", () => { try { await authService.signInWithEmailAndPassword( "user.email@gmail.com", - "userpassword" + "userpassword", ); } catch (error) { expect(error).toMatchInlineSnapshot( - `[FirebaseError: Firebase: Error (auth/user-not-found).]` + `[FirebaseError: Firebase: Error (auth/user-not-found).]`, ); } }); @@ -51,7 +51,7 @@ describe("Firebase Auth Service", () => { const user = ( await authService.createUserWithEmailAndPassword( "user.email@gmail.com", - "userpassword" + "userpassword", ) ).user; @@ -60,7 +60,7 @@ describe("Firebase Auth Service", () => { const user2 = ( await authService.signInWithEmailAndPassword( "user.email@gmail.com", - "userpassword" + "userpassword", ) ).user; @@ -77,7 +77,7 @@ describe("Firebase Auth Service", () => { }, }; expect(toCheck).toMatchInlineSnapshot(` - Object { + { "operationType": "signIn", "user": Object { "isAnonymous": true, @@ -98,7 +98,7 @@ describe("Firebase Auth Service", () => { afterEach(async () => { return await axios .delete( - "http://localhost:9099/emulator/v1/projects/demo-nhogs-nestjs-firebase/accounts" + "http://localhost:9099/emulator/v1/projects/demo-nhogs-nestjs-firebase/accounts", ) .then(function (response) { expect(response.status).toMatchInlineSnapshot(`200`); diff --git a/lib/service/firestore/firestore.service.spec.ts b/lib/service/firestore/firestore.service.spec.ts index d535910..5cbbead 100644 --- a/lib/service/firestore/firestore.service.spec.ts +++ b/lib/service/firestore/firestore.service.spec.ts @@ -172,15 +172,15 @@ describe("Firebase Storage Service", () => { .writeBatch() .set( firestoreService.doc("users", "1").withConverter(userConverter), - u1 + u1, ) .set( firestoreService.doc("users", "2").withConverter(userConverter), - u2 + u2, ) .set( firestoreService.doc("users", "3").withConverter(userConverter), - u3 + u3, ) .commit(); @@ -192,9 +192,9 @@ describe("Firebase Storage Service", () => { expect( querySnapshot.docs .map((value) => value.data()) - .sort((a, b) => b.firstName.localeCompare(a.firstName)) + .sort((a, b) => b.firstName.localeCompare(a.firstName)), ).toMatchInlineSnapshot(` - Array [ + [ User { "age": 3, "firstName": "fn3", @@ -218,15 +218,15 @@ describe("Firebase Storage Service", () => { await firestoreService.runTransaction(async (transaction) => { transaction.set( firestoreService.doc("users", "1").withConverter(userConverter), - u1 + u1, ); transaction.set( firestoreService.doc("users", "2").withConverter(userConverter), - u2 + u2, ); transaction.set( firestoreService.doc("users", "3").withConverter(userConverter), - u3 + u3, ); }); @@ -238,9 +238,9 @@ describe("Firebase Storage Service", () => { expect( querySnapshot.docs .map((value) => value.data()) - .sort((a, b) => b.firstName.localeCompare(a.firstName)) + .sort((a, b) => b.firstName.localeCompare(a.firstName)), ).toMatchInlineSnapshot(` - Array [ + [ User { "age": 3, "firstName": "fn3", @@ -271,13 +271,13 @@ describe("Firebase Storage Service", () => { const q = firestoreService.query( users, - firestoreService.where("age", ">", 2) + firestoreService.where("age", ">", 2), ); const querySnapshot = await firestoreService.getDocs(q); expect(querySnapshot.docs.map((value) => value.data())) .toMatchInlineSnapshot(` - Array [ + [ User { "age": 3, "firstName": "fn3", @@ -297,7 +297,7 @@ describe("Firebase Storage Service", () => { const ref = await firestoreService.addDoc( users, - new UserWithId({ id: null, ...u1 }) + new UserWithId({ id: null, ...u1 }), ); const snapshot = await firestoreService.getDoc(ref); @@ -312,7 +312,7 @@ describe("Firebase Storage Service", () => { "id": Any, "lastName": "ln1", } - ` + `, ); expect(data.id).not.toBeNull(); @@ -326,7 +326,7 @@ describe("Firebase Storage Service", () => { for (let i = 0; i < 25; i++) { await firestoreService.addDoc( users, - new User("fn" + i, "ln" + i, i) + new User("fn" + i, "ln" + i, i), ); } @@ -335,13 +335,13 @@ describe("Firebase Storage Service", () => { firestoreService.orderBy("age", "desc"), firestoreService.startAt(9), firestoreService.endAt(7), - firestoreService.limit(2) + firestoreService.limit(2), ); const querySnapshot1 = await firestoreService.getDocs(q1); expect(querySnapshot1.docs.map((value) => value.data())) .toMatchInlineSnapshot(` - Array [ + [ User { "age": 9, "firstName": "fn9", @@ -359,13 +359,13 @@ describe("Firebase Storage Service", () => { users, firestoreService.orderBy("firstName"), firestoreService.startAfter("fn3"), - firestoreService.endBefore("fn7") + firestoreService.endBefore("fn7"), ); const querySnapshot2 = await firestoreService.getDocs(q2); expect(querySnapshot2.docs.map((value) => value.data())) .toMatchInlineSnapshot(` - Array [ + [ User { "age": 4, "firstName": "fn4", @@ -393,13 +393,13 @@ describe("Firebase Storage Service", () => { for (let i = 3; i >= 0; i--) { await firestoreService.addDoc( users, - new User("fn" + i, "ln" + i, i) + new User("fn" + i, "ln" + i, i), ); } const q1 = firestoreService.query( users, - firestoreService.orderBy(firestoreService.documentId()) + firestoreService.orderBy(firestoreService.documentId()), ); const querySnapshot1 = await firestoreService.getDocs(q1); @@ -421,12 +421,12 @@ describe("Firebase Storage Service", () => { const q = firestoreService.query( docs, - firestoreService.orderBy("time", "desc") + firestoreService.orderBy("time", "desc"), ); const snap = await firestoreService.getDocs(q); expect(snap.docs.map((d) => d.data().index)).toMatchInlineSnapshot(` - Array [ + [ 0, 1, 2, @@ -439,7 +439,7 @@ describe("Firebase Storage Service", () => { // Delete all documents return await axios .delete( - `http://${FirebaseEmulatorEnv.firestoreHost}:${FirebaseEmulatorEnv.firestorePort}/emulator/v1/projects/${FirebaseEmulatorEnv.projectId}/databases/(default)/documents` + `http://${FirebaseEmulatorEnv.firestoreHost}:${FirebaseEmulatorEnv.firestorePort}/emulator/v1/projects/${FirebaseEmulatorEnv.projectId}/databases/(default)/documents`, ) .then(function (response) { expect(response.status).toMatchInlineSnapshot(`200`); diff --git a/lib/service/storage/storage.service.spec.ts b/lib/service/storage/storage.service.spec.ts index de8e4ed..c47e7d9 100644 --- a/lib/service/storage/storage.service.spec.ts +++ b/lib/service/storage/storage.service.spec.ts @@ -51,7 +51,7 @@ describe("Firebase Storage", () => { const storageReference = storageService.ref(); expect(storageReference.toString()).toEqual( - `gs://${FirebaseEmulatorEnv.storageBucket}/` + `gs://${FirebaseEmulatorEnv.storageBucket}/`, ); expect(storageReference.bucket).toEqual(FirebaseEmulatorEnv.storageBucket); expect(storageReference.name).toMatchInlineSnapshot(`""`); @@ -60,7 +60,7 @@ describe("Firebase Storage", () => { it("should create a reference on a folder", () => { const storageReference = storageService.ref("cats"); expect(storageReference.toString()).toEqual( - `gs://${FirebaseEmulatorEnv.storageBucket}/cats` + `gs://${FirebaseEmulatorEnv.storageBucket}/cats`, ); expect(storageReference.name).toMatchInlineSnapshot(`"cats"`); }); @@ -79,14 +79,14 @@ describe("Firebase Storage", () => { }) .then((snapshot) => { expect(snapshot.metadata.contentType).toMatchInlineSnapshot( - `"image/png"` + `"image/png"`, ); }); const downloadUrl = await storageService.getDownloadURL(fileName); expect(downloadUrl).toEqual( - `http://${FirebaseEmulatorEnv.storageHost}:${FirebaseEmulatorEnv.storagePort}/v0/b/default-bucket/o/${fileName}?alt=media&token=custom-token-for-test` + `http://${FirebaseEmulatorEnv.storageHost}:${FirebaseEmulatorEnv.storagePort}/v0/b/default-bucket/o/${fileName}?alt=media&token=custom-token-for-test`, ); }); @@ -101,13 +101,13 @@ describe("Firebase Storage", () => { }) .then((snapshot) => { expect(snapshot.metadata.contentType).toMatchInlineSnapshot( - `"text/plain"` + `"text/plain"`, ); }); const downloadUrl = await storageService.getDownloadURL(fileName); expect(downloadUrl).toEqual( - `http://${FirebaseEmulatorEnv.storageHost}:${FirebaseEmulatorEnv.storagePort}/v0/b/${FirebaseEmulatorEnv.storageBucket}/o/${fileName}?alt=media&token=custom-token-for-test` + `http://${FirebaseEmulatorEnv.storageHost}:${FirebaseEmulatorEnv.storagePort}/v0/b/${FirebaseEmulatorEnv.storageBucket}/o/${fileName}?alt=media&token=custom-token-for-test`, ); }); @@ -125,7 +125,7 @@ describe("Firebase Storage", () => { customMetadata: { firebaseStorageDownloadTokens: "custom-token-for-test", }, - } + }, ); uploadTask.on( @@ -144,7 +144,7 @@ describe("Firebase Storage", () => { running - 100%" `); done(); - } + }, ); }); @@ -152,16 +152,16 @@ describe("Firebase Storage", () => { it(`should fail unknown path`, async () => { await storageService.getDownloadURL("unknown").catch((error) => { expect(error).toMatchInlineSnapshot( - `[FirebaseError: Firebase Storage: Object 'unknown' does not exist. (storage/object-not-found)]` + `[FirebaseError: Firebase Storage: Object 'unknown' does not exist. (storage/object-not-found)]`, ); }); }); it(`should getDownloadURL (from emulator imported dataset)`, async () => { expect( - await storageService.getDownloadURL("cats/snowflake.jpg") + await storageService.getDownloadURL("cats/snowflake.jpg"), ).toMatchInlineSnapshot( - `"http://localhost:9199/v0/b/default-bucket/o/cats%2Fsnowflake.jpg?alt=media&token=1f6f9332-150b-4a91-80e7-8732ac84265e"` + `"http://localhost:9199/v0/b/default-bucket/o/cats%2Fsnowflake.jpg?alt=media&token=1f6f9332-150b-4a91-80e7-8732ac84265e"`, ); }); @@ -187,9 +187,9 @@ describe("Firebase Storage", () => { return await new Promise((fulfill) => stream.on("end", fulfill)).then( () => { expect(Buffer.concat(chunks).toString()).toMatchInlineSnapshot( - `"text content"` + `"text content"`, ); - } + }, ); }); @@ -199,10 +199,10 @@ describe("Firebase Storage", () => { const filtered = keys.reduce( (obj, key) => ({ ...obj, [key]: metadata[key] }), - {} + {}, ); expect(filtered).toMatchInlineSnapshot(` - Object { + { "contentType": "image/jpeg", "fullPath": "cats/snowflake.jpg", "name": "snowflake.jpg", @@ -223,10 +223,10 @@ describe("Firebase Storage", () => { const filteredBefore = keys.reduce( (obj, key) => ({ ...obj, [key]: metadataBefore[key] }), - {} + {}, ); expect(filteredBefore).toMatchInlineSnapshot(` - Object { + { "contentLanguage": undefined, "contentType": "text/plain", "size": 12, @@ -238,7 +238,7 @@ describe("Firebase Storage", () => { const metadataAfter = await storageService.getMetadata(fileName); const filteredAfter = keys.reduce( (obj, key) => ({ ...obj, [key]: metadataAfter[key] }), - {} + {}, ); expect(filteredAfter).toMatchInlineSnapshot(` Object { @@ -262,14 +262,14 @@ describe("Firebase Storage", () => { }); expect(await storageService.getDownloadURL(fileName)).toEqual( - `http://${FirebaseEmulatorEnv.storageHost}:${FirebaseEmulatorEnv.storagePort}/v0/b/${FirebaseEmulatorEnv.storageBucket}/o/${fileName}?alt=media&token=custom-token-for-test` + `http://${FirebaseEmulatorEnv.storageHost}:${FirebaseEmulatorEnv.storagePort}/v0/b/${FirebaseEmulatorEnv.storageBucket}/o/${fileName}?alt=media&token=custom-token-for-test`, ); await storageService.deleteObject(fileName); await storageService.getDownloadURL(fileName).catch((error) => { expect(error).toMatchInlineSnapshot( - `[FirebaseError: Firebase Storage: Object '${fileName}' does not exist. (storage/object-not-found)]` + `[FirebaseError: Firebase Storage: Object '${fileName}' does not exist. (storage/object-not-found)]`, ); }); }); @@ -277,7 +277,7 @@ describe("Firebase Storage", () => { it(`should ListAll`, async () => { expect((await storageService.listAll("cats")).items.map((ref) => ref.name)) .toMatchInlineSnapshot(` - Array [ + [ "jellybean.jpg", "marshmallow.jpg", "minnie.jpg", @@ -291,7 +291,7 @@ describe("Firebase Storage", () => { const firstPage = await storageService.list("cats", { maxResults: 3 }); expect(firstPage.items.map((ref) => ref.name)).toMatchInlineSnapshot(` - Array [ + [ "jellybean.jpg", "marshmallow.jpg", "minnie.jpg", @@ -305,7 +305,7 @@ describe("Firebase Storage", () => { }); expect(secondPage.items.map((ref) => ref.name)).toMatchInlineSnapshot(` - Array [ + [ "puffin.jpg", "snowflake.jpg", ]