Skip to content

Commit 42c0efd

Browse files
committed
JS: add test
1 parent ad592d7 commit 42c0efd

File tree

7 files changed

+113
-0
lines changed

7 files changed

+113
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
| tst.js:5:1:5:22 | fb.data ... ef('x') |
2+
| tst.js:7:3:7:7 | x.ref |
3+
| tst.js:7:3:7:14 | x.ref.parent |
4+
| tst.js:10:1:10:25 | admin.d ... ef('x') |
5+
| tst.js:12:3:12:7 | x.ref |
6+
| tst.js:12:3:12:14 | x.ref.parent |
7+
| tst.js:17:3:17:7 | x.ref |
8+
| tst.js:17:3:17:14 | x.ref.parent |
9+
| tst.js:23:3:23:7 | x.ref |
10+
| tst.js:23:3:23:14 | x.ref.parent |
11+
| tst.js:32:12:32:42 | this.fi ... .ref(x) |
12+
| tst.js:46:12:46:42 | this.fi ... .ref(x) |
13+
| tst.js:50:12:50:25 | this.getRef(x) |
14+
| tst.js:50:12:50:34 | this.ge ... hild(x) |
15+
| tst.js:54:5:54:37 | this.fi ... ef('x') |
16+
| tst.js:58:1:58:61 | new Fir ... /news') |
17+
| tst.js:59:1:59:38 | new Fir ... /news') |
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import javascript
2+
3+
select Firebase::Database::ref()
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
| tst.js:5:1:8:2 | fb.data ... ent;\\n}) |
2+
| tst.js:5:38:5:38 | x |
3+
| tst.js:10:1:13:2 | admin.d ... ent;\\n}) |
4+
| tst.js:10:41:10:41 | x |
5+
| tst.js:15:38:15:38 | x |
6+
| tst.js:20:38:20:38 | x |
7+
| tst.js:21:3:21:10 | x.before |
8+
| tst.js:22:3:22:9 | x.after |
9+
| tst.js:50:12:50:48 | this.ge ... value') |
10+
| tst.js:60:1:60:39 | new Fir ... em('x') |
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import javascript
2+
3+
select Firebase::snapshot()
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
| tst.js:6:3:6:9 | x.val() |
2+
| tst.js:11:3:11:9 | x.val() |
3+
| tst.js:16:3:16:9 | x.val() |
4+
| tst.js:21:3:21:16 | x.before.val() |
5+
| tst.js:22:3:22:15 | x.after.val() |
6+
| tst.js:61:36:61:36 | x |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import javascript
2+
3+
from Firebase::FirebaseVal val
4+
select val
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import * as fb from 'firebase/app';
2+
import * as admin from 'firebase-admin';
3+
import * as functions from 'firebase-functions';
4+
5+
fb.database().ref('x').once('value', x => {
6+
x.val();
7+
x.ref.parent;
8+
});
9+
10+
admin.database().ref('x').once('value', x => {
11+
x.val();
12+
x.ref.parent;
13+
});
14+
15+
functions.database.ref('x').onCreate(x => {
16+
x.val();
17+
x.ref.parent;
18+
});
19+
20+
functions.database.ref('x').onUpdate(x => {
21+
x.before.val();
22+
x.after.val();
23+
x.ref.parent;
24+
});
25+
26+
class FirebaseWrapper {
27+
constructor(firebase) {
28+
this.firebase = firebase;
29+
}
30+
31+
getRef(x) {
32+
return this.firebase.database().ref(x);
33+
}
34+
}
35+
36+
class FirebaseWrapper2 {
37+
constructor() {
38+
this.init();
39+
}
40+
41+
init() {
42+
this.firebase = fb.initializeApp();
43+
}
44+
45+
getRef(x) {
46+
return this.firebase.database().ref(x);
47+
}
48+
49+
getNewsItem(x) {
50+
return this.getRef(x).child(x).once('value');
51+
}
52+
53+
adjustValue(fn) {
54+
this.firebase.database().ref('x').transaction(fn);
55+
}
56+
}
57+
58+
new FirebaseWrapper(firebase.initializeApp()).getRef('/news');
59+
new FirebaseWrapper2().getRef('/news');
60+
new FirebaseWrapper2().getNewsItem('x');
61+
new FirebaseWrapper2().adjustValue(x => x + 1);
62+
63+
class Box {
64+
constructor(x) {
65+
this.x = x;
66+
}
67+
}
68+
let box1 = new Box(fb.database());
69+
let box2 = new Box(whatever());
70+
box2.x.ref(); // not a firebase ref

0 commit comments

Comments
 (0)