@firebase/database-compat 0.1.1-2021823172527 → 0.1.2-canary.0b3ca78eb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -8
- package/dist/database-compat/src/index.d.ts +0 -9
- package/dist/database-compat/src/index.node.d.ts +0 -53
- package/dist/database-compat/src/index.standalone.d.ts +52 -0
- package/dist/index.esm2017.js +5 -6
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +2 -3
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.js +10 -77
- package/dist/index.js.map +1 -1
- package/dist/index.standalone.js +15150 -0
- package/dist/index.standalone.js.map +1 -0
- package/dist/node-esm/database-compat/src/api/Database.d.ts +72 -0
- package/dist/node-esm/database-compat/src/api/Reference.d.ts +201 -0
- package/{karma.conf.js → dist/node-esm/database-compat/src/api/TransactionResult.d.ts} +26 -34
- package/dist/node-esm/database-compat/src/api/internal.d.ts +39 -0
- package/dist/node-esm/database-compat/src/api/onDisconnect.d.ts +27 -0
- package/dist/node-esm/database-compat/src/index.d.ts +32 -0
- package/dist/node-esm/database-compat/src/index.node.d.ts +14 -0
- package/dist/node-esm/database-compat/src/index.standalone.d.ts +52 -0
- package/{src/util/util.ts → dist/node-esm/database-compat/src/util/util.d.ts} +17 -25
- package/dist/node-esm/database-compat/src/util/validation.d.ts +18 -0
- package/{src/api/TransactionResult.ts → dist/node-esm/database-compat/test/browser/crawler_support.test.d.ts} +17 -34
- package/dist/node-esm/database-compat/test/database.test.d.ts +17 -0
- package/dist/node-esm/database-compat/test/datasnapshot.test.d.ts +17 -0
- package/dist/node-esm/database-compat/test/helpers/events.d.ts +34 -0
- package/dist/node-esm/database-compat/test/helpers/util.d.ts +42 -0
- package/dist/node-esm/database-compat/test/info.test.d.ts +17 -0
- package/dist/node-esm/database-compat/test/order.test.d.ts +17 -0
- package/dist/node-esm/database-compat/test/order_by.test.d.ts +17 -0
- package/dist/node-esm/database-compat/test/promise.test.d.ts +17 -0
- package/dist/node-esm/database-compat/test/query.test.d.ts +17 -0
- package/dist/node-esm/database-compat/test/servervalues.test.d.ts +17 -0
- package/dist/node-esm/database-compat/test/transaction.test.d.ts +17 -0
- package/dist/node-esm/index.js +868 -0
- package/dist/node-esm/index.js.map +1 -0
- package/dist/node-esm/package.json +1 -0
- package/package.json +34 -9
- package/standalone/package.json +7 -0
- package/.eslintrc.js +0 -64
- package/rollup.config.js +0 -125
- package/src/api/Database.ts +0 -123
- package/src/api/Reference.ts +0 -790
- package/src/api/internal.ts +0 -91
- package/src/api/onDisconnect.ts +0 -112
- package/src/index.node.ts +0 -142
- package/src/index.ts +0 -88
- package/src/util/validation.ts +0 -59
- package/test/browser/crawler_support.test.ts +0 -206
- package/test/database.test.ts +0 -306
- package/test/datasnapshot.test.ts +0 -249
- package/test/helpers/events.ts +0 -258
- package/test/helpers/util.ts +0 -177
- package/test/info.test.ts +0 -222
- package/test/order.test.ts +0 -592
- package/test/order_by.test.ts +0 -530
- package/test/promise.test.ts +0 -261
- package/test/query.test.ts +0 -4670
- package/test/servervalues.test.ts +0 -152
- package/test/transaction.test.ts +0 -1534
- package/tsconfig.json +0 -11
package/test/promise.test.ts
DELETED
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2017 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import { expect } from 'chai';
|
|
19
|
-
|
|
20
|
-
import { Reference } from '../src/api/Reference';
|
|
21
|
-
|
|
22
|
-
import { getRandomNode, getRootNode } from './helpers/util';
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* This test suite is super flakey, random test fail at random times for
|
|
26
|
-
* no predicatble reason. Skipping for now but adding todo to come back
|
|
27
|
-
* later and fix this
|
|
28
|
-
*/
|
|
29
|
-
// TODO: Fix the flakey test suite
|
|
30
|
-
describe.skip('Promise Tests', () => {
|
|
31
|
-
it('wraps Query.once', () => {
|
|
32
|
-
return (getRandomNode() as Reference).once('value').then(snap => {
|
|
33
|
-
expect(snap.val()).to.equal(null);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('wraps Firebase.set', () => {
|
|
38
|
-
const ref = getRandomNode() as Reference;
|
|
39
|
-
return ref
|
|
40
|
-
.set(5)
|
|
41
|
-
.then(() => {
|
|
42
|
-
return ref.once('value');
|
|
43
|
-
})
|
|
44
|
-
.then(read => {
|
|
45
|
-
expect(read.val()).to.equal(5);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('wraps Firebase.push when no value is passed', () => {
|
|
50
|
-
const ref = getRandomNode() as Reference;
|
|
51
|
-
const pushed = ref.push();
|
|
52
|
-
return pushed
|
|
53
|
-
.then(childRef => {
|
|
54
|
-
expect(pushed.ref.parent.toString()).to.equal(ref.toString());
|
|
55
|
-
expect(pushed.toString()).to.equal(childRef.toString());
|
|
56
|
-
return pushed.once('value');
|
|
57
|
-
})
|
|
58
|
-
.then(snap => {
|
|
59
|
-
expect(snap.val()).to.equal(null);
|
|
60
|
-
expect(snap.ref.toString()).to.equal(pushed.toString());
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('wraps Firebase.push when a value is passed', () => {
|
|
65
|
-
const ref = getRandomNode() as Reference;
|
|
66
|
-
const pushed = ref.push(6);
|
|
67
|
-
return pushed
|
|
68
|
-
.then(childRef => {
|
|
69
|
-
expect(pushed.ref.parent.toString()).to.equal(ref.toString());
|
|
70
|
-
expect(pushed.toString()).to.equal(childRef.toString());
|
|
71
|
-
return pushed.once('value');
|
|
72
|
-
})
|
|
73
|
-
.then(snap => {
|
|
74
|
-
expect(snap.val()).to.equal(6);
|
|
75
|
-
expect(snap.ref.toString()).to.equal(pushed.toString());
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('wraps Firebase.remove', () => {
|
|
80
|
-
const ref = getRandomNode() as Reference;
|
|
81
|
-
return ref
|
|
82
|
-
.set({ a: 'b' })
|
|
83
|
-
.then(() => {
|
|
84
|
-
const p = ref.child('a').remove();
|
|
85
|
-
expect(typeof p.then === 'function').to.equal(true);
|
|
86
|
-
return p;
|
|
87
|
-
})
|
|
88
|
-
.then(() => {
|
|
89
|
-
return ref.once('value');
|
|
90
|
-
})
|
|
91
|
-
.then(snap => {
|
|
92
|
-
expect(snap.val()).to.equal(null);
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('wraps Firebase.update', () => {
|
|
97
|
-
const ref = getRandomNode() as Reference;
|
|
98
|
-
return ref
|
|
99
|
-
.set({ a: 'b' })
|
|
100
|
-
.then(() => {
|
|
101
|
-
const p = ref.update({ c: 'd' });
|
|
102
|
-
expect(typeof p.then === 'function').to.equal(true);
|
|
103
|
-
return p;
|
|
104
|
-
})
|
|
105
|
-
.then(() => {
|
|
106
|
-
return ref.once('value');
|
|
107
|
-
})
|
|
108
|
-
.then(snap => {
|
|
109
|
-
expect(snap.val()).to.deep.equal({ a: 'b', c: 'd' });
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('wraps Fireabse.setPriority', () => {
|
|
114
|
-
const ref = getRandomNode() as Reference;
|
|
115
|
-
return ref
|
|
116
|
-
.set({ a: 'b' })
|
|
117
|
-
.then(() => {
|
|
118
|
-
const p = ref.child('a').setPriority(5);
|
|
119
|
-
expect(typeof p.then === 'function').to.equal(true);
|
|
120
|
-
return p;
|
|
121
|
-
})
|
|
122
|
-
.then(() => {
|
|
123
|
-
return ref.once('value');
|
|
124
|
-
})
|
|
125
|
-
.then(snap => {
|
|
126
|
-
expect(snap.child('a').getPriority()).to.equal(5);
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it('wraps Firebase.setWithPriority', () => {
|
|
131
|
-
const ref = getRandomNode() as Reference;
|
|
132
|
-
return ref
|
|
133
|
-
.setWithPriority('hi', 5)
|
|
134
|
-
.then(() => {
|
|
135
|
-
return ref.once('value');
|
|
136
|
-
})
|
|
137
|
-
.then(snap => {
|
|
138
|
-
expect(snap.getPriority()).to.equal(5);
|
|
139
|
-
expect(snap.val()).to.equal('hi');
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it('wraps Firebase.transaction', () => {
|
|
144
|
-
const ref = getRandomNode() as Reference;
|
|
145
|
-
return ref
|
|
146
|
-
.transaction(() => {
|
|
147
|
-
return 5;
|
|
148
|
-
})
|
|
149
|
-
.then(result => {
|
|
150
|
-
expect(result.committed).to.equal(true);
|
|
151
|
-
expect(result.snapshot.val()).to.equal(5);
|
|
152
|
-
return ref.transaction(() => {
|
|
153
|
-
return undefined;
|
|
154
|
-
});
|
|
155
|
-
})
|
|
156
|
-
.then(result => {
|
|
157
|
-
expect(result.committed).to.equal(false);
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it('exposes catch in the return of Firebase.push', () => {
|
|
162
|
-
// Catch is a pain in the bum to provide safely because "catch" is a reserved word and ES3 and below require
|
|
163
|
-
// you to use quotes to define it, but the closure linter really doesn't want you to do that either.
|
|
164
|
-
const ref = getRandomNode() as Reference;
|
|
165
|
-
const pushed = ref.push(6);
|
|
166
|
-
|
|
167
|
-
expect(typeof ref.then === 'function').to.equal(false);
|
|
168
|
-
expect(typeof ref.catch === 'function').to.equal(false);
|
|
169
|
-
expect(typeof pushed.then === 'function').to.equal(true);
|
|
170
|
-
expect(typeof pushed.catch === 'function').to.equal(true);
|
|
171
|
-
return pushed;
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
it('wraps onDisconnect.remove', () => {
|
|
175
|
-
const refs = getRandomNode(2) as Reference[];
|
|
176
|
-
const writer = refs[0];
|
|
177
|
-
const reader = refs[1];
|
|
178
|
-
const refInfo = getRootNode(0, '.info/connected');
|
|
179
|
-
|
|
180
|
-
refInfo.once('value', snapshot => {
|
|
181
|
-
expect(snapshot.val()).to.equal(true);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
return writer
|
|
185
|
-
.child('here today')
|
|
186
|
-
.set('gone tomorrow')
|
|
187
|
-
.then(() => {
|
|
188
|
-
const p = writer.child('here today').onDisconnect().remove();
|
|
189
|
-
expect(typeof p.then === 'function').to.equal(true);
|
|
190
|
-
return p;
|
|
191
|
-
})
|
|
192
|
-
.then(() => {
|
|
193
|
-
writer.database.goOffline();
|
|
194
|
-
writer.database.goOnline();
|
|
195
|
-
return reader.once('value');
|
|
196
|
-
})
|
|
197
|
-
.then(snap => {
|
|
198
|
-
expect(snap.val()).to.equal(null);
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
it('wraps onDisconnect.update', () => {
|
|
203
|
-
const refs = getRandomNode(2) as Reference[];
|
|
204
|
-
const writer = refs[0];
|
|
205
|
-
const reader = refs[1];
|
|
206
|
-
return writer
|
|
207
|
-
.set({ foo: 'baz' })
|
|
208
|
-
.then(() => {
|
|
209
|
-
const p = writer.onDisconnect().update({ foo: 'bar' });
|
|
210
|
-
expect(typeof p.then === 'function').to.equal(true);
|
|
211
|
-
return p;
|
|
212
|
-
})
|
|
213
|
-
.then(() => {
|
|
214
|
-
writer.database.goOffline();
|
|
215
|
-
writer.database.goOnline();
|
|
216
|
-
return reader.once('value');
|
|
217
|
-
})
|
|
218
|
-
.then(snap => {
|
|
219
|
-
expect(snap.val()).to.deep.equal({ foo: 'bar' });
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
it('wraps onDisconnect.set', () => {
|
|
224
|
-
const refs = getRandomNode(2) as Reference[];
|
|
225
|
-
const writer = refs[0];
|
|
226
|
-
const reader = refs[1];
|
|
227
|
-
return writer
|
|
228
|
-
.child('hello')
|
|
229
|
-
.onDisconnect()
|
|
230
|
-
.set('world')
|
|
231
|
-
.then(() => {
|
|
232
|
-
writer.database.goOffline();
|
|
233
|
-
writer.database.goOnline();
|
|
234
|
-
return reader.once('value');
|
|
235
|
-
})
|
|
236
|
-
.then(snap => {
|
|
237
|
-
expect(snap.val()).to.deep.equal({ hello: 'world' });
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
it('wraps onDisconnect.setWithPriority', () => {
|
|
242
|
-
const refs = getRandomNode(2) as Reference[];
|
|
243
|
-
const writer = refs[0];
|
|
244
|
-
const reader = refs[1];
|
|
245
|
-
return writer
|
|
246
|
-
.child('meaning of life')
|
|
247
|
-
.onDisconnect()
|
|
248
|
-
.setWithPriority('ultimate question', 42)
|
|
249
|
-
.then(() => {
|
|
250
|
-
writer.database.goOffline();
|
|
251
|
-
writer.database.goOnline();
|
|
252
|
-
return reader.once('value');
|
|
253
|
-
})
|
|
254
|
-
.then(snap => {
|
|
255
|
-
expect(snap.val()).to.deep.equal({
|
|
256
|
-
'meaning of life': 'ultimate question'
|
|
257
|
-
});
|
|
258
|
-
expect(snap.child('meaning of life').getPriority()).to.equal(42);
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
});
|