Skip to content

Commit

Permalink
Use v9 API in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidt-sebastian committed Jan 5, 2022
1 parent 4f3662b commit 44b61ee
Show file tree
Hide file tree
Showing 43 changed files with 2,607 additions and 2,692 deletions.
3 changes: 0 additions & 3 deletions packages/firestore/package.json
Expand Up @@ -25,8 +25,6 @@
"test:lite:prod": "node ./scripts/run-tests.js --platform node_lite --main=lite/index.ts 'test/lite/**/*.test.ts'",
"test:lite:browser": "karma start --single-run --lite",
"test:lite:browser:debug": "karma start --browsers=Chrome --lite --auto-watch",
"pretest": "yarn test:prepare",
"pretest:ci": "yarn pretest",
"test": "run-s lint test:all",
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:all:ci",
"test:all:ci": "run-p test:browser test:lite:browser test:travis",
Expand All @@ -44,7 +42,6 @@
"api-report:api-json": "rm -rf temp && api-extractor run --local --verbose",
"api-report": "run-s api-report:main api-report:lite && yarn api-report:api-json",
"doc": "api-documenter markdown --input temp --output docs",
"test:prepare": "node ./scripts/prepare-test.js",
"typings:public": "node ../../scripts/build/use_typings.js ./dist/index.d.ts"
},
"exports": {
Expand Down
18 changes: 0 additions & 18 deletions packages/firestore/scripts/prepare-test.js

This file was deleted.

84 changes: 0 additions & 84 deletions packages/firestore/scripts/prepare-test.ts

This file was deleted.

2 changes: 2 additions & 0 deletions packages/firestore/src/api.ts
Expand Up @@ -133,6 +133,8 @@ export { FirestoreErrorCode, FirestoreError } from './util/error';

export { AbstractUserDataWriter } from './lite-api/user_data_writer';

export { FirestoreSettings as Settings } from './lite-api/settings';

export {
Primitive,
NestedUpdateFields,
Expand Down
12 changes: 6 additions & 6 deletions packages/firestore/src/api/snapshot.ts
Expand Up @@ -59,12 +59,12 @@ import { SnapshotListenOptions } from './reference_impl';
* }
*
* const postConverter = {
* toFirestore(post: WithFieldValue<Post>): firebase.firestore.DocumentData {
* toFirestore(post: WithFieldValue<Post>): DocumentData {
* return {title: post.title, author: post.author};
* },
* fromFirestore(
* snapshot: firebase.firestore.QueryDocumentSnapshot,
* options: firebase.firestore.SnapshotOptions
* snapshot: QueryDocumentSnapshot,
* options: SnapshotOptions
* ): Post {
* const data = snapshot.data(options)!;
* return new Post(data.title, data.author);
Expand Down Expand Up @@ -269,7 +269,7 @@ export class DocumentSnapshot<
* Retrieves all fields in the document as an `Object`. Returns `undefined` if
* the document doesn't exist.
*
* By default, `FieldValue.serverTimestamp()` values that have not yet been
* By default, `serverTimestamp()` values that have not yet been
* set to their final value will be returned as `null`. You can override
* this by passing an options object.
*
Expand Down Expand Up @@ -306,7 +306,7 @@ export class DocumentSnapshot<
* Retrieves the field specified by `fieldPath`. Returns `undefined` if the
* document or field doesn't exist.
*
* By default, a `FieldValue.serverTimestamp()` that has not yet been set to
* By default, a `serverTimestamp()` that has not yet been set to
* its final value will be returned as `null`. You can override this by
* passing an options object.
*
Expand Down Expand Up @@ -353,7 +353,7 @@ export class QueryDocumentSnapshot<
/**
* Retrieves all fields in the document as an `Object`.
*
* By default, `FieldValue.serverTimestamp()` values that have not yet been
* By default, `serverTimestamp()` values that have not yet been
* set to their final value will be returned as `null`. You can override
* this by passing an options object.
*
Expand Down
15 changes: 7 additions & 8 deletions packages/firestore/src/lite-api/query.ts
Expand Up @@ -480,8 +480,7 @@ export function newQueryFilter(
if (op === Operator.ARRAY_CONTAINS || op === Operator.ARRAY_CONTAINS_ANY) {
throw new FirestoreError(
Code.INVALID_ARGUMENT,
`Invalid Query. You can't perform '${op}' ` +
'queries on FieldPath.documentId().'
`Invalid Query. You can't perform '${op}' ` + 'queries on documentId().'
);
} else if (op === Operator.IN || op === Operator.NOT_IN) {
validateDisjunctiveFilterElements(value, op);
Expand Down Expand Up @@ -639,7 +638,7 @@ export function newQueryBoundFromFields(
if (!isCollectionGroupQuery(query) && rawValue.indexOf('/') !== -1) {
throw new FirestoreError(
Code.INVALID_ARGUMENT,
`Invalid query. When querying a collection and ordering by FieldPath.documentId(), ` +
`Invalid query. When querying a collection and ordering by documentId(), ` +
`the value passed to ${methodName}() must be a plain document ID, but ` +
`'${rawValue}' contains a slash.`
);
Expand All @@ -649,7 +648,7 @@ export function newQueryBoundFromFields(
throw new FirestoreError(
Code.INVALID_ARGUMENT,
`Invalid query. When querying a collection group and ordering by ` +
`FieldPath.documentId(), the value passed to ${methodName}() must result in a ` +
`documentId(), the value passed to ${methodName}() must result in a ` +
`valid document path, but '${path}' is not because it contains an odd number ` +
`of segments.`
);
Expand Down Expand Up @@ -681,15 +680,15 @@ function parseDocumentIdValue(
if (documentIdValue === '') {
throw new FirestoreError(
Code.INVALID_ARGUMENT,
'Invalid query. When querying with FieldPath.documentId(), you ' +
'Invalid query. When querying with documentId(), you ' +
'must provide a valid document ID, but it was an empty string.'
);
}
if (!isCollectionGroupQuery(query) && documentIdValue.indexOf('/') !== -1) {
throw new FirestoreError(
Code.INVALID_ARGUMENT,
`Invalid query. When querying a collection by ` +
`FieldPath.documentId(), you must provide a plain document ID, but ` +
`documentId(), you must provide a plain document ID, but ` +
`'${documentIdValue}' contains a '/' character.`
);
}
Expand All @@ -698,7 +697,7 @@ function parseDocumentIdValue(
throw new FirestoreError(
Code.INVALID_ARGUMENT,
`Invalid query. When querying a collection group by ` +
`FieldPath.documentId(), the value provided must result in a valid document path, ` +
`documentId(), the value provided must result in a valid document path, ` +
`but '${path}' is not because it has an odd number of segments (${path.length}).`
);
}
Expand All @@ -708,7 +707,7 @@ function parseDocumentIdValue(
} else {
throw new FirestoreError(
Code.INVALID_ARGUMENT,
`Invalid query. When querying with FieldPath.documentId(), you must provide a valid ` +
`Invalid query. When querying with documentId(), you must provide a valid ` +
`string or a DocumentReference, but it was: ` +
`${valueDescription(documentIdValue)}.`
);
Expand Down
4 changes: 2 additions & 2 deletions packages/firestore/src/lite-api/snapshot.ts
Expand Up @@ -57,10 +57,10 @@ import { AbstractUserDataWriter } from './user_data_writer';
* }
*
* const postConverter = {
* toFirestore(post: WithFieldValue<Post>): firebase.firestore.DocumentData {
* toFirestore(post: WithFieldValue<Post>): DocumentData {
* return {title: post.title, author: post.author};
* },
* fromFirestore(snapshot: firebase.firestore.QueryDocumentSnapshot): Post {
* fromFirestore(snapshot: QueryDocumentSnapshot): Post {
* const data = snapshot.data(options)!;
* return new Post(data.title, data.author);
* }
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/src/lite-api/user_data_reader.ts
Expand Up @@ -722,7 +722,7 @@ export function parseData(
validatePlainObject('Unsupported field value:', context, input);
return parseObject(input, context);
} else if (input instanceof FieldValue) {
// FieldValues usually parse into transforms (except FieldValue.delete())
// FieldValues usually parse into transforms (except deleteField())
// in which case we do not want to include this field in our parsed data
// (as doing so will overwrite the field directly prior to the transform
// trying to transform it). So we don't add this location to
Expand Down

0 comments on commit 44b61ee

Please sign in to comment.