Skip to content

Commit 566fcdb

Browse files
committed
Send the correct error code when firestore create fails
1 parent 93ad60d commit 566fcdb

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/firestore-document.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,11 @@ MockFirestoreDocument.prototype.get = function () {
8888
};
8989

9090
MockFirestoreDocument.prototype._validateDoesNotExist = function (data) {
91+
var ALREADY_EXISTS_CODE = 6;
92+
9193
if (data !== null) {
9294
var err = new Error('Cannot create a document which already exists');
93-
err.code = 'firestore/already-exists';
95+
err.code = ALREADY_EXISTS_CODE;
9496
return err;
9597
}
9698
return null;

test/unit/firestore-document.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ describe('MockFirestoreDocument', function () {
131131
done('should have thrown an error');
132132
})
133133
.catch(function(error) {
134-
expect(error.code).to.equal('firestore/already-exists');
134+
expect(error.code).to.equal(6);
135135
done();
136136
});
137137

0 commit comments

Comments
 (0)