Skip to content

Commit fe7b97a

Browse files
committed
Fixed access to nested objects in arrays and updated Tests. Closes #95
1 parent 3ab4ae3 commit fe7b97a

File tree

4 files changed

+8
-18
lines changed

4 files changed

+8
-18
lines changed

Document.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class Document implements FirestoreAPI.Document, FirestoreAPI.MapValue {
9090
}
9191

9292
static unwrapArray(wrappedArray: FirestoreAPI.Value[] = []): Value[] {
93-
return wrappedArray.map(this.unwrapValue);
93+
return wrappedArray.map(this.unwrapValue, this);
9494
}
9595

9696
static unwrapDate(wrappedDate: string): Date {

Tests.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Tests implements TestManager {
4242
}
4343

4444
this.expected_ = {
45-
'array value': ['string123', 42, false],
45+
'array value': ['string123', 42, false, { 'nested map property': 123 }],
4646
'number value': 100,
4747
'string value 이': 'The fox jumps over the lazy dog 름',
4848
'boolean value': true,
@@ -186,6 +186,9 @@ class Tests implements TestManager {
186186
const path = 'Test Collection';
187187
const docs = this.db.getDocuments(path);
188188
GSUnit.assertEquals(8, docs.length);
189+
const doc = docs.find((doc) => doc.name!.endsWith('/New Document !@#$%^&*(),.<>?;\':"[]{}|-=_+áéíóúæÆÑ'));
190+
GSUnit.assertNotUndefined(doc);
191+
GSUnit.assertObjectEquals(this.expected_, doc!.obj);
189192
}
190193

191194
Test_Get_Documents_By_ID(): void {
@@ -201,14 +204,6 @@ class Tests implements TestManager {
201204
GSUnit.assertEquals(ids.length - 1, docs.length);
202205
}
203206

204-
Test_Get_Documents_Content(): void {
205-
const path = 'Test Collection';
206-
const ids = ['New Document !@#$%^&*(),.<>?;\':"[]{}|-=_+áéíóúæÆÑ'];
207-
const docs = this.db.getDocuments(path, ids);
208-
GSUnit.assertEquals(ids.length, docs.length);
209-
GSUnit.assertObjectEquals(this.expected_, docs[0].obj);
210-
}
211-
212207
Test_Get_Documents_By_ID_Missing(): void {
213208
const path = 'Missing Collection';
214209
const ids = [
@@ -258,12 +253,6 @@ class Tests implements TestManager {
258253
GSUnit.assertArrayEquals(expected, docs);
259254
}
260255

261-
Test_Query_One(): void {
262-
const path = 'Test Collection';
263-
const docs = this.db.query(path).Where('null value', null).Execute();
264-
GSUnit.assertObjectEquals(this.expected_, docs[0].obj);
265-
}
266-
267256
Test_Query_Select_Name(): void {
268257
const path = 'Test Collection';
269258
const docs = this.db.query(path).Select().Execute();
@@ -353,6 +342,7 @@ class Tests implements TestManager {
353342
const path = 'Test Collection';
354343
const docs = this.db.query(path).Where('null value', null).Execute();
355344
GSUnit.assertEquals(1, docs.length);
345+
GSUnit.assertObjectEquals(this.expected_, docs[0].obj);
356346
}
357347

358348
Test_Query_OrderBy_Number(): void {

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "firestore_google-apps-script",
3-
"version": "1.0.30",
3+
"version": "1.0.31",
44
"description": "A Google Apps Script library for accessing Google Cloud Firestore",
55
"homepage": "https://github.com/grahamearley/FirestoreGoogleAppsScript",
66
"bugs": "https://github.com/grahamearley/FirestoreGoogleAppsScript/issues",

0 commit comments

Comments
 (0)