@@ -2047,29 +2047,15 @@ describe('withConverter() support', () => {
2047
2047
} ) ;
2048
2048
2049
2049
describe ( 'countQuery()' , ( ) => {
2050
- const converter = {
2051
- toFirestore ( input : { id : string ; content : string } ) : DocumentData {
2052
- return { key : input . id , value : input . content } ;
2053
- } ,
2054
- fromFirestore ( snapshot : QueryDocumentSnapshot ) : {
2055
- id : string ;
2056
- content : string ;
2057
- } {
2058
- const data = snapshot . data ( ) ;
2059
- return { content : data . value , id : data . documentId } ;
2060
- }
2061
- } ;
2062
-
2063
2050
const testDocs = [
2064
- { key : 'a' , value : 'Adam' } ,
2065
- { key : 'b' , value : 'Bob' } ,
2066
- { key : 'c' , value : 'Chris' } ,
2067
- { key : 'a' , value : 'Anna' } ,
2068
- { key : 'b' , value : 'Bill' } ,
2069
- { key : 'c' , value : 'Cooper' }
2051
+ { author : 'authorA' , title : 'titleA' } ,
2052
+ { author : 'authorA' , title : 'titleB' } ,
2053
+ { author : 'authorB' , title : 'titleC' } ,
2054
+ { author : 'authorB' , title : 'titleD' } ,
2055
+ { author : 'authorB' , title : 'titleE' }
2070
2056
] ;
2071
2057
2072
- it . only ( 'AggregateQuery and AggregateQuerySnapshot inherits the original query' , ( ) => {
2058
+ it ( 'AggregateQuery and AggregateQuerySnapshot inherits the original query' , ( ) => {
2073
2059
return withTestCollection ( async coll => {
2074
2060
const query_ = query ( coll ) ;
2075
2061
@@ -2082,7 +2068,7 @@ describe('countQuery()', () => {
2082
2068
} ) ;
2083
2069
} ) ;
2084
2070
2085
- it . only ( 'empty collection count equals to 0 ' , ( ) => {
2071
+ it ( 'empty test collection count' , ( ) => {
2086
2072
return withTestCollection ( async coll => {
2087
2073
const countQuery_ = countQuery ( query ( coll ) ) ;
2088
2074
@@ -2091,76 +2077,85 @@ describe('countQuery()', () => {
2091
2077
} ) ;
2092
2078
} ) ;
2093
2079
2094
- it . only ( 'test collection count equals to 6 ' , ( ) => {
2080
+ it ( 'test collection count with sample docs ' , ( ) => {
2095
2081
return withTestCollectionAndInitialData ( testDocs , async collection => {
2096
2082
const countQuery_ = countQuery ( query ( collection ) ) ;
2097
2083
const snapshot = await getAggregateFromServerDirect ( countQuery_ ) ;
2098
- expect ( snapshot . getCount ( ) ) . to . equal ( 6 ) ;
2084
+ expect ( snapshot . getCount ( ) ) . to . equal ( 5 ) ;
2099
2085
} ) ;
2100
2086
} ) ;
2101
2087
2102
- it . only ( 'test collection count with filter' , ( ) => {
2088
+ it ( 'test collection count with filter' , ( ) => {
2103
2089
return withTestCollectionAndInitialData ( testDocs , async collection => {
2104
- const query_ = query ( collection , where ( 'key ' , '==' , 'a ' ) ) ;
2090
+ const query_ = query ( collection , where ( 'author ' , '==' , 'authorA ' ) ) ;
2105
2091
const countQuery_ = countQuery ( query_ ) ;
2106
2092
const snapshot = await getAggregateFromServerDirect ( countQuery_ ) ;
2107
2093
expect ( snapshot . getCount ( ) ) . to . equal ( 2 ) ;
2108
2094
} ) ;
2109
2095
} ) ;
2110
2096
2111
- it . only ( 'test collection count with filter and a small limit size' , ( ) => {
2097
+ it ( 'test collection count with filter and a small limit size' , ( ) => {
2112
2098
return withTestCollectionAndInitialData ( testDocs , async collection => {
2113
- const query_ = query ( collection , where ( 'key' , '==' , 'a' ) , limit ( 1 ) ) ;
2099
+ const query_ = query (
2100
+ collection ,
2101
+ where ( 'author' , '==' , 'authorA' ) ,
2102
+ limit ( 1 )
2103
+ ) ;
2114
2104
const countQuery_ = countQuery ( query_ ) ;
2115
2105
const snapshot = await getAggregateFromServerDirect ( countQuery_ ) ;
2116
2106
expect ( snapshot . getCount ( ) ) . to . equal ( 1 ) ;
2117
2107
} ) ;
2118
2108
} ) ;
2119
2109
2120
- it . only ( 'test collection count with filter and a large limit size' , ( ) => {
2110
+ it ( 'test collection count with filter and a large limit size' , ( ) => {
2121
2111
return withTestCollectionAndInitialData ( testDocs , async collection => {
2122
- const query_ = query ( collection , where ( 'key' , '==' , 'a' ) , limit ( 3 ) ) ;
2112
+ const query_ = query (
2113
+ collection ,
2114
+ where ( 'author' , '==' , 'authorA' ) ,
2115
+ limit ( 3 )
2116
+ ) ;
2123
2117
const countQuery_ = countQuery ( query_ ) ;
2124
2118
const snapshot = await getAggregateFromServerDirect ( countQuery_ ) ;
2125
2119
expect ( snapshot . getCount ( ) ) . to . equal ( 2 ) ;
2126
2120
} ) ;
2127
2121
} ) ;
2128
2122
2129
- it . only ( 'test collection count with converter on query' , ( ) => {
2123
+ it ( 'test collection count with converter on query' , ( ) => {
2130
2124
return withTestCollectionAndInitialData ( testDocs , async collection => {
2131
- const query_ = query ( collection , where ( 'key' , '==' , 'a' ) ) . withConverter (
2132
- converter
2133
- ) ;
2125
+ const query_ = query (
2126
+ collection ,
2127
+ where ( 'author' , '==' , 'authorA' )
2128
+ ) . withConverter ( postConverter ) ;
2134
2129
const countQuery_ = countQuery ( query_ ) ;
2135
2130
const snapshot = await getAggregateFromServerDirect ( countQuery_ ) ;
2136
2131
expect ( snapshot . getCount ( ) ) . to . equal ( 2 ) ;
2137
2132
} ) ;
2138
2133
} ) ;
2139
2134
2140
- it . only ( 'aggregateQueryEqual returns true on same queries' , ( ) => {
2135
+ it ( 'aggregateQueryEqual returns true on same queries' , ( ) => {
2141
2136
return withTestCollectionAndInitialData ( testDocs , async collection => {
2142
- const query1 = query ( collection , where ( 'key ' , '==' , 'a ' ) ) ;
2143
- const query2 = query ( collection , where ( 'key ' , '==' , 'a ' ) ) ;
2137
+ const query1 = query ( collection , where ( 'author ' , '==' , 'authorA ' ) ) ;
2138
+ const query2 = query ( collection , where ( 'author ' , '==' , 'authorA ' ) ) ;
2144
2139
const countQuery1 = countQuery ( query1 ) ;
2145
2140
const countQuery2 = countQuery ( query2 ) ;
2146
2141
expect ( aggregateQueryEqual ( countQuery1 , countQuery2 ) ) . to . be . true ;
2147
2142
} ) ;
2148
2143
} ) ;
2149
2144
2150
- it . only ( 'aggregateQueryEqual returns false on different queries' , ( ) => {
2145
+ it ( 'aggregateQueryEqual returns false on different queries' , ( ) => {
2151
2146
return withTestCollectionAndInitialData ( testDocs , async collection => {
2152
- const query1 = query ( collection , where ( 'key ' , '==' , 'a ' ) ) ;
2153
- const query2 = query ( collection , where ( 'key ' , '!= ' , 'a ' ) ) ;
2147
+ const query1 = query ( collection , where ( 'author ' , '==' , 'authorA ' ) ) ;
2148
+ const query2 = query ( collection , where ( 'author ' , '== ' , 'authorB ' ) ) ;
2154
2149
const countQuery1 = countQuery ( query1 ) ;
2155
2150
const countQuery2 = countQuery ( query2 ) ;
2156
2151
expect ( aggregateQueryEqual ( countQuery1 , countQuery2 ) ) . to . be . false ;
2157
2152
} ) ;
2158
2153
} ) ;
2159
2154
2160
- it . only ( 'aggregateQuerySnapshotEqual returns true on same queries' , ( ) => {
2155
+ it ( 'aggregateQuerySnapshotEqual returns true on same queries' , ( ) => {
2161
2156
return withTestCollectionAndInitialData ( testDocs , async collection => {
2162
- const query1 = query ( collection , where ( 'key ' , '==' , 'a ' ) ) ;
2163
- const query2 = query ( collection , where ( 'key ' , '==' , 'a ' ) ) ;
2157
+ const query1 = query ( collection , where ( 'author ' , '==' , 'authorA ' ) ) ;
2158
+ const query2 = query ( collection , where ( 'author ' , '==' , 'authorA ' ) ) ;
2164
2159
const countQuery1A = countQuery ( query1 ) ;
2165
2160
const countQuery1B = countQuery ( query1 ) ;
2166
2161
const countQuery2 = countQuery ( query2 ) ;
@@ -2172,10 +2167,10 @@ describe('countQuery()', () => {
2172
2167
} ) ;
2173
2168
} ) ;
2174
2169
2175
- it . only ( 'aggregateQuerySnapshotEqual returns false on different queries' , ( ) => {
2170
+ it ( 'aggregateQuerySnapshotEqual returns false on different queries' , ( ) => {
2176
2171
return withTestCollectionAndInitialData ( testDocs , async collection => {
2177
- const query1 = query ( collection , where ( 'key ' , '==' , 'a ' ) ) ;
2178
- const query2 = query ( collection , where ( 'key ' , '==' , 'b ' ) ) ;
2172
+ const query1 = query ( collection , where ( 'author ' , '==' , 'authorA ' ) ) ;
2173
+ const query2 = query ( collection , where ( 'author ' , '==' , 'authorB ' ) ) ;
2179
2174
const countQuery1 = countQuery ( query1 ) ;
2180
2175
const countQuery2 = countQuery ( query2 ) ;
2181
2176
const snapshot1 = await getAggregateFromServerDirect ( countQuery1 ) ;
0 commit comments