|
1 | 1 | /**
|
2 | 2 | * @license
|
3 |
| - * Copyright 2017 Google Inc. |
| 3 | + * Copyright 2017 Google LLC |
4 | 4 | *
|
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License");
|
6 | 6 | * you may not use this file except in compliance with the License.
|
@@ -62,18 +62,49 @@ describe('Database Tests', () => {
|
62 | 62 | expect(db.ref().toString()).to.equal('https://foo.bar.com/');
|
63 | 63 | });
|
64 | 64 |
|
| 65 | + it('Can get database with multi-region URL', () => { |
| 66 | + const db = defaultApp.database('http://foo.euw1.firebasedatabase.app'); |
| 67 | + expect(db).to.be.ok; |
| 68 | + expect(db.repo_.repoInfo_.namespace).to.equal('foo'); |
| 69 | + expect(db.ref().toString()).to.equal( |
| 70 | + 'https://foo.euw1.firebasedatabase.app/' |
| 71 | + ); |
| 72 | + }); |
| 73 | + |
| 74 | + it('Can get database with upper case URL', () => { |
| 75 | + const db = defaultApp.database('http://fOO.EUW1.firebaseDATABASE.app'); |
| 76 | + expect(db).to.be.ok; |
| 77 | + expect(db.repo_.repoInfo_.namespace).to.equal('foo'); |
| 78 | + expect(db.ref().toString()).to.equal( |
| 79 | + 'https://foo.euw1.firebasedatabase.app/' |
| 80 | + ); |
| 81 | + }); |
| 82 | + |
| 83 | + it('Can get database with localhost URL', () => { |
| 84 | + const db = defaultApp.database('http://localhost'); |
| 85 | + expect(db).to.be.ok; |
| 86 | + expect(db.ref().toString()).to.equal('https://localhost/'); |
| 87 | + }); |
| 88 | + |
65 | 89 | it('Can get database with localhost URL and port', () => {
|
66 | 90 | const db = defaultApp.database('http://localhost:80');
|
67 | 91 | expect(db).to.be.ok;
|
68 | 92 | expect(db.ref().toString()).to.equal('http://localhost:80/');
|
69 | 93 | });
|
70 | 94 |
|
71 |
| - it('Can get database with localhost URL', () => { |
72 |
| - const db = defaultApp.database('http://localhost'); |
| 95 | + it('Can get database with a upper case localhost URL', () => { |
| 96 | + const db = defaultApp.database('http://LOCALHOST'); |
73 | 97 | expect(db).to.be.ok;
|
74 | 98 | expect(db.ref().toString()).to.equal('https://localhost/');
|
75 | 99 | });
|
76 | 100 |
|
| 101 | + it('Can get database with a upper case localhost URL and ns', () => { |
| 102 | + const db = defaultApp.database('http://LOCALHOST?ns=foo'); |
| 103 | + expect(db).to.be.ok; |
| 104 | + expect(db.repo_.repoInfo_.namespace).to.equal('foo'); |
| 105 | + expect(db.ref().toString()).to.equal('https://localhost/'); |
| 106 | + }); |
| 107 | + |
77 | 108 | it('Can read ns query param', () => {
|
78 | 109 | const db = defaultApp.database('http://localhost:80/?ns=foo&unused=true');
|
79 | 110 | expect(db).to.be.ok;
|
@@ -111,10 +142,19 @@ describe('Database Tests', () => {
|
111 | 142 | }).to.throw(/Database initialized multiple times/i);
|
112 | 143 | });
|
113 | 144 |
|
| 145 | + it('Databases with legacy domain', () => { |
| 146 | + expect(() => { |
| 147 | + defaultApp.database('http://foo.firebase.com/'); |
| 148 | + }).to.throw(/is no longer supported/i); |
| 149 | + }); |
| 150 | + |
114 | 151 | it('Databases with invalid custom URLs', () => {
|
115 | 152 | expect(() => {
|
116 | 153 | defaultApp.database('not-a-url');
|
117 | 154 | }).to.throw(/Cannot parse Firebase url/i);
|
| 155 | + expect(() => { |
| 156 | + defaultApp.database('http://foo.com'); |
| 157 | + }).to.throw(/Cannot parse Firebase url/i); |
118 | 158 | expect(() => {
|
119 | 159 | defaultApp.database('http://fblocal.com');
|
120 | 160 | }).to.throw(/Cannot parse Firebase url/i);
|
|
0 commit comments