[tests] refactor dynamic apps platform config into a TestsHelper util -> TestsHelper.core.config()
This commit is contained in:
parent
151f6b4886
commit
22ad63118c
|
@ -1,31 +1,3 @@
|
|||
const androidTestConfig = {
|
||||
// firebase android sdk completely ignores client id
|
||||
clientId:
|
||||
'305229645282-j8ij0jev9ut24odmlk9i215pas808ugn.apps.googleusercontent.com',
|
||||
appId: '1:305229645282:android:af36d4d29a83e04c',
|
||||
apiKey: 'AIzaSyCzbBYFyX8d6VdSu7T4s10IWYbPc-dguwM',
|
||||
databaseURL: 'https://rnfirebase-b9ad4.firebaseio.com',
|
||||
storageBucket: 'rnfirebase-b9ad4.appspot.com',
|
||||
messagingSenderId: '305229645282',
|
||||
projectId: 'rnfirebase-b9ad4',
|
||||
};
|
||||
|
||||
const iosTestConfig = {
|
||||
clientId:
|
||||
'305229645282-22imndi01abc2p6esgtu1i1m9mqrd0ib.apps.googleusercontent.com',
|
||||
androidClientId: androidTestConfig.clientId,
|
||||
appId: '1:305229645282:ios:af36d4d29a83e04c',
|
||||
apiKey: 'AIzaSyAcdVLG5dRzA1ck_fa_xd4Z0cY7cga7S5A',
|
||||
databaseURL: 'https://rnfirebase-b9ad4.firebaseio.com',
|
||||
storageBucket: 'rnfirebase-b9ad4.appspot.com',
|
||||
messagingSenderId: '305229645282',
|
||||
projectId: 'rnfirebase-b9ad4',
|
||||
};
|
||||
|
||||
function rand(from = 1, to = 9999) {
|
||||
const r = Math.random();
|
||||
return Math.floor(r * (to - from + from));
|
||||
}
|
||||
describe('Core', () => {
|
||||
describe('Firebase', () => {
|
||||
it('it should create js apps for natively initialized apps', () => {
|
||||
|
@ -34,30 +6,24 @@ describe('Core', () => {
|
|||
});
|
||||
|
||||
it('natively initialized apps should have options available in js', () => {
|
||||
should.equal(
|
||||
firebase.app().options.apiKey,
|
||||
device.getPlatform() === 'ios'
|
||||
? iosTestConfig.apiKey
|
||||
: androidTestConfig.apiKey
|
||||
);
|
||||
should.equal(
|
||||
firebase.app().options.appId,
|
||||
device.getPlatform() === 'ios'
|
||||
? iosTestConfig.appId
|
||||
: androidTestConfig.appId
|
||||
);
|
||||
const platformAppConfig = TestHelpers.core.config();
|
||||
should.equal(firebase.app().options.apiKey, platformAppConfig.apiKey);
|
||||
should.equal(firebase.app().options.appId, platformAppConfig.appId);
|
||||
should.equal(
|
||||
firebase.app().options.databaseURL,
|
||||
iosTestConfig.databaseURL
|
||||
platformAppConfig.databaseURL
|
||||
);
|
||||
should.equal(
|
||||
firebase.app().options.messagingSenderId,
|
||||
iosTestConfig.messagingSenderId
|
||||
platformAppConfig.messagingSenderId
|
||||
);
|
||||
should.equal(
|
||||
firebase.app().options.projectId,
|
||||
platformAppConfig.projectId
|
||||
);
|
||||
should.equal(firebase.app().options.projectId, iosTestConfig.projectId);
|
||||
should.equal(
|
||||
firebase.app().options.storageBucket,
|
||||
iosTestConfig.storageBucket
|
||||
platformAppConfig.storageBucket
|
||||
);
|
||||
return Promise.resolve();
|
||||
});
|
||||
|
@ -66,20 +32,15 @@ describe('Core', () => {
|
|||
firebase.app().onReady());
|
||||
|
||||
it('it should initialize dynamic apps', () => {
|
||||
const name = `testscoreapp${rand()}`;
|
||||
const name = `testscoreapp${global.testRunId}`;
|
||||
const platformAppConfig = TestHelpers.core.config();
|
||||
return firebase
|
||||
.initializeApp(
|
||||
device.getPlatform() === 'ios' ? iosTestConfig : androidTestConfig,
|
||||
name
|
||||
)
|
||||
.initializeApp(platformAppConfig, name)
|
||||
.onReady()
|
||||
.then(newApp => {
|
||||
newApp.name.should.equal(name.toUpperCase());
|
||||
newApp.toString().should.equal(name.toUpperCase());
|
||||
newApp.options.apiKey.should.equal(
|
||||
(device.getPlatform() === 'ios' ? iosTestConfig : androidTestConfig)
|
||||
.apiKey
|
||||
);
|
||||
newApp.options.apiKey.should.equal(platformAppConfig.apiKey);
|
||||
// TODO add back in when android sdk support for deleting apps becomes available
|
||||
// return newApp.delete();
|
||||
return Promise.resolve();
|
||||
|
|
|
@ -62,6 +62,7 @@ global.randomString = (length, chars) => {
|
|||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
global.testRunId = randomString(4, 'aA#');
|
||||
|
||||
/** ------------------
|
||||
|
@ -112,10 +113,41 @@ Promise.defer = function defer() {
|
|||
return deferred;
|
||||
};
|
||||
|
||||
const androidTestConfig = {
|
||||
// firebase android sdk completely ignores client id
|
||||
clientId:
|
||||
'305229645282-j8ij0jev9ut24odmlk9i215pas808ugn.apps.googleusercontent.com',
|
||||
appId: '1:305229645282:android:af36d4d29a83e04c',
|
||||
apiKey: 'AIzaSyCzbBYFyX8d6VdSu7T4s10IWYbPc-dguwM',
|
||||
databaseURL: 'https://rnfirebase-b9ad4.firebaseio.com',
|
||||
storageBucket: 'rnfirebase-b9ad4.appspot.com',
|
||||
messagingSenderId: '305229645282',
|
||||
projectId: 'rnfirebase-b9ad4',
|
||||
};
|
||||
|
||||
const iosTestConfig = {
|
||||
clientId:
|
||||
'305229645282-22imndi01abc2p6esgtu1i1m9mqrd0ib.apps.googleusercontent.com',
|
||||
androidClientId: androidTestConfig.clientId,
|
||||
appId: '1:305229645282:ios:af36d4d29a83e04c',
|
||||
apiKey: 'AIzaSyAcdVLG5dRzA1ck_fa_xd4Z0cY7cga7S5A',
|
||||
databaseURL: 'https://rnfirebase-b9ad4.firebaseio.com',
|
||||
storageBucket: 'rnfirebase-b9ad4.appspot.com',
|
||||
messagingSenderId: '305229645282',
|
||||
projectId: 'rnfirebase-b9ad4',
|
||||
};
|
||||
|
||||
global.TestHelpers = {
|
||||
functions: {
|
||||
data: require('./../functions/test-data'),
|
||||
},
|
||||
firestore: require('./firestore'),
|
||||
database: require('./database'),
|
||||
core: {
|
||||
config() {
|
||||
const config =
|
||||
device.getPlatform() === 'ios' ? iosTestConfig : androidTestConfig;
|
||||
return { ...config };
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
"version": "7.0.0-beta.47",
|
||||
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.0.0-beta.47.tgz",
|
||||
"integrity": "sha512-7EIuAX0UVnCgZ0E9tz9rFK0gd+aovwMA9bul+dnkmBQYLrJdas2EHMUSmaK67i1cyZpvgVvXhHtXJxC7wo3rlQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/code-frame": "7.0.0-beta.47",
|
||||
"@babel/generator": "7.0.0-beta.47",
|
||||
|
@ -63,6 +64,7 @@
|
|||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz",
|
||||
"integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"arr-flatten": "^1.0.1"
|
||||
}
|
||||
|
@ -70,17 +72,20 @@
|
|||
"array-unique": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz",
|
||||
"integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM="
|
||||
"integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=",
|
||||
"dev": true
|
||||
},
|
||||
"babylon": {
|
||||
"version": "7.0.0-beta.47",
|
||||
"resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.47.tgz",
|
||||
"integrity": "sha512-+rq2cr4GDhtToEzKFD6KZZMDBXhjFAr9JjPw9pAppZACeEWqNM294j+NdBzkSHYXwzzBmVjZ3nEVJlOhbR2gOQ=="
|
||||
"integrity": "sha512-+rq2cr4GDhtToEzKFD6KZZMDBXhjFAr9JjPw9pAppZACeEWqNM294j+NdBzkSHYXwzzBmVjZ3nEVJlOhbR2gOQ==",
|
||||
"dev": true
|
||||
},
|
||||
"braces": {
|
||||
"version": "1.8.5",
|
||||
"resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz",
|
||||
"integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"expand-range": "^1.8.1",
|
||||
"preserve": "^0.2.0",
|
||||
|
@ -91,6 +96,7 @@
|
|||
"version": "0.1.5",
|
||||
"resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz",
|
||||
"integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-posix-bracket": "^0.1.0"
|
||||
}
|
||||
|
@ -99,6 +105,7 @@
|
|||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz",
|
||||
"integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-extglob": "^1.0.0"
|
||||
}
|
||||
|
@ -106,12 +113,14 @@
|
|||
"is-extglob": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz",
|
||||
"integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA="
|
||||
"integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=",
|
||||
"dev": true
|
||||
},
|
||||
"is-glob": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz",
|
||||
"integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-extglob": "^1.0.0"
|
||||
}
|
||||
|
@ -120,6 +129,7 @@
|
|||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
|
||||
"integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-buffer": "^1.1.5"
|
||||
}
|
||||
|
@ -128,6 +138,7 @@
|
|||
"version": "2.3.11",
|
||||
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz",
|
||||
"integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"arr-diff": "^2.0.0",
|
||||
"array-unique": "^0.2.1",
|
||||
|
@ -147,7 +158,8 @@
|
|||
"source-map": {
|
||||
"version": "0.5.7",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
|
||||
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w="
|
||||
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -363,6 +375,7 @@
|
|||
"version": "7.0.0-beta.47",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.0.0-beta.47.tgz",
|
||||
"integrity": "sha512-uWk7gIua2COEWLwZGxfF5Wq1bgXOt1V6xzWxqeFznrA6F1TUPiAhkK5zORiZEa5RAILp6Mswsn3xFjDyCpp3rQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/template": "7.0.0-beta.47",
|
||||
"@babel/traverse": "7.0.0-beta.47",
|
||||
|
@ -6804,6 +6817,53 @@
|
|||
"yargs": "^9.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/core": {
|
||||
"version": "7.0.0-beta.47",
|
||||
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.0.0-beta.47.tgz",
|
||||
"integrity": "sha512-7EIuAX0UVnCgZ0E9tz9rFK0gd+aovwMA9bul+dnkmBQYLrJdas2EHMUSmaK67i1cyZpvgVvXhHtXJxC7wo3rlQ==",
|
||||
"requires": {
|
||||
"@babel/code-frame": "7.0.0-beta.47",
|
||||
"@babel/generator": "7.0.0-beta.47",
|
||||
"@babel/helpers": "7.0.0-beta.47",
|
||||
"@babel/template": "7.0.0-beta.47",
|
||||
"@babel/traverse": "7.0.0-beta.47",
|
||||
"@babel/types": "7.0.0-beta.47",
|
||||
"babylon": "7.0.0-beta.47",
|
||||
"convert-source-map": "^1.1.0",
|
||||
"debug": "^3.1.0",
|
||||
"json5": "^0.5.0",
|
||||
"lodash": "^4.17.5",
|
||||
"micromatch": "^2.3.11",
|
||||
"resolve": "^1.3.2",
|
||||
"semver": "^5.4.1",
|
||||
"source-map": "^0.5.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
|
||||
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"json5": {
|
||||
"version": "0.5.1",
|
||||
"resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz",
|
||||
"integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE="
|
||||
}
|
||||
}
|
||||
},
|
||||
"@babel/helpers": {
|
||||
"version": "7.0.0-beta.47",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.0.0-beta.47.tgz",
|
||||
"integrity": "sha512-uWk7gIua2COEWLwZGxfF5Wq1bgXOt1V6xzWxqeFznrA6F1TUPiAhkK5zORiZEa5RAILp6Mswsn3xFjDyCpp3rQ==",
|
||||
"requires": {
|
||||
"@babel/template": "7.0.0-beta.47",
|
||||
"@babel/traverse": "7.0.0-beta.47",
|
||||
"@babel/types": "7.0.0-beta.47"
|
||||
}
|
||||
},
|
||||
"ansi-regex": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
|
||||
|
@ -6814,11 +6874,34 @@
|
|||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz",
|
||||
"integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4="
|
||||
},
|
||||
"arr-diff": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz",
|
||||
"integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=",
|
||||
"requires": {
|
||||
"arr-flatten": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"array-unique": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz",
|
||||
"integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM="
|
||||
},
|
||||
"babylon": {
|
||||
"version": "7.0.0-beta.47",
|
||||
"resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.47.tgz",
|
||||
"integrity": "sha512-+rq2cr4GDhtToEzKFD6KZZMDBXhjFAr9JjPw9pAppZACeEWqNM294j+NdBzkSHYXwzzBmVjZ3nEVJlOhbR2gOQ=="
|
||||
},
|
||||
"braces": {
|
||||
"version": "1.8.5",
|
||||
"resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz",
|
||||
"integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=",
|
||||
"requires": {
|
||||
"expand-range": "^1.8.1",
|
||||
"preserve": "^0.2.0",
|
||||
"repeat-element": "^1.1.2"
|
||||
}
|
||||
},
|
||||
"camelcase": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz",
|
||||
|
@ -6844,6 +6927,22 @@
|
|||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"expand-brackets": {
|
||||
"version": "0.1.5",
|
||||
"resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz",
|
||||
"integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=",
|
||||
"requires": {
|
||||
"is-posix-bracket": "^0.1.0"
|
||||
}
|
||||
},
|
||||
"extglob": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz",
|
||||
"integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=",
|
||||
"requires": {
|
||||
"is-extglob": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"fs-extra": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz",
|
||||
|
@ -6854,11 +6953,24 @@
|
|||
"klaw": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"is-extglob": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz",
|
||||
"integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA="
|
||||
},
|
||||
"is-fullwidth-code-point": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
|
||||
"integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8="
|
||||
},
|
||||
"is-glob": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz",
|
||||
"integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=",
|
||||
"requires": {
|
||||
"is-extglob": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"json5": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/json5/-/json5-0.4.0.tgz",
|
||||
|
@ -6872,6 +6984,34 @@
|
|||
"graceful-fs": "^4.1.6"
|
||||
}
|
||||
},
|
||||
"kind-of": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
|
||||
"integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=",
|
||||
"requires": {
|
||||
"is-buffer": "^1.1.5"
|
||||
}
|
||||
},
|
||||
"micromatch": {
|
||||
"version": "2.3.11",
|
||||
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz",
|
||||
"integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=",
|
||||
"requires": {
|
||||
"arr-diff": "^2.0.0",
|
||||
"array-unique": "^0.2.1",
|
||||
"braces": "^1.8.2",
|
||||
"expand-brackets": "^0.1.4",
|
||||
"extglob": "^0.3.1",
|
||||
"filename-regex": "^2.0.0",
|
||||
"is-extglob": "^1.0.0",
|
||||
"is-glob": "^2.0.1",
|
||||
"kind-of": "^3.0.2",
|
||||
"normalize-path": "^2.0.1",
|
||||
"object.omit": "^2.0.0",
|
||||
"parse-glob": "^3.0.4",
|
||||
"regex-cache": "^0.4.2"
|
||||
}
|
||||
},
|
||||
"mime-db": {
|
||||
"version": "1.23.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.23.0.tgz",
|
||||
|
|
Loading…
Reference in New Issue