diff --git a/bridge/e2e/auth/auth.e2e.js b/bridge/e2e/auth/auth.e2e.js index 9950791a..c3549ec6 100644 --- a/bridge/e2e/auth/auth.e2e.js +++ b/bridge/e2e/auth/auth.e2e.js @@ -1,4 +1,26 @@ describe('auth()', () => { + beforeEach(async () => { + if (firebase.auth().currentUser) await firebase.auth().signOut(); + }); + + describe('signInWithCustomToken()', () => { + it('signs in with a admin sdk created custom auth token', async () => { + const customUID = `custom${randomString(12, '#aA')}`; + const token = await firebaseAdmin.auth().createCustomToken(customUID); + const user = await firebase.auth().signInWithCustomToken(token); + user.uid.should.equal(customUID); + firebase.auth().currentUser.uid.should.equal(customUID); + + await firebase.auth().signOut(); + const { + user: user2, + } = await firebase.auth().signInAndRetrieveDataWithCustomToken(token); + + user2.uid.should.equal(customUID); + firebase.auth().currentUser.uid.should.equal(customUID); + }); + }); + describe('onAuthStateChanged()', () => { it('calls callback with the current user and when auth state changes', async () => { await firebase.auth().signInAnonymouslyAndRetrieveData(); diff --git a/bridge/e2e/init.js b/bridge/e2e/init.js index f4684061..bf1be32c 100755 --- a/bridge/e2e/init.js +++ b/bridge/e2e/init.js @@ -1,9 +1,6 @@ const detox = require('detox'); const config = require('../package.json').detox; - -global.sinon = require('sinon'); -require('should-sinon'); -global.should = require('should'); +require('./../helpers'); before(async () => { await detox.init(config); @@ -12,27 +9,3 @@ before(async () => { after(async () => { await detox.cleanup(); }); - -Object.defineProperty(global, 'firebase', { - get() { - return bridge.module; - }, -}); - -global.sleep = duration => - new Promise(resolve => { - setTimeout(resolve, duration); - }); - -global.randomString = (length, chars) => { - let mask = ''; - if (chars.indexOf('a') > -1) mask += 'abcdefghijklmnopqrstuvwxyz'; - if (chars.indexOf('A') > -1) mask += 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; - if (chars.indexOf('#') > -1) mask += '0123456789'; - if (chars.indexOf('!') > -1) mask += '~`!@#$%^&*()_+-={}[]:";\'<>?,./|\\'; - let result = ''; - for (let i = length; i > 0; --i) { - result += mask[Math.round(Math.random() * (mask.length - 1))]; - } - return result; -};