Skip to content

Commit 9ea07fb

Browse files
jshcrowthejsayol
authored andcommitted
WIP: fix several code signature problems, add test files
1 parent 0920c04 commit 9ea07fb

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

tests/database/connection.test.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
import { expect } from "chai";
2-
import { ConnectionTarget } from "../../src/database/api/test_access";
3-
import { TEST_PROJECT } from "./helpers/util";
2+
import { TEST_PROJECT, testRepoInfo } from "./helpers/util";
43
import { Connection } from "../../src/database/realtime/Connection";
54

65
describe('Connection', () => {
7-
function testRepoInfo(url) {
8-
const regex = /https:\/\/(.*).firebaseio.com/;
9-
const match = url.match(regex);
10-
if (!match) throw new Error('Couldnt get Namespace from passed URL');
11-
const [,ns] = match;
12-
return new ConnectionTarget(`${ns}.firebaseio.com`, false, ns, false);
13-
}
146
it('return the session id', function(done) {
157
new Connection('1',
168
testRepoInfo(TEST_PROJECT.databaseURL),

tests/database/helpers/util.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import '../../../src/database';
44
import { Reference } from "../../../src/database/api/Reference";
55
import { Query } from "../../../src/database/api/Query";
66
import { expect } from "chai";
7+
import { ConnectionTarget } from "../../../src/database/api/test_access";
8+
79

810
export const TEST_PROJECT = require('../../config/project.json');
911

@@ -211,3 +213,11 @@ export function buildObjFromKey(key) {
211213
}
212214
return obj;
213215
};
216+
217+
export function testRepoInfo(url) {
218+
const regex = /https:\/\/(.*).firebaseio.com/;
219+
const match = url.match(regex);
220+
if (!match) throw new Error('Couldnt get Namespace from passed URL');
221+
const [,ns] = match;
222+
return new ConnectionTarget(`${ns}.firebaseio.com`, false, ns, false);
223+
}

0 commit comments

Comments
 (0)