Skip to content

Commit 192ecca

Browse files
authored
Upgraded to latest Firestore client; Added a test case to check for Doc Ref's (#100)
1 parent 0ccd65d commit 192ecca

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

npm-shrinkwrap.json

Lines changed: 3 additions & 3 deletions
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
@@ -50,7 +50,7 @@
5050
"dependencies": {
5151
"google-auth-library": "^0.10.0",
5252
"@google-cloud/storage": "^1.2.1",
53-
"@google-cloud/firestore": "~0.8.1",
53+
"@google-cloud/firestore": "~0.8.2",
5454
"@types/google-cloud__storage": "^1.1.1",
5555
"@types/jsonwebtoken": "^7.1.33",
5656
"@types/node": "^8.0.32",

test/integration/firestore.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,39 @@ function test(utils) {
9191
});
9292
}
9393

94+
function testSetDocumentReference() {
95+
const expected = {
96+
name: 'Mountain View',
97+
population: 77846,
98+
};
99+
const source = admin.firestore().collection('cities').doc();
100+
const target = admin.firestore().collection('cities').doc();
101+
return source.set(expected)
102+
.then(result => {
103+
return target.set({name: 'Palo Alto', sisterCity: source});
104+
})
105+
.then(result => {
106+
return target.get();
107+
})
108+
.then(snapshot => {
109+
var data = snapshot.data();
110+
utils.assert(
111+
_.isEqual(source.path, data.sisterCity.path),
112+
'firestore.DocumentReference',
113+
'Data read from Firestore did not match expected: ' + data);
114+
var promises = [];
115+
promises.push(source.delete());
116+
promises.push(target.delete());
117+
return Promise.all(promises);
118+
});
119+
}
120+
94121
return Promise.resolve()
95122
.then(testFirestore)
96123
.then(testFieldValue)
97124
.then(testFieldPath)
98-
.then(testGeoPoint);
125+
.then(testGeoPoint)
126+
.then(testSetDocumentReference);
99127
}
100128

101129
module.exports = {

0 commit comments

Comments
 (0)