-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(database): add database.useEmulator()
- detox needed another timer disable on android to succeed - offline / online is flaky - lots of the e2e databases tests themselves are flaky - did my best there - database rules are injected dynamically using @firebase/rules-unit-testing which is nice
- Loading branch information
Showing
44 changed files
with
781 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"rules": { | ||
// Database in general is closed. Read/Write to anything but "tests/" will fail. | ||
".read": false, | ||
".write": false, | ||
|
||
// ..."tests" node will succeed | ||
"tests": { | ||
".read": true, | ||
".write": true, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import database, { firebase } from '../lib'; | ||
|
||
describe('Database', function () { | ||
describe('namespace', function () { | ||
it('accessible from firebase.app()', function () { | ||
const app = firebase.app(); | ||
expect(app.database).toBeDefined(); | ||
expect(app.database().useEmulator).toBeDefined(); | ||
}); | ||
}); | ||
|
||
describe('useEmulator()', function () { | ||
it('useEmulator requires a string host', function () { | ||
// @ts-ignore because we pass an invalid argument... | ||
expect(() => database().useEmulator()).toThrow( | ||
'firebase.database().useEmulator() takes a non-empty host', | ||
); | ||
expect(() => database().useEmulator('', -1)).toThrow( | ||
'firebase.database().useEmulator() takes a non-empty host', | ||
); | ||
// @ts-ignore because we pass an invalid argument... | ||
expect(() => database().useEmulator(123)).toThrow( | ||
'firebase.database().useEmulator() takes a non-empty host', | ||
); | ||
}); | ||
|
||
it('useEmulator requires a host and port', function () { | ||
expect(() => database().useEmulator('', 9000)).toThrow( | ||
'firebase.database().useEmulator() takes a non-empty host and port', | ||
); | ||
// No port | ||
// @ts-ignore because we pass an invalid argument... | ||
expect(() => database().useEmulator('localhost')).toThrow( | ||
'firebase.database().useEmulator() takes a non-empty host and port', | ||
); | ||
}); | ||
|
||
it('useEmulator -> remaps Android loopback to host', function () { | ||
const foo = database().useEmulator('localhost', 9000); | ||
expect(foo).toEqual(['10.0.2.2', 9000]); | ||
|
||
const bar = database().useEmulator('127.0.0.1', 9000); | ||
expect(bar).toEqual(['10.0.2.2', 9000]); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
0632ca5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: