diff --git a/.eslintrc.js b/.eslintrc.js index 1f5cf601dc..74eadca77d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -33,10 +33,12 @@ module.exports = { 'no-underscore-dangle': 'off', 'no-use-before-define': 0, 'import/no-unresolved': 0, + '@typescript-eslint/ban-ts-comment': 'off', // keep it professional when you use them though please '@typescript-eslint/no-use-before-define': 'off', '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-var-requires': 'off', '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/camelcase': 'off', '@typescript-eslint/no-empty-function': 'off', // off for validation tests @@ -45,7 +47,6 @@ module.exports = { 'mocha/no-top-level-hooks': 'off', // potentially has value if anyone wants to refactor 'mocha/no-hooks-for-single-case': 'off', // potentially has value 'mocha/no-setup-in-describe': 'off', // potentially has value, large refactor here though - }, globals: { __DEV__: true, diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 3a4f7d0dc7..442953ae6a 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -42,9 +42,9 @@ jobs: max_attempts: 3 command: yarn --no-audit --prefer-offline - name: Lint - run: yarn run lint + run: yarn lint - name: Save Code Linting Report JSON - run: yarn run lint:report + run: yarn lint:report continue-on-error: true - name: Annotate Code Linting Results uses: ataylorme/eslint-annotate-action@1.1.2 @@ -91,7 +91,7 @@ jobs: max_attempts: 3 command: yarn --no-audit --prefer-offline - name: Lint - run: yarn run tsc:compile + run: yarn tsc:compile typedoc: name: TypeDoc Generation diff --git a/.github/workflows/tests_e2e.yml b/.github/workflows/tests_e2e.yml index b1614b7535..0d173bdecb 100644 --- a/.github/workflows/tests_e2e.yml +++ b/.github/workflows/tests_e2e.yml @@ -90,7 +90,7 @@ jobs: - name: Pre-fetch Javascript bundle # Prebuild the bundle so that's fast when the app starts. run: | - nohup yarn run tests:packager:jet & + nohup yarn tests:packager:jet & printf 'Waiting for packager to come online' until curl --output /dev/null --silent --head --fail http://localhost:8081/status; do printf '.' @@ -296,7 +296,7 @@ jobs: - name: Pre-fetch Javascript bundle run: | - nohup yarn run tests:packager:jet & + nohup yarn tests:packager:jet & printf 'Waiting for packager to come online' until curl --output /dev/null --silent --head --fail http://localhost:8081/status; do printf '.' diff --git a/.github/workflows/tests_jest.yml b/.github/workflows/tests_jest.yml index 4183666d6b..f6da18435c 100644 --- a/.github/workflows/tests_jest.yml +++ b/.github/workflows/tests_jest.yml @@ -54,7 +54,7 @@ jobs: max_attempts: 3 command: yarn --no-audit --prefer-offline - name: Jest - run: yarn run tests:jest-coverage + run: yarn tests:jest-coverage - name: Submit Coverage # This can fail on timeouts etc, wrap with retry uses: nick-invision/retry@v2 diff --git a/package.json b/package.json index 3ce22e45a9..eaa59610a1 100644 --- a/package.json +++ b/package.json @@ -41,30 +41,30 @@ "format:markdown": "prettier --write \"docs/**/*.md\"" }, "devDependencies": { - "@babel/preset-env": "7.9.5", - "@babel/preset-flow": "7.9.0", - "@types/jest": "^25.2.1", + "@babel/preset-env": "7.12.11", + "@babel/preset-flow": "7.12.1", + "@types/jest": "^26.0.19", "@types/react": "^16.9.49", - "@types/react-native": "^0.62.0", - "@typescript-eslint/eslint-plugin": "^2.18.0", - "@typescript-eslint/parser": "^2.18.0", + "@types/react-native": "^0.63.42", + "@typescript-eslint/eslint-plugin": "^4.11.0", + "@typescript-eslint/parser": "^4.11.0", "codecov": "^3.6.5", "conventional-changelog-cli": "^2.0.34", - "cross-env": "^7.0.2", - "eslint": "^6.8.0", - "eslint-config-prettier": "^6.5.0", + "cross-env": "^7.0.3", + "eslint": "^7.16.0", + "eslint-config-prettier": "^7.1.0", "eslint-plugin-mocha": "^8.0.0", - "eslint-plugin-prettier": "^3.1.1", + "eslint-plugin-prettier": "^3.3.0", "eslint-plugin-react": "^7.19.0", "genversion": "^2.2.0", "inquirer": "^7.1.0", - "jest": "^25.5.1", - "lerna": "3.20.2", - "prettier": "^1.19.1", + "jest": "^26.6.3", + "lerna": "3.22.1", + "prettier": "^2.2.1", "rimraf": "^3.0.2", "shelljs": "^0.8.3", - "ts-jest": "^25.4.0", - "typescript": "^3.8.3" + "ts-jest": "^26.4.4", + "typescript": "^4.1.3" }, "resolutions": { "@types/react": "^16.9.49" diff --git a/packages/admob/__tests__/admob.test.ts b/packages/admob/__tests__/admob.test.ts index 5e624bb045..78e4323360 100644 --- a/packages/admob/__tests__/admob.test.ts +++ b/packages/admob/__tests__/admob.test.ts @@ -1,24 +1,24 @@ import { firebase, FirebaseAdMobTypes } from '../lib'; -describe('Admob', function() { - describe('namespace', function() { - it('accessible from firebase.app()', function() { +describe('Admob', function () { + describe('namespace', function () { + it('accessible from firebase.app()', function () { const app = firebase.app(); expect(app.admob).toBeDefined(); expect(app.admob().app).toEqual(app); }); }); - describe('setRequestConfiguration()', function() { - it('throws if config is not an object', function() { + describe('setRequestConfiguration()', function () { + it('throws if config is not an object', function () { // @ts-ignore expect(() => firebase.admob().setRequestConfiguration('123')).toThrowError( "firebase.admob().setRequestConfiguration(*) 'requestConfiguration' expected an object value", ); }); - describe('maxAdContentRating', function() { - it('throws if maxAdContentRating is invalid', function() { + describe('maxAdContentRating', function () { + it('throws if maxAdContentRating is invalid', function () { expect(() => firebase.admob().setRequestConfiguration({ maxAdContentRating: 'Y' as FirebaseAdMobTypes.MaxAdContentRating[keyof FirebaseAdMobTypes.MaxAdContentRating], @@ -29,8 +29,8 @@ describe('Admob', function() { }); }); - describe('tagForChildDirectedTreatment', function() { - it('throws if tagForChildDirectedTreatment not a boolean', function() { + describe('tagForChildDirectedTreatment', function () { + it('throws if tagForChildDirectedTreatment not a boolean', function () { expect(() => firebase.admob().setRequestConfiguration({ // @ts-ignore @@ -42,8 +42,8 @@ describe('Admob', function() { }); }); - describe('tagForUnderAgeOfConsent', function() { - it('throws if tagForUnderAgeOfConsent not a boolean', function() { + describe('tagForUnderAgeOfConsent', function () { + it('throws if tagForUnderAgeOfConsent not a boolean', function () { expect(() => firebase.admob().setRequestConfiguration({ // @ts-ignore diff --git a/packages/admob/__tests__/consent.test.ts b/packages/admob/__tests__/consent.test.ts index d60563ef48..9f90f7342f 100644 --- a/packages/admob/__tests__/consent.test.ts +++ b/packages/admob/__tests__/consent.test.ts @@ -1,21 +1,21 @@ import { AdsConsent } from '../lib'; -describe('Admob AdsConsent', function() { - describe('requestInfoUpdate', function() { - it('throws if publisherIds is not an array', function() { +describe('Admob AdsConsent', function () { + describe('requestInfoUpdate', function () { + it('throws if publisherIds is not an array', function () { // @ts-ignore expect(() => AdsConsent.requestInfoUpdate('pub-123')).toThrowError( "firebase.admob.AdsConsent.requestInfoUpdate(*) 'publisherIds' expected an array of string values.", ); }); - it('throws if publisherIds is empty array', function() { + it('throws if publisherIds is empty array', function () { expect(() => AdsConsent.requestInfoUpdate([])).toThrowError( "firebase.admob.AdsConsent.requestInfoUpdate(*) 'publisherIds' list of publisher IDs cannot be empty.", ); }); - it('throws if publisherIds contains non-string values', function() { + it('throws if publisherIds contains non-string values', function () { // @ts-ignore expect(() => AdsConsent.requestInfoUpdate(['foo', 123])).toThrowError( "firebase.admob.AdsConsent.requestInfoUpdate(*) 'publisherIds[1]' expected a string value.", diff --git a/packages/admob/__tests__/interstitial.test.ts b/packages/admob/__tests__/interstitial.test.ts index 1a0d88eb1e..bf855b47d9 100644 --- a/packages/admob/__tests__/interstitial.test.ts +++ b/packages/admob/__tests__/interstitial.test.ts @@ -1,15 +1,15 @@ import { InterstitialAd } from '../lib'; -describe('Admob Interstitial', function() { - describe('createForAdRequest', function() { - it('throws if adUnitId is invalid', function() { +describe('Admob Interstitial', function () { + describe('createForAdRequest', function () { + it('throws if adUnitId is invalid', function () { // @ts-ignore expect(() => InterstitialAd.createForAdRequest(123)).toThrowError( "'adUnitId' expected an string value", ); }); - it('throws if requestOptions are invalid', function() { + it('throws if requestOptions are invalid', function () { // @ts-ignore expect(() => InterstitialAd.createForAdRequest('123', 123)).toThrowError( "firebase.admob() InterstitialAd.createForAdRequest(_, *) 'options' expected an object value.", @@ -17,15 +17,15 @@ describe('Admob Interstitial', function() { }); // has own tests - it('returns a new instance', function() { + it('returns a new instance', function () { const i = InterstitialAd.createForAdRequest('abc'); expect(i.constructor.name).toEqual('InterstitialAd'); expect(i.adUnitId).toEqual('abc'); expect(i.loaded).toEqual(false); }); - describe('show', function() { - it('throws if showing before loaded', function() { + describe('show', function () { + it('throws if showing before loaded', function () { const i = InterstitialAd.createForAdRequest('abc'); expect(() => i.show()).toThrowError( @@ -34,15 +34,15 @@ describe('Admob Interstitial', function() { }); }); - describe('onAdEvent', function() { - it('throws if handler is not a function', function() { + describe('onAdEvent', function () { + it('throws if handler is not a function', function () { const i = InterstitialAd.createForAdRequest('abc'); // @ts-ignore expect(() => i.onAdEvent('foo')).toThrowError("'handler' expected a function"); }); - it('returns an unsubscriber function', function() { + it('returns an unsubscriber function', function () { const i = InterstitialAd.createForAdRequest('abc'); const unsub = i.onAdEvent(() => {}); expect(unsub).toBeDefined(); diff --git a/packages/admob/e2e/admob.e2e.js b/packages/admob/e2e/admob.e2e.js index d382714c9c..67bcfcc0e9 100644 --- a/packages/admob/e2e/admob.e2e.js +++ b/packages/admob/e2e/admob.e2e.js @@ -15,17 +15,17 @@ * */ -describe('admob()', function() { - describe('namespace', function() { - it('accessible from firebase.app()', function() { +describe('admob()', function () { + describe('namespace', function () { + it('accessible from firebase.app()', function () { const app = firebase.app(); should.exist(app.admob); app.admob().app.should.equal(app); }); }); - describe('setRequestConfiguration()', function() { - it('throws if config is not an object', function() { + describe('setRequestConfiguration()', function () { + it('throws if config is not an object', function () { try { firebase.admob().setRequestConfiguration('123'); return Promise.reject(new Error('Did not throw Error.')); @@ -35,8 +35,8 @@ describe('admob()', function() { } }); - describe('maxAdContentRating', function() { - it('throws if maxAdContentRating is invalid', function() { + describe('maxAdContentRating', function () { + it('throws if maxAdContentRating is invalid', function () { try { firebase.admob().setRequestConfiguration({ maxAdContentRating: 'Y', @@ -48,15 +48,15 @@ describe('admob()', function() { } }); - it('accepts a age rating', async function() { + it('accepts a age rating', async function () { await firebase.admob().setRequestConfiguration({ maxAdContentRating: firebase.admob.MaxAdContentRating.G, }); }); }); - describe('tagForChildDirectedTreatment', function() { - it('throws if tagForChildDirectedTreatment not a boolean', function() { + describe('tagForChildDirectedTreatment', function () { + it('throws if tagForChildDirectedTreatment not a boolean', function () { try { firebase.admob().setRequestConfiguration({ tagForChildDirectedTreatment: 'true', @@ -70,15 +70,15 @@ describe('admob()', function() { } }); - it('sets the value', async function() { + it('sets the value', async function () { await firebase.admob().setRequestConfiguration({ tagForChildDirectedTreatment: false, }); }); }); - describe('tagForUnderAgeOfConsent', function() { - it('throws if tagForUnderAgeOfConsent not a boolean', function() { + describe('tagForUnderAgeOfConsent', function () { + it('throws if tagForUnderAgeOfConsent not a boolean', function () { try { firebase.admob().setRequestConfiguration({ tagForUnderAgeOfConsent: 'false', @@ -92,7 +92,7 @@ describe('admob()', function() { } }); - it('sets the value', async function() { + it('sets the value', async function () { await firebase.admob().setRequestConfiguration({ tagForUnderAgeOfConsent: false, }); diff --git a/packages/admob/e2e/consent.e2e.js b/packages/admob/e2e/consent.e2e.js index 33af635c95..575ca76f23 100644 --- a/packages/admob/e2e/consent.e2e.js +++ b/packages/admob/e2e/consent.e2e.js @@ -17,21 +17,21 @@ let AdsConsent; -describe('admob() AdsConsent', function() { - before(function() { +describe('admob() AdsConsent', function () { + before(function () { AdsConsent = jet.require('packages/admob/lib/AdsConsent'); }); - describe('requestInfoUpdate', function() { - it('requests info update', async function() { + describe('requestInfoUpdate', function () { + it('requests info update', async function () { const info = await AdsConsent.requestInfoUpdate(['pub-4406399463942824']); info.status.should.Number(); info.isRequestLocationInEeaOrUnknown.should.be.Boolean(); }); }); - describe('showForm', function() { - it('throws if options is not valid', function() { + describe('showForm', function () { + it('throws if options is not valid', function () { try { AdsConsent.showForm('foo'); return Promise.reject(new Error('Did not throw Error.')); @@ -41,7 +41,7 @@ describe('admob() AdsConsent', function() { } }); - it('throws if privacy policy is not valid', function() { + it('throws if privacy policy is not valid', function () { try { AdsConsent.showForm({ privacyPolicy: 'www.invertase.io', @@ -53,7 +53,7 @@ describe('admob() AdsConsent', function() { } }); - it('throws if withPersonalizedAds is not a boolean', function() { + it('throws if withPersonalizedAds is not a boolean', function () { try { AdsConsent.showForm({ privacyPolicy: 'https://invertase.io', @@ -66,7 +66,7 @@ describe('admob() AdsConsent', function() { } }); - it('throws if withNonPersonalizedAds is not a boolean', function() { + it('throws if withNonPersonalizedAds is not a boolean', function () { try { AdsConsent.showForm({ privacyPolicy: 'https://invertase.io', @@ -79,7 +79,7 @@ describe('admob() AdsConsent', function() { } }); - it('throws if withAdFree is not a boolean', function() { + it('throws if withAdFree is not a boolean', function () { try { AdsConsent.showForm({ privacyPolicy: 'https://invertase.io', @@ -92,7 +92,7 @@ describe('admob() AdsConsent', function() { } }); - it('throws if all options are false', function() { + it('throws if all options are false', function () { try { AdsConsent.showForm({ privacyPolicy: 'https://invertase.io', @@ -107,8 +107,8 @@ describe('admob() AdsConsent', function() { // TODO test show form works? }); - describe('getAdProviders', function() { - it('returns a list of ad providers', async function() { + describe('getAdProviders', function () { + it('returns a list of ad providers', async function () { await AdsConsent.requestInfoUpdate(['pub-4406399463942824']); const providers = await AdsConsent.getAdProviders(); providers.should.be.Array(); @@ -122,8 +122,8 @@ describe('admob() AdsConsent', function() { }); }); - describe('setDebugGeography', function() { - it('throws if geography is invalid', function() { + describe('setDebugGeography', function () { + it('throws if geography is invalid', function () { try { AdsConsent.setDebugGeography(3); return Promise.reject(new Error('Did not throw Error.')); @@ -133,7 +133,7 @@ describe('admob() AdsConsent', function() { } }); - it('sets the geography', async function() { + it('sets the geography', async function () { await AdsConsent.setDebugGeography(0); const r1 = await AdsConsent.requestInfoUpdate(['pub-4406399463942824']); r1.isRequestLocationInEeaOrUnknown.should.eql(false); @@ -170,8 +170,8 @@ describe('admob() AdsConsent', function() { }); }); - describe('getStatus / setStatus', function() { - it('throws if status is invalid', function() { + describe('getStatus / setStatus', function () { + it('throws if status is invalid', function () { try { AdsConsent.setStatus(4); return Promise.reject(new Error('Did not throw Error.')); @@ -181,27 +181,27 @@ describe('admob() AdsConsent', function() { } }); - it('sets and gets unknown', async function() { + it('sets and gets unknown', async function () { await AdsConsent.setStatus(0); const s = await AdsConsent.getStatus(); s.should.eql(0); }); - it('sets and gets non-personalized', async function() { + it('sets and gets non-personalized', async function () { await AdsConsent.setStatus(1); const s = await AdsConsent.getStatus(); s.should.eql(1); }); - it('sets and gets personalized', async function() { + it('sets and gets personalized', async function () { await AdsConsent.setStatus(2); const s = await AdsConsent.getStatus(); s.should.eql(2); }); }); - describe('setTagForUnderAgeOfConsent', function() { - it('throws if value is not a boolean', function() { + describe('setTagForUnderAgeOfConsent', function () { + it('throws if value is not a boolean', function () { try { AdsConsent.setTagForUnderAgeOfConsent('true'); return Promise.reject(new Error('Did not throw Error.')); @@ -211,13 +211,13 @@ describe('admob() AdsConsent', function() { } }); - it('sets a value', async function() { + it('sets a value', async function () { await AdsConsent.setTagForUnderAgeOfConsent(false); }); }); - describe('addTestDevices', function() { - it('throws if value is not an array', function() { + describe('addTestDevices', function () { + it('throws if value is not an array', function () { try { AdsConsent.addTestDevices(12345); return Promise.reject(new Error('Did not throw Error.')); @@ -227,7 +227,7 @@ describe('admob() AdsConsent', function() { } }); - it('throws if deviceIds contains invalid value', function() { + it('throws if deviceIds contains invalid value', function () { try { AdsConsent.addTestDevices(['foo', 123]); return Promise.reject(new Error('Did not throw Error.')); @@ -237,7 +237,7 @@ describe('admob() AdsConsent', function() { } }); - it('sets device IDs', async function() { + it('sets device IDs', async function () { await AdsConsent.addTestDevices(['foo', 'bar']); }); }); diff --git a/packages/admob/e2e/interstitial.e2e.js b/packages/admob/e2e/interstitial.e2e.js index f43a3307d0..24e3dda7b8 100644 --- a/packages/admob/e2e/interstitial.e2e.js +++ b/packages/admob/e2e/interstitial.e2e.js @@ -17,15 +17,15 @@ let InterstitialAd; -describe('admob() InterstitialAd', function() { - before(function() { +describe('admob() InterstitialAd', function () { + before(function () { InterstitialAd = jet.require('packages/admob/lib/ads/InterstitialAd'); }); - describe('createForAdRequest', function() { + describe('createForAdRequest', function () { // has own tests - it('loads with requestOptions', async function() { + it('loads with requestOptions', async function () { const spy = sinon.spy(); const i = InterstitialAd.createForAdRequest(firebase.admob.TestIds.INTERSTITIAL, { @@ -50,8 +50,8 @@ describe('admob() InterstitialAd', function() { }); }); - describe('onAdEvent', function() { - it('unsubscribe should prevent events', async function() { + describe('onAdEvent', function () { + it('unsubscribe should prevent events', async function () { const spy = sinon.spy(); const i = InterstitialAd.createForAdRequest('abc'); const unsub = i.onAdEvent(spy); @@ -61,7 +61,7 @@ describe('admob() InterstitialAd', function() { spy.callCount.should.be.eql(0); }); - it('loads with a valid ad unit id', async function() { + it('loads with a valid ad unit id', async function () { const spy = sinon.spy(); const i = InterstitialAd.createForAdRequest(firebase.admob.TestIds.INTERSTITIAL); @@ -74,7 +74,7 @@ describe('admob() InterstitialAd', function() { spy.getCall(0).args[0].should.eql('loaded'); }); - it('errors with an invalid ad unit id', async function() { + it('errors with an invalid ad unit id', async function () { const spy = sinon.spy(); const i = InterstitialAd.createForAdRequest('123'); diff --git a/packages/admob/e2e/requestOptions.e2e.js b/packages/admob/e2e/requestOptions.e2e.js index 5059556698..26dcf7e3ae 100644 --- a/packages/admob/e2e/requestOptions.e2e.js +++ b/packages/admob/e2e/requestOptions.e2e.js @@ -17,17 +17,17 @@ let validator = null; -describe('admob() requestOptions', function() { - before(function() { +describe('admob() requestOptions', function () { + before(function () { validator = jet.require('packages/admob/lib/validateAdRequestOptions'); }); - it('returns an empty object is not defined', function() { + it('returns an empty object is not defined', function () { const v = validator(); v.should.eql(jet.contextify({})); }); - it('throws if options is not an object', function() { + it('throws if options is not an object', function () { try { validator('foo'); return Promise.reject(new Error('Did not throw Error.')); @@ -37,8 +37,8 @@ describe('admob() requestOptions', function() { } }); - describe('requestNonPersonalizedAdsOnly', function() { - it('throws if requestNonPersonalizedAdsOnly is not a boolean', function() { + describe('requestNonPersonalizedAdsOnly', function () { + it('throws if requestNonPersonalizedAdsOnly is not a boolean', function () { try { validator({ requestNonPersonalizedAdsOnly: 'true', @@ -52,7 +52,7 @@ describe('admob() requestOptions', function() { } }); - it('accepts requestNonPersonalizedAdsOnly boolean', function() { + it('accepts requestNonPersonalizedAdsOnly boolean', function () { const v = validator({ requestNonPersonalizedAdsOnly: false, }); @@ -60,8 +60,8 @@ describe('admob() requestOptions', function() { }); }); - describe('networkExtras', function() { - it('throws if networkExtras is not an object', function() { + describe('networkExtras', function () { + it('throws if networkExtras is not an object', function () { try { validator({ networkExtras: ['foo', 'bar'], @@ -75,7 +75,7 @@ describe('admob() requestOptions', function() { } }); - it('throws if networkExtras value is not a string', function() { + it('throws if networkExtras value is not a string', function () { try { validator({ networkExtras: { @@ -92,7 +92,7 @@ describe('admob() requestOptions', function() { } }); - it('accepts networkExtras object', function() { + it('accepts networkExtras object', function () { const v = validator({ networkExtras: { foo: 'bar', @@ -105,8 +105,8 @@ describe('admob() requestOptions', function() { }); }); - describe('keywords', function() { - it('throws if keywords is not an array', function() { + describe('keywords', function () { + it('throws if keywords is not an array', function () { try { validator({ keywords: { foo: 'bar' }, @@ -120,7 +120,7 @@ describe('admob() requestOptions', function() { } }); - it('throws if a keyword is not a string', function() { + it('throws if a keyword is not a string', function () { try { validator({ keywords: ['foo', 123], @@ -134,7 +134,7 @@ describe('admob() requestOptions', function() { } }); - it('accepts keywords array', function() { + it('accepts keywords array', function () { const v = validator({ keywords: ['foo', 'bar'], }); @@ -145,8 +145,8 @@ describe('admob() requestOptions', function() { }); }); - describe('testDevices', function() { - it('throws if testDevices is not an array', function() { + describe('testDevices', function () { + it('throws if testDevices is not an array', function () { try { validator({ testDevices: { foo: 'bar' }, @@ -160,7 +160,7 @@ describe('admob() requestOptions', function() { } }); - it('throws if a testDevices is not a string', function() { + it('throws if a testDevices is not a string', function () { try { validator({ testDevices: ['foo', 123], @@ -174,7 +174,7 @@ describe('admob() requestOptions', function() { } }); - it('accepts testDevices array', function() { + it('accepts testDevices array', function () { const v = validator({ testDevices: ['foo', 'bar'], }); @@ -185,8 +185,8 @@ describe('admob() requestOptions', function() { }); }); - describe('contentUrl', function() { - it('throws if contentUrl is not a string', function() { + describe('contentUrl', function () { + it('throws if contentUrl is not a string', function () { try { validator({ contentUrl: 123, @@ -198,7 +198,7 @@ describe('admob() requestOptions', function() { } }); - it('throws if contentUrl is not a valid url', function() { + it('throws if contentUrl is not a valid url', function () { try { validator({ contentUrl: 'www.invertase.io', @@ -210,7 +210,7 @@ describe('admob() requestOptions', function() { } }); - it('throws if contentUrl is too long', function() { + it('throws if contentUrl is too long', function () { let str = ''; for (let i = 0; i < 530; i++) { str += i.toString(); @@ -229,7 +229,7 @@ describe('admob() requestOptions', function() { } }); - it('accepts a contentUrl', function() { + it('accepts a contentUrl', function () { const v = validator({ contentUrl: 'http://invertase.io/privacy-policy', }); @@ -238,8 +238,8 @@ describe('admob() requestOptions', function() { }); }); - describe('location', function() { - it('throws if not an array', function() { + describe('location', function () { + it('throws if not an array', function () { try { validator({ location: 'United Kingdom', @@ -253,7 +253,7 @@ describe('admob() requestOptions', function() { } }); - it('throws if latitude not a number', function() { + it('throws if latitude not a number', function () { try { validator({ location: ['123', 123], @@ -267,7 +267,7 @@ describe('admob() requestOptions', function() { } }); - it('throws if latitude is invalid', function() { + it('throws if latitude is invalid', function () { try { validator({ location: [-100, 100], @@ -281,7 +281,7 @@ describe('admob() requestOptions', function() { } }); - it('throws if longitude not a number', function() { + it('throws if longitude not a number', function () { try { validator({ location: [10, '123'], @@ -295,7 +295,7 @@ describe('admob() requestOptions', function() { } }); - it('throws if longitude is invalid', function() { + it('throws if longitude is invalid', function () { try { validator({ location: [50, 200], @@ -309,7 +309,7 @@ describe('admob() requestOptions', function() { } }); - it('accepts a latitude and longitude', function() { + it('accepts a latitude and longitude', function () { const v = validator({ location: [10, 20], }); @@ -320,8 +320,8 @@ describe('admob() requestOptions', function() { }); }); - describe('locationAccuracy', function() { - it('throws if not a number', function() { + describe('locationAccuracy', function () { + it('throws if not a number', function () { try { validator({ locationAccuracy: '10', @@ -333,7 +333,7 @@ describe('admob() requestOptions', function() { } }); - it('throws if less than 0', function() { + it('throws if less than 0', function () { try { validator({ locationAccuracy: -1, @@ -345,21 +345,21 @@ describe('admob() requestOptions', function() { } }); - it('accepts locationAccuracy', function() { + it('accepts locationAccuracy', function () { const v = validator({ locationAccuracy: 10.5, }); v.locationAccuracy.should.eql(10.5); }); - it('uses a defaultValue', function() { + it('uses a defaultValue', function () { const v = validator({}); v.locationAccuracy.should.eql(5); }); }); - describe('requestAgent', function() { - it('throws if not a string', function() { + describe('requestAgent', function () { + it('throws if not a string', function () { try { validator({ requestAgent: 1, @@ -371,7 +371,7 @@ describe('admob() requestOptions', function() { } }); - it('accepts a requestAgent', function() { + it('accepts a requestAgent', function () { const v = validator({ requestAgent: 'CoolAds', }); @@ -379,8 +379,8 @@ describe('admob() requestOptions', function() { }); }); - describe('serverSideVerificationOptions', function() { - it('throws if userId is not a string', function() { + describe('serverSideVerificationOptions', function () { + it('throws if userId is not a string', function () { try { validator({ serverSideVerificationOptions: { @@ -396,7 +396,7 @@ describe('admob() requestOptions', function() { } }); - it('throws if customData is not a string', function() { + it('throws if customData is not a string', function () { try { validator({ serverSideVerificationOptions: { @@ -412,7 +412,7 @@ describe('admob() requestOptions', function() { } }); - it('accepts a serverSideVerificationOptions', function() { + it('accepts a serverSideVerificationOptions', function () { const v = validator({ serverSideVerificationOptions: { userId: '1', diff --git a/packages/admob/e2e/rewarded.e2e.js b/packages/admob/e2e/rewarded.e2e.js index 0fa088d8c2..b8cfa173e8 100644 --- a/packages/admob/e2e/rewarded.e2e.js +++ b/packages/admob/e2e/rewarded.e2e.js @@ -17,13 +17,13 @@ let RewardedAd; -describe('admob() RewardedAd', function() { - before(function() { +describe('admob() RewardedAd', function () { + before(function () { RewardedAd = jet.require('packages/admob/lib/ads/RewardedAd'); }); - describe('createForAdRequest', function() { - it('throws if adUnitId is invalid', function() { + describe('createForAdRequest', function () { + it('throws if adUnitId is invalid', function () { try { RewardedAd.createForAdRequest(123); return Promise.reject(new Error('Did not throw Error.')); @@ -34,7 +34,7 @@ describe('admob() RewardedAd', function() { }); // has own tests - it('throws if requestOptions are invalid', function() { + it('throws if requestOptions are invalid', function () { try { RewardedAd.createForAdRequest('123', 123); return Promise.reject(new Error('Did not throw Error.')); @@ -43,14 +43,14 @@ describe('admob() RewardedAd', function() { } }); - it('returns a new instance', function() { + it('returns a new instance', function () { const i = RewardedAd.createForAdRequest('abc'); i.constructor.name.should.eql('RewardedAd'); i.adUnitId.should.eql('abc'); i.loaded.should.eql(false); }); - it('loads with requestOptions', async function() { + it('loads with requestOptions', async function () { if (device.getPlatform() === 'ios') { // Flaky on local iOS return; @@ -79,8 +79,8 @@ describe('admob() RewardedAd', function() { }); }); - describe('show', function() { - it('throws if showing before loaded', function() { + describe('show', function () { + it('throws if showing before loaded', function () { const i = RewardedAd.createForAdRequest('abc'); try { @@ -95,8 +95,8 @@ describe('admob() RewardedAd', function() { }); }); - describe('onAdEvent', function() { - it('throws if handler is not a function', function() { + describe('onAdEvent', function () { + it('throws if handler is not a function', function () { const i = RewardedAd.createForAdRequest('abc'); try { @@ -108,14 +108,14 @@ describe('admob() RewardedAd', function() { } }); - it('returns an unsubscriber function', function() { + it('returns an unsubscriber function', function () { const i = RewardedAd.createForAdRequest('abc'); const unsub = i.onAdEvent(() => {}); unsub.should.be.Function(); unsub(); }); - it('unsubscribe should prevent events', async function() { + it('unsubscribe should prevent events', async function () { if (device.getPlatform() === 'ios') { // Flaky on local iOS return; @@ -129,7 +129,7 @@ describe('admob() RewardedAd', function() { spy.callCount.should.be.eql(0); }); - it('loads with a valid ad unit id', async function() { + it('loads with a valid ad unit id', async function () { if (device.getPlatform() === 'ios') { // Flaky on local iOS return; @@ -152,7 +152,7 @@ describe('admob() RewardedAd', function() { d.amount.should.be.Number(); }); - it('errors with an invalid ad unit id', async function() { + it('errors with an invalid ad unit id', async function () { const spy = sinon.spy(); const i = RewardedAd.createForAdRequest('123'); diff --git a/packages/admob/e2e/showOptions.e2e.js b/packages/admob/e2e/showOptions.e2e.js index ec069ca16c..5548d28b5f 100644 --- a/packages/admob/e2e/showOptions.e2e.js +++ b/packages/admob/e2e/showOptions.e2e.js @@ -17,17 +17,17 @@ let validator = null; -describe('admob() showOptions', function() { - before(function() { +describe('admob() showOptions', function () { + before(function () { validator = jet.require('packages/admob/lib/validateAdShowOptions'); }); - it('returns an empty object is not defined', function() { + it('returns an empty object is not defined', function () { const v = validator(); v.should.eql(jet.contextify({})); }); - it('throws if options is not an object', function() { + it('throws if options is not an object', function () { try { validator('foo'); return Promise.reject(new Error('Did not throw Error.')); @@ -37,7 +37,7 @@ describe('admob() showOptions', function() { } }); - it('throws if immersiveModeEnabled is not a boolean', function() { + it('throws if immersiveModeEnabled is not a boolean', function () { try { validator({ immersiveModeEnabled: 'true', @@ -49,7 +49,7 @@ describe('admob() showOptions', function() { } }); - it('sets immersiveMode', function() { + it('sets immersiveMode', function () { const v = validator({ immersiveModeEnabled: true, }); diff --git a/packages/admob/lib/index.d.ts b/packages/admob/lib/index.d.ts index 8ce4faeeb6..b56f9c801c 100644 --- a/packages/admob/lib/index.d.ts +++ b/packages/admob/lib/index.d.ts @@ -908,7 +908,7 @@ export namespace FirebaseAdMobTypes { * * @param listener A listener callback containing a event type, error and data. */ - onAdEvent(listener: AdEventListener): Function; + onAdEvent(listener: AdEventListener): () => void; /** * Show the loaded advert to the user. @@ -1134,27 +1134,27 @@ export namespace FirebaseAdMobTypes { /** * When an ad has finished loading. */ - onAdLoaded: Function; + onAdLoaded: () => void; /** * When an ad has failed to load. Callback contains an Error. */ - onAdFailedToLoad: Function; + onAdFailedToLoad: (error: Error) => void; /** * The ad is now visible to the user. */ - onAdOpened: Function; + onAdOpened: () => void; /** * Called when the user is about to return to the app after tapping on an ad. */ - onAdClosed: Function; + onAdClosed: () => void; /** * Called when the user has left the application (e.g. clicking an advert). */ - onAdLeftApplication: Function; + onAdLeftApplication: () => void; } /** @@ -1219,6 +1219,7 @@ export default defaultExport; * Attach namespace to `firebase.` and `FirebaseApp.`. */ declare module '@react-native-firebase/app' { + // eslint-disable-next-line @typescript-eslint/no-unused-vars namespace ReactNativeFirebase { import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp; diff --git a/packages/analytics/__tests__/analytics.test.ts b/packages/analytics/__tests__/analytics.test.ts index 8a288e7c9c..cc9f17e3c7 100644 --- a/packages/analytics/__tests__/analytics.test.ts +++ b/packages/analytics/__tests__/analytics.test.ts @@ -1,14 +1,14 @@ import { firebase } from '../lib'; -describe('Analytics', function() { - describe('namespace', function() { - it('accessible from firebase.app()', function() { +describe('Analytics', function () { + describe('namespace', function () { + it('accessible from firebase.app()', function () { const app = firebase.app(); expect(app.analytics).toBeDefined(); expect(app.analytics().app).toEqual(app); }); - it('throws if non default app arg provided to firebase.analytics(APP)', function() { + it('throws if non default app arg provided to firebase.analytics(APP)', function () { const app = firebase.app('secondaryFromNative'); const expectedError = [ @@ -21,7 +21,7 @@ describe('Analytics', function() { expect(() => firebase.analytics(app)).toThrowError(expectedError); }); - it('throws if analytics access from a non default app', function() { + it('throws if analytics access from a non default app', function () { const app = firebase.app('secondaryFromNative'); const expectedError = [ @@ -34,7 +34,7 @@ describe('Analytics', function() { }); // TODO in app/registry/namespace.js - if (!hasCustomUrlOrRegionSupport) - xit('throws if args provided to firebase.app().analytics(ARGS)', function() { + xit('throws if args provided to firebase.app().analytics(ARGS)', function () { try { // @ts-ignore test firebase.app().analytics('foo', 'arg2'); @@ -46,38 +46,38 @@ describe('Analytics', function() { }); }); - it('errors if milliseconds not a number', function() { + it('errors if milliseconds not a number', function () { // @ts-ignore test expect(() => firebase.analytics().setSessionTimeoutDuration('123')).toThrowError( "'milliseconds' expected a number value", ); }); - it('throws if none string none null values', function() { + it('throws if none string none null values', function () { // @ts-ignore test expect(() => firebase.analytics().setUserId(123)).toThrowError("'id' expected a string value"); }); - it('throws if name is not a string', function() { + it('throws if name is not a string', function () { // @ts-ignore test expect(() => firebase.analytics().setUserProperty(1337, 'invertase')).toThrowError( "'name' expected a string value", ); }); - it('throws if value is invalid', function() { + it('throws if value is invalid', function () { // @ts-ignore test expect(() => firebase.analytics().setUserProperty('invertase3', 33.3333)).toThrowError( "'value' expected a string value", ); }); - it('throws if properties is not an object', function() { + it('throws if properties is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().setUserProperties(1337)).toThrowError( "'properties' expected an object of key/value pairs", ); }); - it('throws if property value is invalid', function() { + it('throws if property value is invalid', function () { const props = { test: '123', foo: { @@ -89,48 +89,48 @@ describe('Analytics', function() { "'properties' value for parameter 'foo' is invalid", ); }); - it('throws if value is a number', function() { + it('throws if value is a number', function () { // @ts-ignore test expect(() => firebase.analytics().setUserProperties({ invertase1: 123 })).toThrowError( "'properties' value for parameter 'invertase1' is invalid, expected a string.", ); }); - it('errors when no parameters are set', function() { + it('errors when no parameters are set', function () { // @ts-ignore test expect(() => firebase.analytics().logSearch()).toThrowError( 'The supplied arg must be an object of key/values', ); }); - describe('logEvent()', function() { - it('errors if name is not a string', function() { + describe('logEvent()', function () { + it('errors if name is not a string', function () { // @ts-ignore test expect(() => firebase.analytics().logEvent(123)).toThrowError( "firebase.analytics().logEvent(*) 'name' expected a string value.", ); }); - it('errors if params is not an object', function() { + it('errors if params is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logEvent('invertase_event', 'foobar')).toThrowError( "firebase.analytics().logEvent(_, *) 'params' expected an object value.", ); }); - it('errors on using a reserved name', function() { + it('errors on using a reserved name', function () { expect(() => firebase.analytics().logEvent('session_start')).toThrowError( "firebase.analytics().logEvent(*) 'name' the event name 'session_start' is reserved and can not be used.", ); }); - it('errors if name not alphanumeric', function() { + it('errors if name not alphanumeric', function () { expect(() => firebase.analytics().logEvent('!@£$%^&*')).toThrowError( "firebase.analytics().logEvent(*) 'name' invalid event name '!@£$%^&*'. Names should contain 1 to 40 alphanumeric characters or underscores.", ); }); - it('errors if more than 25 params provided', function() { + it('errors if more than 25 params provided', function () { expect(() => firebase.analytics().logEvent('invertase', Object.assign({}, new Array(26).fill(1))), ).toThrowError( @@ -138,8 +138,8 @@ describe('Analytics', function() { ); }); - describe('logScreenView()', function() { - it('errors if param is not an object', function() { + describe('logScreenView()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logScreenView(123)).toThrowError( 'firebase.analytics().logScreenView(*):', @@ -147,14 +147,14 @@ describe('Analytics', function() { }); }); - describe('logAddPaymentInfo()', function() { - it('errors if param is not an object', function() { + describe('logAddPaymentInfo()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logAddPaymentInfo(123)).toThrowError( 'firebase.analytics().logAddPaymentInfo(*):', ); }); - it('errors when compound values are not set', function() { + it('errors when compound values are not set', function () { expect(() => firebase.analytics().logAddPaymentInfo({ value: 123, @@ -164,14 +164,14 @@ describe('Analytics', function() { }); }); - describe('logAddToCart()', function() { - it('errors if param is not an object', function() { + describe('logAddToCart()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logAddToCart(123)).toThrowError( 'firebase.analytics().logAddToCart(*):', ); }); - it('errors when compound values are not set', function() { + it('errors when compound values are not set', function () { expect(() => firebase.analytics().logAddToCart({ value: 123, @@ -180,14 +180,14 @@ describe('Analytics', function() { }); }); - describe('logAddShippingInfo()', function() { - it('errors if param is not an object', function() { + describe('logAddShippingInfo()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logAddShippingInfo(123)).toThrowError( 'firebase.analytics().logAddShippingInfo(*):', ); }); - it('errors when compound values are not set', function() { + it('errors when compound values are not set', function () { expect(() => firebase.analytics().logAddShippingInfo({ value: 123, @@ -196,14 +196,14 @@ describe('Analytics', function() { }); }); - describe('logAddToWishlist()', function() { - it('errors if param is not an object', function() { + describe('logAddToWishlist()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logAddToWishlist(123)).toThrowError( 'firebase.analytics().logAddToWishlist(*):', ); }); - it('errors when compound values are not set', function() { + it('errors when compound values are not set', function () { expect(() => firebase.analytics().logAddToWishlist({ value: 123, @@ -212,14 +212,14 @@ describe('Analytics', function() { }); }); - describe('logBeginCheckout()', function() { - it('errors if param is not an object', function() { + describe('logBeginCheckout()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logBeginCheckout(123)).toThrowError( 'firebase.analytics().logBeginCheckout(*):', ); }); - it('errors when compound values are not set', function() { + it('errors when compound values are not set', function () { expect(() => firebase.analytics().logBeginCheckout({ value: 123, @@ -228,14 +228,14 @@ describe('Analytics', function() { }); }); - describe('logGenerateLead()', function() { - it('errors if param is not an object', function() { + describe('logGenerateLead()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logGenerateLead(123)).toThrowError( 'firebase.analytics().logGenerateLead(*):', ); }); - it('errors when compound values are not set', function() { + it('errors when compound values are not set', function () { expect(() => firebase.analytics().logGenerateLead({ value: 123, @@ -244,8 +244,8 @@ describe('Analytics', function() { }); }); - describe('logCampaignDetails()', function() { - it('errors if param is not an object', function() { + describe('logCampaignDetails()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logCampaignDetails(123)).toThrowError( 'firebase.analytics().logCampaignDetails(*):', @@ -253,8 +253,8 @@ describe('Analytics', function() { }); }); - describe('logEarnVirtualCurrency()', function() { - it('errors if param is not an object', function() { + describe('logEarnVirtualCurrency()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logEarnVirtualCurrency(123)).toThrowError( 'firebase.analytics().logEarnVirtualCurrency(*):', @@ -262,8 +262,8 @@ describe('Analytics', function() { }); }); - describe('logJoinGroup()', function() { - it('errors if param is not an object', function() { + describe('logJoinGroup()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logJoinGroup(123)).toThrowError( 'firebase.analytics().logJoinGroup(*):', @@ -271,8 +271,8 @@ describe('Analytics', function() { }); }); - describe('logLevelEnd()', function() { - it('errors if param is not an object', function() { + describe('logLevelEnd()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logLevelEnd(123)).toThrowError( 'firebase.analytics().logLevelEnd(*):', @@ -280,8 +280,8 @@ describe('Analytics', function() { }); }); - describe('logLevelStart()', function() { - it('errors if param is not an object', function() { + describe('logLevelStart()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logLevelStart(123)).toThrowError( 'firebase.analytics().logLevelStart(*):', @@ -289,8 +289,8 @@ describe('Analytics', function() { }); }); - describe('logLevelUp()', function() { - it('errors if param is not an object', function() { + describe('logLevelUp()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logLevelUp(123)).toThrowError( 'firebase.analytics().logLevelUp(*):', @@ -298,8 +298,8 @@ describe('Analytics', function() { }); }); - describe('logLogin()', function() { - it('errors if param is not an object', function() { + describe('logLogin()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logLogin(123)).toThrowError( 'firebase.analytics().logLogin(*):', @@ -307,8 +307,8 @@ describe('Analytics', function() { }); }); - describe('logPostScore()', function() { - it('errors if param is not an object', function() { + describe('logPostScore()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logPostScore(123)).toThrowError( 'firebase.analytics().logPostScore(*):', @@ -316,8 +316,8 @@ describe('Analytics', function() { }); }); - describe('logSelectContent()', function() { - it('errors if param is not an object', function() { + describe('logSelectContent()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logSelectContent(123)).toThrowError( 'firebase.analytics().logSelectContent(*):', @@ -325,8 +325,8 @@ describe('Analytics', function() { }); }); - describe('logSearch()', function() { - it('errors if param is not an object', function() { + describe('logSearch()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logSearch(123)).toThrowError( 'firebase.analytics().logSearch(*):', @@ -334,8 +334,8 @@ describe('Analytics', function() { }); }); - describe('logSelectItem()', function() { - it('errors if param is not an object', function() { + describe('logSelectItem()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logSelectItem(123)).toThrowError( 'firebase.analytics().logSelectItem(*):', @@ -343,8 +343,8 @@ describe('Analytics', function() { }); }); - describe('logSetCheckoutOption()', function() { - it('errors if param is not an object', function() { + describe('logSetCheckoutOption()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logSetCheckoutOption(123)).toThrowError( 'firebase.analytics().logSetCheckoutOption(*):', @@ -352,8 +352,8 @@ describe('Analytics', function() { }); }); - describe('logShare()', function() { - it('errors if param is not an object', function() { + describe('logShare()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logShare(123)).toThrowError( 'firebase.analytics().logShare(*):', @@ -361,8 +361,8 @@ describe('Analytics', function() { }); }); - describe('logSignUp()', function() { - it('errors if param is not an object', function() { + describe('logSignUp()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logSignUp(123)).toThrowError( 'firebase.analytics().logSignUp(*):', @@ -370,8 +370,8 @@ describe('Analytics', function() { }); }); - describe('logSelectPromotion()', function() { - it('errors if param is not an object', function() { + describe('logSelectPromotion()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logSelectPromotion(123)).toThrowError( 'firebase.analytics().logSelectPromotion(*):', @@ -379,8 +379,8 @@ describe('Analytics', function() { }); }); - describe('logSpendVirtualCurrency()', function() { - it('errors if param is not an object', function() { + describe('logSpendVirtualCurrency()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logSpendVirtualCurrency(123)).toThrowError( 'firebase.analytics().logSpendVirtualCurrency(*):', @@ -388,8 +388,8 @@ describe('Analytics', function() { }); }); - describe('logUnlockAchievement()', function() { - it('errors if param is not an object', function() { + describe('logUnlockAchievement()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logUnlockAchievement(123)).toThrowError( 'firebase.analytics().logUnlockAchievement(*):', @@ -397,14 +397,14 @@ describe('Analytics', function() { }); }); - describe('logPurchase()', function() { - it('errors if param is not an object', function() { + describe('logPurchase()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logPurchase(123)).toThrowError( 'firebase.analytics().logPurchase(*):', ); }); - it('errors when compound values are not set', function() { + it('errors when compound values are not set', function () { expect(() => firebase.analytics().logPurchase({ value: 123, @@ -413,15 +413,15 @@ describe('Analytics', function() { }); }); - describe('logRefund()', function() { - it('errors if param is not an object', function() { + describe('logRefund()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logRefund(123)).toThrowError( 'firebase.analytics().logRefund(*):', ); }); - it('errors when compound values are not set', function() { + it('errors when compound values are not set', function () { expect(() => firebase.analytics().logRefund({ value: 123, @@ -430,14 +430,14 @@ describe('Analytics', function() { }); }); - describe('logViewCart()', function() { - it('errors if param is not an object', function() { + describe('logViewCart()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logViewCart(123)).toThrowError( 'firebase.analytics().logViewCart(*):', ); }); - it('errors when compound values are not set', function() { + it('errors when compound values are not set', function () { expect(() => firebase.analytics().logViewCart({ value: 123, @@ -446,14 +446,14 @@ describe('Analytics', function() { }); }); - describe('logViewItem()', function() { - it('errors if param is not an object', function() { + describe('logViewItem()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logViewItem(123)).toThrowError( 'firebase.analytics().logViewItem(*):', ); }); - it('errors when compound values are not set', function() { + it('errors when compound values are not set', function () { expect(() => firebase.analytics().logViewItem({ value: 123, @@ -462,8 +462,8 @@ describe('Analytics', function() { }); }); - describe('logViewItemList()', function() { - it('errors if param is not an object', function() { + describe('logViewItemList()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logViewItemList(123)).toThrowError( 'firebase.analytics().logViewItemList(*):', @@ -471,14 +471,14 @@ describe('Analytics', function() { }); }); - describe('logRemoveFromCart()', function() { - it('errors if param is not an object', function() { + describe('logRemoveFromCart()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logRemoveFromCart(123)).toThrowError( 'firebase.analytics().logRemoveFromCart(*):', ); }); - it('errors when compound values are not set', function() { + it('errors when compound values are not set', function () { expect(() => firebase.analytics().logRemoveFromCart({ value: 123, @@ -487,8 +487,8 @@ describe('Analytics', function() { }); }); - describe('logViewPromotion()', function() { - it('errors if param is not an object', function() { + describe('logViewPromotion()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logViewPromotion(123)).toThrowError( 'firebase.analytics().logViewPromotion(*):', @@ -496,8 +496,8 @@ describe('Analytics', function() { }); }); - describe('logViewSearchResults()', function() { - it('errors if param is not an object', function() { + describe('logViewSearchResults()', function () { + it('errors if param is not an object', function () { // @ts-ignore test expect(() => firebase.analytics().logViewSearchResults(123)).toThrowError( 'firebase.analytics().logViewSearchResults(*):', @@ -505,8 +505,8 @@ describe('Analytics', function() { }); }); - describe('setAnalyticsCollectionEnabled()', function() { - it('throws if not a boolean', function() { + describe('setAnalyticsCollectionEnabled()', function () { + it('throws if not a boolean', function () { // @ts-ignore expect(() => firebase.analytics().setAnalyticsCollectionEnabled('foo')).toThrowError( "firebase.analytics().setAnalyticsCollectionEnabled(*) 'enabled' expected a boolean value.", diff --git a/packages/analytics/e2e/analytics.e2e.js b/packages/analytics/e2e/analytics.e2e.js index 190e630859..bfbb3f7f1b 100644 --- a/packages/analytics/e2e/analytics.e2e.js +++ b/packages/analytics/e2e/analytics.e2e.js @@ -15,15 +15,15 @@ * */ -describe('analytics()', function() { - describe('namespace', function() {}); +describe('analytics()', function () { + describe('namespace', function () {}); - describe('logEvent()', function() { - it('log an event without parameters', async function() { + describe('logEvent()', function () { + it('log an event without parameters', async function () { await firebase.analytics().logEvent('invertase_event'); }); - it('log an event with parameters', async function() { + it('log an event with parameters', async function () { await firebase.analytics().logEvent('invertase_event', { boolean: true, number: 1, @@ -32,72 +32,72 @@ describe('analytics()', function() { }); }); - describe('setAnalyticsCollectionEnabled()', function() { - it('true', async function() { + describe('setAnalyticsCollectionEnabled()', function () { + it('true', async function () { await firebase.analytics().setAnalyticsCollectionEnabled(true); }); - it('false', async function() { + it('false', async function () { await firebase.analytics().setAnalyticsCollectionEnabled(false); }); }); - describe('resetAnalyticsData()', function() { - it('calls native fn without error', async function() { + describe('resetAnalyticsData()', function () { + it('calls native fn without error', async function () { await firebase.analytics().resetAnalyticsData(); }); }); - describe('setSessionTimeoutDuration()', function() { - it('default duration', async function() { + describe('setSessionTimeoutDuration()', function () { + it('default duration', async function () { await firebase.analytics().setSessionTimeoutDuration(); }); - it('custom duration', async function() { + it('custom duration', async function () { await firebase.analytics().setSessionTimeoutDuration(13371337); }); }); - describe('setUserId()', function() { - it('allows a null values to be set', async function() { + describe('setUserId()', function () { + it('allows a null values to be set', async function () { await firebase.analytics().setUserId(null); }); - it('accepts string values', async function() { + it('accepts string values', async function () { await firebase.analytics().setUserId('rn-firebase'); }); }); - describe('setUserProperty()', function() { - it('allows a null values to be set', async function() { + describe('setUserProperty()', function () { + it('allows a null values to be set', async function () { await firebase.analytics().setUserProperty('invertase', null); }); - it('accepts string values', async function() { + it('accepts string values', async function () { await firebase.analytics().setUserProperty('invertase2', 'rn-firebase'); }); }); - describe('setUserProperties()', function() { - it('allows null values to be set', async function() { + describe('setUserProperties()', function () { + it('allows null values to be set', async function () { await firebase.analytics().setUserProperties({ invertase2: null }); }); - it('accepts string values', async function() { + it('accepts string values', async function () { await firebase.analytics().setUserProperties({ invertase3: 'rn-firebase' }); }); }); - describe('logScreenView()', function() { - it('calls logScreenView', async function() { + describe('logScreenView()', function () { + it('calls logScreenView', async function () { await firebase .analytics() .logScreenView({ screen_name: 'invertase screen', screen_class: 'invertase class' }); }); }); - describe('logAddPaymentInfo()', function() { - it('calls logAddPaymentInfo', async function() { + describe('logAddPaymentInfo()', function () { + it('calls logAddPaymentInfo', async function () { await firebase.analytics().logAddPaymentInfo({ value: 123, currency: 'USD', @@ -106,8 +106,8 @@ describe('analytics()', function() { }); }); - describe('logAddToCart()', function() { - it('calls logAddToCart', async function() { + describe('logAddToCart()', function () { + it('calls logAddToCart', async function () { await firebase.analytics().logAddToCart({ value: 123, currency: 'GBP', @@ -115,8 +115,8 @@ describe('analytics()', function() { }); }); - describe('logAddShippingInfo()', function() { - it('calls logAddShippingInfo', async function() { + describe('logAddShippingInfo()', function () { + it('calls logAddShippingInfo', async function () { await firebase.analytics().logAddShippingInfo({ value: 123, currency: 'GBP', @@ -124,8 +124,8 @@ describe('analytics()', function() { }); }); - describe('logAddToWishlist()', function() { - it('calls logAddToWishlist', async function() { + describe('logAddToWishlist()', function () { + it('calls logAddToWishlist', async function () { await firebase.analytics().logAddToWishlist({ items: [ { @@ -142,20 +142,20 @@ describe('analytics()', function() { }); }); - describe('logAppOpen()', function() { - it('calls logAppOpen', async function() { + describe('logAppOpen()', function () { + it('calls logAppOpen', async function () { await firebase.analytics().logAppOpen(); }); }); - describe('logBeginCheckout()', function() { - it('calls logBeginCheckout', async function() { + describe('logBeginCheckout()', function () { + it('calls logBeginCheckout', async function () { await firebase.analytics().logBeginCheckout(); }); }); - describe('logCampaignDetails()', function() { - it('calls logCampaignDetails', async function() { + describe('logCampaignDetails()', function () { + it('calls logCampaignDetails', async function () { await firebase.analytics().logCampaignDetails({ source: 'foo', medium: 'bar', @@ -164,8 +164,8 @@ describe('analytics()', function() { }); }); - describe('logEarnVirtualCurrency()', function() { - it('calls logEarnVirtualCurrency', async function() { + describe('logEarnVirtualCurrency()', function () { + it('calls logEarnVirtualCurrency', async function () { await firebase.analytics().logEarnVirtualCurrency({ virtual_currency_name: 'foo', value: 123, @@ -173,8 +173,8 @@ describe('analytics()', function() { }); }); - describe('logPurchase()', function() { - it('calls logPurchase', async function() { + describe('logPurchase()', function () { + it('calls logPurchase', async function () { await firebase.analytics().logPurchase({ currency: 'USD', value: 123, @@ -183,8 +183,8 @@ describe('analytics()', function() { }); }); - describe('logViewPromotion()', function() { - it('calls logViewPromotion', async function() { + describe('logViewPromotion()', function () { + it('calls logViewPromotion', async function () { await firebase.analytics().logViewPromotion({ creative_name: 'creative_name', creative_slot: 'creative_slot', @@ -192,8 +192,8 @@ describe('analytics()', function() { }); }); - describe('logGenerateLead()', function() { - it('calls logGenerateLead', async function() { + describe('logGenerateLead()', function () { + it('calls logGenerateLead', async function () { await firebase.analytics().logGenerateLead({ currency: 'USD', value: 123, @@ -201,16 +201,16 @@ describe('analytics()', function() { }); }); - describe('logJoinGroup()', function() { - it('calls logJoinGroup', async function() { + describe('logJoinGroup()', function () { + it('calls logJoinGroup', async function () { await firebase.analytics().logJoinGroup({ group_id: '123', }); }); }); - describe('logLevelEnd()', function() { - it('calls logLevelEnd', async function() { + describe('logLevelEnd()', function () { + it('calls logLevelEnd', async function () { await firebase.analytics().logLevelEnd({ level: 123, success: 'yes', @@ -218,16 +218,16 @@ describe('analytics()', function() { }); }); - describe('logLevelStart()', function() { - it('calls logLevelEnd', async function() { + describe('logLevelStart()', function () { + it('calls logLevelEnd', async function () { await firebase.analytics().logLevelStart({ level: 123, }); }); }); - describe('logLevelUp()', function() { - it('calls logLevelUp', async function() { + describe('logLevelUp()', function () { + it('calls logLevelUp', async function () { await firebase.analytics().logLevelUp({ level: 123, character: 'foo', @@ -235,24 +235,24 @@ describe('analytics()', function() { }); }); - describe('logLogin()', function() { - it('calls logLogin', async function() { + describe('logLogin()', function () { + it('calls logLogin', async function () { await firebase.analytics().logLogin({ method: 'facebook.com', }); }); }); - describe('logPostScore()', function() { - it('calls logPostScore', async function() { + describe('logPostScore()', function () { + it('calls logPostScore', async function () { await firebase.analytics().logPostScore({ score: 123, }); }); }); - describe('logRemoveFromCart()', function() { - it('calls logRemoveFromCart', async function() { + describe('logRemoveFromCart()', function () { + it('calls logRemoveFromCart', async function () { await firebase.analytics().logRemoveFromCart({ value: 123, currency: 'USD', @@ -260,16 +260,16 @@ describe('analytics()', function() { }); }); - describe('logSearch()', function() { - it('calls logSearch', async function() { + describe('logSearch()', function () { + it('calls logSearch', async function () { await firebase.analytics().logSearch({ search_term: 'foo', }); }); }); - describe('logSetCheckoutOption()', function() { - it('calls logSelectContent', async function() { + describe('logSetCheckoutOption()', function () { + it('calls logSelectContent', async function () { await firebase.analytics().logSetCheckoutOption({ checkout_step: 123, checkout_option: 'foo', @@ -277,8 +277,8 @@ describe('analytics()', function() { }); }); - describe('logSelectItem()', function() { - it('calls logSelectItem', async function() { + describe('logSelectItem()', function () { + it('calls logSelectItem', async function () { await firebase.analytics().logSelectItem({ item_list_id: 'foo', item_list_name: 'foo', @@ -287,8 +287,8 @@ describe('analytics()', function() { }); }); - describe('logShare()', function() { - it('calls logShare', async function() { + describe('logShare()', function () { + it('calls logShare', async function () { await firebase.analytics().logShare({ content_type: 'foo', item_id: 'foo', @@ -297,16 +297,16 @@ describe('analytics()', function() { }); }); - describe('logSignUp()', function() { - it('calls logSignUp', async function() { + describe('logSignUp()', function () { + it('calls logSignUp', async function () { await firebase.analytics().logSignUp({ method: 'facebook.com', }); }); }); - describe('logSpendVirtualCurrency()', function() { - it('calls logSpendVirtualCurrency', async function() { + describe('logSpendVirtualCurrency()', function () { + it('calls logSpendVirtualCurrency', async function () { await firebase.analytics().logSpendVirtualCurrency({ item_name: 'foo', virtual_currency_name: 'foo', @@ -315,34 +315,34 @@ describe('analytics()', function() { }); }); - describe('logTutorialBegin()', function() { - it('calls logTutorialBegin', async function() { + describe('logTutorialBegin()', function () { + it('calls logTutorialBegin', async function () { await firebase.analytics().logTutorialBegin(); }); }); - describe('logTutorialComplete()', function() { - it('calls logTutorialComplete', async function() { + describe('logTutorialComplete()', function () { + it('calls logTutorialComplete', async function () { await firebase.analytics().logTutorialComplete(); }); }); - describe('logUnlockAchievement()', function() { - it('calls logUnlockAchievement', async function() { + describe('logUnlockAchievement()', function () { + it('calls logUnlockAchievement', async function () { await firebase.analytics().logUnlockAchievement({ achievement_id: 'foo', }); }); }); - describe('logViewCart()', function() { - it('calls logViewCart', async function() { + describe('logViewCart()', function () { + it('calls logViewCart', async function () { await firebase.analytics().logViewCart(); }); }); - describe('logViewItem()', function() { - it('calls logViewItem', async function() { + describe('logViewItem()', function () { + it('calls logViewItem', async function () { await firebase.analytics().logViewItem({ items: [ { @@ -358,16 +358,16 @@ describe('analytics()', function() { }); }); - describe('logViewItemList()', function() { - it('calls logViewItemList', async function() { + describe('logViewItemList()', function () { + it('calls logViewItemList', async function () { await firebase.analytics().logViewItemList({ item_list_name: 'foo', }); }); }); - describe('logRefund()', function() { - it('calls logRefund', async function() { + describe('logRefund()', function () { + it('calls logRefund', async function () { await firebase.analytics().logRefund({ affiliation: 'affiliation', coupon: 'coupon', @@ -375,8 +375,8 @@ describe('analytics()', function() { }); }); - describe('logSelectContent()', function() { - it('calls logSelectContent', async function() { + describe('logSelectContent()', function () { + it('calls logSelectContent', async function () { await firebase.analytics().logSelectContent({ content_type: 'clothing', item_id: 'abcd', @@ -384,8 +384,8 @@ describe('analytics()', function() { }); }); - describe('logSelectPromotion()', function() { - it('calls logSelectPromotion', async function() { + describe('logSelectPromotion()', function () { + it('calls logSelectPromotion', async function () { await firebase.analytics().logSelectPromotion({ creative_name: 'string', creative_slot: 'string', @@ -396,8 +396,8 @@ describe('analytics()', function() { }); }); - describe('logViewSearchResults()', function() { - it('calls logViewSearchResults', async function() { + describe('logViewSearchResults()', function () { + it('calls logViewSearchResults', async function () { await firebase.analytics().logViewSearchResults({ search_term: 'promotion', }); diff --git a/packages/analytics/lib/index.d.ts b/packages/analytics/lib/index.d.ts index d5bd288865..79eaab790b 100644 --- a/packages/analytics/lib/index.d.ts +++ b/packages/analytics/lib/index.d.ts @@ -1470,6 +1470,7 @@ export default defaultExport; * Attach namespace to `firebase.` and `FirebaseApp.`. */ declare module '@react-native-firebase/app' { + // eslint-disable-next-line @typescript-eslint/no-unused-vars namespace ReactNativeFirebase { import FirebaseModuleWithStatics = ReactNativeFirebase.FirebaseModuleWithStatics; interface Module { diff --git a/packages/app/e2e/app.constants.e2e.js b/packages/app/e2e/app.constants.e2e.js index b01b32b26c..492dca39ad 100644 --- a/packages/app/e2e/app.constants.e2e.js +++ b/packages/app/e2e/app.constants.e2e.js @@ -15,9 +15,9 @@ * */ -describe('App -> NativeModules -> Constants', function() { - describe('.apps', function() { - it('should be an array', function() { +describe('App -> NativeModules -> Constants', function () { + describe('.apps', function () { + it('should be an array', function () { const { NATIVE_FIREBASE_APPS } = NativeModules.RNFBAppModule; NATIVE_FIREBASE_APPS.should.be.an.Array(); @@ -25,7 +25,7 @@ describe('App -> NativeModules -> Constants', function() { NATIVE_FIREBASE_APPS.length.should.equal(2); }); - it('array items contain name, options & state properties', function() { + it('array items contain name, options & state properties', function () { const { NATIVE_FIREBASE_APPS } = NativeModules.RNFBAppModule; NATIVE_FIREBASE_APPS.should.be.an.Array(); diff --git a/packages/app/e2e/app.e2e.js b/packages/app/e2e/app.e2e.js index 55cddf0347..f3a78430f5 100644 --- a/packages/app/e2e/app.e2e.js +++ b/packages/app/e2e/app.e2e.js @@ -15,19 +15,19 @@ * */ -describe('firebase', function() { - it('it should allow read the default app from native', function() { +describe('firebase', function () { + it('it should allow read the default app from native', function () { // app is created in tests app before all hook should.equal(firebase.app()._nativeInitialized, true); should.equal(firebase.app().name, '[DEFAULT]'); }); - it('it should create js apps for natively initialized apps', function() { + it('it should create js apps for natively initialized apps', function () { should.equal(firebase.app('secondaryFromNative')._nativeInitialized, true); should.equal(firebase.app('secondaryFromNative').name, 'secondaryFromNative'); }); - it('natively initialized apps should have options available in js', function() { + it('natively initialized apps should have options available in js', function () { const platformAppConfig = FirebaseHelpers.app.config(); should.equal(firebase.app().options.apiKey, platformAppConfig.apiKey); should.equal(firebase.app().options.appId, platformAppConfig.appId); @@ -37,7 +37,7 @@ describe('firebase', function() { should.equal(firebase.app().options.storageBucket, platformAppConfig.storageBucket); }); - xit('it should initialize dynamic apps', function() { + xit('it should initialize dynamic apps', function () { const name = `testscoreapp${FirebaseHelpers.id}`; const platformAppConfig = FirebaseHelpers.app.config(); return firebase.initializeApp(platformAppConfig, name).then(newApp => { @@ -48,25 +48,25 @@ describe('firebase', function() { }); }); - it('SDK_VERSION should return a string version', function() { + it('SDK_VERSION should return a string version', function () { firebase.SDK_VERSION.should.be.a.String(); }); }); // eslint-disable-next-line mocha/max-top-level-suites -describe('firebase -> X', function() { - it('apps should provide an array of apps', function() { +describe('firebase -> X', function () { + it('apps should provide an array of apps', function () { should.equal(!!firebase.apps.length, true); should.equal(firebase.apps.includes(firebase.app('[DEFAULT]')), true); return Promise.resolve(); }); - it('apps can get and set data collection', async function() { + it('apps can get and set data collection', async function () { firebase.app().automaticDataCollectionEnabled = false; should.equal(firebase.app().automaticDataCollectionEnabled, false); }); - xit('apps can be deleted', async function() { + xit('apps can be deleted', async function () { const name = `testscoreapp${FirebaseHelpers.id}`; const platformAppConfig = FirebaseHelpers.app.config(); const newApp = await firebase.initializeApp(platformAppConfig, name); @@ -86,14 +86,14 @@ describe('firebase -> X', function() { }).should.throw(`No Firebase App '${name}' has been created - call firebase.initializeApp()`); }); - xit('prevents the default app from being deleted', async function() { + xit('prevents the default app from being deleted', async function () { firebase .app() .delete() .should.be.rejectedWith('Unable to delete the default native firebase app instance.'); }); - it('extendApp should provide additional functionality', function() { + it('extendApp should provide additional functionality', function () { const extension = {}; firebase.app().extendApp({ extension, diff --git a/packages/app/e2e/config.e2e.js b/packages/app/e2e/config.e2e.js index d7e070ecf0..36b6df729d 100644 --- a/packages/app/e2e/config.e2e.js +++ b/packages/app/e2e/config.e2e.js @@ -15,9 +15,9 @@ * */ -describe('config', function() { - describe('meta', function() { - it('should read Info.plist/AndroidManifest.xml meta data', async function() { +describe('config', function () { + describe('meta', function () { + it('should read Info.plist/AndroidManifest.xml meta data', async function () { const metaData = await NativeModules.RNFBAppModule.metaGetAll(); metaData.rnfirebase_meta_testing_string.should.equal('abc'); metaData.rnfirebase_meta_testing_boolean_false.should.equal(false); @@ -25,8 +25,8 @@ describe('config', function() { }); }); - describe('json', function() { - xit('should read firebase.json data', async function() { + describe('json', function () { + xit('should read firebase.json data', async function () { const jsonData = await NativeModules.RNFBAppModule.jsonGetAll(); jsonData.rnfirebase_json_testing_string.should.equal('abc'); jsonData.rnfirebase_json_testing_boolean_false.should.equal(false); @@ -34,19 +34,19 @@ describe('config', function() { }); }); - describe('prefs', function() { - beforeEach(async function() { + describe('prefs', function () { + beforeEach(async function () { await NativeModules.RNFBAppModule.preferencesClearAll(); }); // NOTE: "preferencesClearAll" clears Firestore settings. Set DB as emulator again. - after(async function() { + after(async function () { await firebase .firestore() .settings({ host: 'localhost:8080', ssl: false, persistence: true }); }); - it('should set bool values', async function() { + it('should set bool values', async function () { const prefsBefore = await NativeModules.RNFBAppModule.preferencesGetAll(); should.equal(prefsBefore.invertase_oss, undefined); await NativeModules.RNFBAppModule.preferencesSetBool('invertase_oss', true); @@ -54,7 +54,7 @@ describe('config', function() { prefsAfter.invertase_oss.should.equal(true); }); - it('should set string values', async function() { + it('should set string values', async function () { const prefsBefore = await NativeModules.RNFBAppModule.preferencesGetAll(); should.equal(prefsBefore.invertase_oss, undefined); await NativeModules.RNFBAppModule.preferencesSetString('invertase_oss', 'invertase.io'); @@ -62,7 +62,7 @@ describe('config', function() { prefsAfter.invertase_oss.should.equal('invertase.io'); }); - it('should clear all values', async function() { + it('should clear all values', async function () { await NativeModules.RNFBAppModule.preferencesSetString('invertase_oss', 'invertase.io'); const prefsBefore = await NativeModules.RNFBAppModule.preferencesGetAll(); prefsBefore.invertase_oss.should.equal('invertase.io'); diff --git a/packages/app/e2e/events.e2e.js b/packages/app/e2e/events.e2e.js index 569761909c..e92696d9a7 100644 --- a/packages/app/e2e/events.e2e.js +++ b/packages/app/e2e/events.e2e.js @@ -21,9 +21,9 @@ const eventBody = { foo: 'bar', }; -describe('Core -> EventEmitter', function() { - describe('ReactNativeFirebaseEventEmitter', function() { - it('queues events before app is ready', async function() { +describe('Core -> EventEmitter', function () { + describe('ReactNativeFirebaseEventEmitter', function () { + it('queues events before app is ready', async function () { const { eventsPing, eventsNotifyReady, eventsGetListeners } = NativeModules.RNFBAppModule; await eventsNotifyReady(false); @@ -57,7 +57,7 @@ describe('Core -> EventEmitter', function() { should.equal(nativeListenersAfter.events.pong, undefined); }); - it('queues events before a js listener is registered', async function() { + it('queues events before a js listener is registered', async function () { const { eventsPing, eventsNotifyReady, diff --git a/packages/app/e2e/utils.e2e.js b/packages/app/e2e/utils.e2e.js index a4ce67647c..3e08b94b16 100644 --- a/packages/app/e2e/utils.e2e.js +++ b/packages/app/e2e/utils.e2e.js @@ -15,23 +15,23 @@ * */ -describe('utils()', function() { - describe('namespace', function() { - it('accessible from firebase.app()', function() { +describe('utils()', function () { + describe('namespace', function () { + it('accessible from firebase.app()', function () { const app = firebase.app(); should.exist(app.utils); app.utils().app.should.equal(app); }); }); - describe('isRunningInTestLab', function() { - it('returns true or false', function() { + describe('isRunningInTestLab', function () { + it('returns true or false', function () { should.equal(firebase.utils().isRunningInTestLab, false); }); }); - describe('playServicesAvailability', function() { - it('returns isAvailable and Play Service status', async function() { + describe('playServicesAvailability', function () { + it('returns isAvailable and Play Service status', async function () { const playService = await firebase.utils().playServicesAvailability; //iOS always returns { isAvailable: true, status: 0} should(playService.isAvailable).equal(true); @@ -39,8 +39,8 @@ describe('utils()', function() { }); }); - describe('getPlayServicesStatus', function() { - it('returns isAvailable and Play Service status', async function() { + describe('getPlayServicesStatus', function () { + it('returns isAvailable and Play Service status', async function () { const status = await firebase.utils().getPlayServicesStatus(); //iOS always returns { isAvailable: true, status: 0} should(status.isAvailable).equal(true); diff --git a/packages/app/e2e/utilsStatics.e2e.js b/packages/app/e2e/utilsStatics.e2e.js index 65c83bd616..10f80c6fa6 100644 --- a/packages/app/e2e/utilsStatics.e2e.js +++ b/packages/app/e2e/utilsStatics.e2e.js @@ -15,9 +15,9 @@ * */ -describe('utils()', function() { - describe('statics', function() { - it('provides native path strings', function() { +describe('utils()', function () { + describe('statics', function () { + it('provides native path strings', function () { firebase.utils.FilePath.should.be.an.Object(); if (device.getPlatform() === 'ios') { firebase.utils.FilePath.MAIN_BUNDLE.should.be.a.String(); diff --git a/packages/app/lib/index.d.ts b/packages/app/lib/index.d.ts index 65268532dc..1510aba04d 100644 --- a/packages/app/lib/index.d.ts +++ b/packages/app/lib/index.d.ts @@ -220,6 +220,7 @@ export namespace ReactNativeFirebase { private emitter: any; } + // eslint-disable-next-line @typescript-eslint/ban-types export type FirebaseModuleWithStatics = { (): M; @@ -229,6 +230,7 @@ export namespace ReactNativeFirebase { readonly SDK_VERSION: string; } & S; + // eslint-disable-next-line @typescript-eslint/ban-types export type FirebaseModuleWithStaticsAndApp = { (app?: FirebaseApp): M; diff --git a/packages/auth/__tests__/auth.test.ts b/packages/auth/__tests__/auth.test.ts index a1b94bb68e..e86e88e500 100644 --- a/packages/auth/__tests__/auth.test.ts +++ b/packages/auth/__tests__/auth.test.ts @@ -1,16 +1,16 @@ import auth, { firebase } from '../lib'; -describe('Auth', function() { - describe('namespace', function() { - it('accessible from firebase.app()', function() { +describe('Auth', function () { + describe('namespace', function () { + it('accessible from firebase.app()', function () { const app = firebase.app(); expect(app.auth).toBeDefined(); expect(app.auth().useEmulator).toBeDefined(); }); }); - describe('useEmulator()', function() { - it('useEmulator requires a string url', function() { + describe('useEmulator()', function () { + it('useEmulator requires a string url', function () { // @ts-ignore because we pass an invalid argument... expect(() => auth().useEmulator()).toThrow( 'firebase.auth().useEmulator() takes a non-empty string', @@ -24,7 +24,7 @@ describe('Auth', function() { ); }); - it('useEmulator requires a well-formed url', function() { + it('useEmulator requires a well-formed url', function () { // No http:// expect(() => auth().useEmulator('localhost:9099')).toThrow( 'firebase.auth().useEmulator() unable to parse host and port from url', @@ -35,7 +35,7 @@ describe('Auth', function() { ); }); - it('useEmulator -> remaps Android loopback to host', function() { + it('useEmulator -> remaps Android loopback to host', function () { const foo = auth().useEmulator('http://localhost:9099'); expect(foo).toEqual(['10.0.2.2', 9099]); diff --git a/packages/auth/e2e/auth.e2e.js b/packages/auth/e2e/auth.e2e.js index 181aad9e90..5fea94c806 100644 --- a/packages/auth/e2e/auth.e2e.js +++ b/packages/auth/e2e/auth.e2e.js @@ -23,8 +23,8 @@ const DISABLED_PASS = 'test1234'; const { clearAllUsers, disableUser, getLastOob, resetPassword } = require('./helpers'); -describe('auth()', function() { - before(async function() { +describe('auth()', function () { + before(async function () { await clearAllUsers(); await firebase.auth().createUserWithEmailAndPassword(TEST_EMAIL, TEST_PASS); const disabledUserCredential = await firebase @@ -33,44 +33,41 @@ describe('auth()', function() { await disableUser(disabledUserCredential.user.uid); }); - beforeEach(async function() { + beforeEach(async function () { if (firebase.auth().currentUser) { await firebase.auth().signOut(); await Utils.sleep(50); } }); - describe('namespace', function() { - it('accessible from firebase.app()', function() { + describe('namespace', function () { + it('accessible from firebase.app()', function () { const app = firebase.app(); should.exist(app.auth); app.auth().app.should.equal(app); }); // removing as pending if module.options.hasMultiAppSupport = true - it('supports multiple apps', async function() { + it('supports multiple apps', async function () { firebase.auth().app.name.should.equal('[DEFAULT]'); firebase .auth(firebase.app('secondaryFromNative')) .app.name.should.equal('secondaryFromNative'); - firebase - .app('secondaryFromNative') - .auth() - .app.name.should.equal('secondaryFromNative'); + firebase.app('secondaryFromNative').auth().app.name.should.equal('secondaryFromNative'); }); }); - describe('applyActionCode()', function() { + describe('applyActionCode()', function () { // Needs a different setup to work against the auth emulator - xit('works as expected', async function() { + xit('works as expected', async function () { await firebase .auth() .applyActionCode('fooby shooby dooby') .then($ => $); }); - it('errors on invalid code', async function() { + it('errors on invalid code', async function () { try { await firebase .auth() @@ -82,8 +79,8 @@ describe('auth()', function() { }); }); - describe('checkActionCode()', function() { - it('errors on invalid code', async function() { + describe('checkActionCode()', function () { + it('errors on invalid code', async function () { try { await firebase.auth().checkActionCode('fooby shooby dooby'); } catch (e) { @@ -92,8 +89,8 @@ describe('auth()', function() { }); }); - describe('reload()', function() { - it('Meta data returns as expected with annonymous sign in', async function() { + describe('reload()', function () { + it('Meta data returns as expected with annonymous sign in', async function () { await firebase.auth().signInAnonymously(); await Utils.sleep(50); const firstUser = firebase.auth().currentUser; @@ -109,7 +106,7 @@ describe('auth()', function() { firstUser.metadata.creationTime.should.not.equal(secondUser.metadata.creationTime); }); - it('Meta data returns as expected with email and password sign in', async function() { + it('Meta data returns as expected with email and password sign in', async function () { const random = Utils.randString(12, '#aA'); const email1 = `${random}@${random}.com`; const pass = random; @@ -131,8 +128,8 @@ describe('auth()', function() { }); }); - describe('confirmPasswordReset()', function() { - it('errors on invalid code via API', async function() { + describe('confirmPasswordReset()', function () { + it('errors on invalid code via API', async function () { try { await firebase.auth().confirmPasswordReset('fooby shooby dooby', 'passwordthing'); } catch (e) { @@ -141,9 +138,9 @@ describe('auth()', function() { }); }); - describe('signInWithCustomToken()', function() { + describe('signInWithCustomToken()', function () { // Needs a different setup when running against the emulator - xit('signs in with a admin sdk created custom auth token', async function() { + xit('signs in with a admin sdk created custom auth token', async function () { const successCb = currentUserCredential => { const currentUser = currentUserCredential.user; currentUser.should.be.an.Object(); @@ -179,8 +176,8 @@ describe('auth()', function() { }); }); - describe('onAuthStateChanged()', function() { - it('calls callback with the current user and when auth state changes', async function() { + describe('onAuthStateChanged()', function () { + it('calls callback with the current user and when auth state changes', async function () { await firebase.auth().signInAnonymously(); await Utils.sleep(50); @@ -215,7 +212,7 @@ describe('auth()', function() { unsubscribe(); }); - it('accept observer instead callback as well', async function() { + it('accept observer instead callback as well', async function () { await firebase.auth().signInAnonymously(); await Utils.sleep(200); @@ -250,7 +247,7 @@ describe('auth()', function() { unsubscribe(); }); - it('stops listening when unsubscribed', async function() { + it('stops listening when unsubscribed', async function () { await firebase.auth().signInAnonymously(); await Utils.sleep(200); @@ -290,7 +287,7 @@ describe('auth()', function() { await Utils.sleep(50); }); - it('returns the same user with multiple subscribers #1815', async function() { + it('returns the same user with multiple subscribers #1815', async function () { const callback = sinon.spy(); let unsubscribe1; @@ -340,8 +337,8 @@ describe('auth()', function() { }); }); - describe('onIdTokenChanged()', function() { - it('calls callback with the current user and when auth state changes', async function() { + describe('onIdTokenChanged()', function () { + it('calls callback with the current user and when auth state changes', async function () { await firebase.auth().signInAnonymously(); await Utils.sleep(200); @@ -371,7 +368,7 @@ describe('auth()', function() { unsubscribe(); }); - it('stops listening when unsubscribed', async function() { + it('stops listening when unsubscribed', async function () { await firebase.auth().signInAnonymously(); await Utils.sleep(200); @@ -411,7 +408,7 @@ describe('auth()', function() { await Utils.sleep(50); }); - it('listens to a null user when auth result is not defined', async function() { + it('listens to a null user when auth result is not defined', async function () { let unsubscribe; const callback = sinon.spy(); @@ -427,8 +424,8 @@ describe('auth()', function() { }); }); - describe('onUserChanged()', function() { - it('calls callback with the current user and when auth state changes', async function() { + describe('onUserChanged()', function () { + it('calls callback with the current user and when auth state changes', async function () { await firebase.auth().signInAnonymously(); await Utils.sleep(200); @@ -461,7 +458,7 @@ describe('auth()', function() { unsubscribe(); }); - it('stops listening when unsubscribed', async function() { + it('stops listening when unsubscribed', async function () { await firebase.auth().signInAnonymously(); await Utils.sleep(200); @@ -505,8 +502,8 @@ describe('auth()', function() { }); }); - describe('signInAnonymously()', function() { - it('it should sign in anonymously', function() { + describe('signInAnonymously()', function () { + it('it should sign in anonymously', function () { const successCb = currentUserCredential => { const currentUser = currentUserCredential.user; currentUser.should.be.an.Object(); @@ -523,15 +520,12 @@ describe('auth()', function() { return firebase.auth().signOut(); }; - return firebase - .auth() - .signInAnonymously() - .then(successCb); + return firebase.auth().signInAnonymously().then(successCb); }); }); - describe('signInWithEmailAndPassword()', function() { - it('it should login with email and password', function() { + describe('signInWithEmailAndPassword()', function () { + it('it should login with email and password', function () { const successCb = currentUserCredential => { const currentUser = currentUserCredential.user; currentUser.should.be.an.Object(); @@ -549,13 +543,10 @@ describe('auth()', function() { return firebase.auth().signOut(); }; - return firebase - .auth() - .signInWithEmailAndPassword(TEST_EMAIL, TEST_PASS) - .then(successCb); + return firebase.auth().signInWithEmailAndPassword(TEST_EMAIL, TEST_PASS).then(successCb); }); - it('it should error on login if user is disabled', function() { + it('it should error on login if user is disabled', function () { const successCb = () => Promise.reject(new Error('Did not error.')); const failureCb = error => { @@ -571,7 +562,7 @@ describe('auth()', function() { .catch(failureCb); }); - it('it should error on login if password incorrect', function() { + it('it should error on login if password incorrect', function () { const successCb = () => Promise.reject(new Error('Did not error.')); const failureCb = error => { @@ -589,7 +580,7 @@ describe('auth()', function() { .catch(failureCb); }); - it('it should error on login if user not found', function() { + it('it should error on login if user not found', function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; const pass = random; @@ -612,8 +603,8 @@ describe('auth()', function() { }); }); - describe('signInWithCredential()', function() { - it('it should login with email and password', function() { + describe('signInWithCredential()', function () { + it('it should login with email and password', function () { const credential = firebase.auth.EmailAuthProvider.credential(TEST_EMAIL, TEST_PASS); const successCb = currentUserCredential => { @@ -633,13 +624,10 @@ describe('auth()', function() { return firebase.auth().signOut(); }; - return firebase - .auth() - .signInWithCredential(credential) - .then(successCb); + return firebase.auth().signInWithCredential(credential).then(successCb); }); - it('it should error on login if user is disabled', function() { + it('it should error on login if user is disabled', function () { const credential = firebase.auth.EmailAuthProvider.credential(DISABLED_EMAIL, DISABLED_PASS); const successCb = () => Promise.reject(new Error('Did not error.')); @@ -650,14 +638,10 @@ describe('auth()', function() { return Promise.resolve(); }; - return firebase - .auth() - .signInWithCredential(credential) - .then(successCb) - .catch(failureCb); + return firebase.auth().signInWithCredential(credential).then(successCb).catch(failureCb); }); - it('it should error on login if password incorrect', function() { + it('it should error on login if password incorrect', function () { const credential = firebase.auth.EmailAuthProvider.credential(TEST_EMAIL, TEST_PASS + '666'); const successCb = () => Promise.reject(new Error('Did not error.')); @@ -670,14 +654,10 @@ describe('auth()', function() { return Promise.resolve(); }; - return firebase - .auth() - .signInWithCredential(credential) - .then(successCb) - .catch(failureCb); + return firebase.auth().signInWithCredential(credential).then(successCb).catch(failureCb); }); - it('it should error on login if user not found', function() { + it('it should error on login if user not found', function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; const pass = random; @@ -694,16 +674,12 @@ describe('auth()', function() { return Promise.resolve(); }; - return firebase - .auth() - .signInWithCredential(credential) - .then(successCb) - .catch(failureCb); + return firebase.auth().signInWithCredential(credential).then(successCb).catch(failureCb); }); }); - describe('createUserWithEmailAndPassword()', function() { - it('it should create a user with an email and password', function() { + describe('createUserWithEmailAndPassword()', function () { + it('it should create a user with an email and password', function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; const pass = random; @@ -723,13 +699,10 @@ describe('auth()', function() { return newUser.delete(); }; - return firebase - .auth() - .createUserWithEmailAndPassword(email, pass) - .then(successCb); + return firebase.auth().createUserWithEmailAndPassword(email, pass).then(successCb); }); - it('it should error on create with invalid email', function() { + it('it should error on create with invalid email', function () { const random = Utils.randString(12, '#aA'); const email = `${random}${random}.com.boop.shoop`; const pass = random; @@ -749,7 +722,7 @@ describe('auth()', function() { .catch(failureCb); }); - it('it should error on create if email in use', function() { + it('it should error on create if email in use', function () { const successCb = () => Promise.reject(new Error('Did not error.')); const failureCb = error => { @@ -765,7 +738,7 @@ describe('auth()', function() { .catch(failureCb); }); - it('it should error on create if password weak', function() { + it('it should error on create if password weak', function () { const email = 'testy@testy.com'; const pass = '123'; @@ -786,8 +759,8 @@ describe('auth()', function() { }); }); - describe('fetchSignInMethodsForEmail()', function() { - it('it should return password provider for an email address', function() { + describe('fetchSignInMethodsForEmail()', function () { + it('it should return password provider for an email address', function () { return new Promise((resolve, reject) => { const successCb = providers => { providers.should.be.a.Array(); @@ -807,7 +780,7 @@ describe('auth()', function() { }); }); - it('it should return an empty array for a not found email', function() { + it('it should return an empty array for a not found email', function () { return new Promise((resolve, reject) => { const successCb = providers => { providers.should.be.a.Array(); @@ -827,7 +800,7 @@ describe('auth()', function() { }); }); - it('it should return an error for a bad email address', function() { + it('it should return an error for a bad email address', function () { return new Promise((resolve, reject) => { const successCb = () => { reject(new Error('Should not have successfully resolved.')); @@ -848,8 +821,8 @@ describe('auth()', function() { }); }); - describe('signOut()', function() { - it('it should reject signOut if no currentUser', function() { + describe('signOut()', function () { + it('it should reject signOut if no currentUser', function () { return new Promise((resolve, reject) => { if (firebase.auth().currentUser) { return reject( @@ -867,17 +840,13 @@ describe('auth()', function() { resolve(); }; - return firebase - .auth() - .signOut() - .then(successCb) - .catch(failureCb); + return firebase.auth().signOut().then(successCb).catch(failureCb); }); }); }); - describe('delete()', function() { - it('should delete a user', function() { + describe('delete()', function () { + it('should delete a user', function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; const pass = random; @@ -892,15 +861,12 @@ describe('auth()', function() { return firebase.auth().currentUser.delete(); }; - return firebase - .auth() - .createUserWithEmailAndPassword(email, pass) - .then(successCb); + return firebase.auth().createUserWithEmailAndPassword(email, pass).then(successCb); }); }); - describe('languageCode', function() { - it('it should change the language code', async function() { + describe('languageCode', function () { + it('it should change the language code', async function () { await firebase.auth().setLanguageCode('en'); if (firebase.auth().languageCode !== 'en') { @@ -925,8 +891,8 @@ describe('auth()', function() { }); }); - describe('getRedirectResult()', function() { - it('should throw an unsupported error', function() { + describe('getRedirectResult()', function () { + it('should throw an unsupported error', function () { (() => { firebase.auth().getRedirectResult(); }).should.throw( @@ -935,8 +901,8 @@ describe('auth()', function() { }); }); - describe('setPersistence()', function() { - it('should throw an unsupported error', function() { + describe('setPersistence()', function () { + it('should throw an unsupported error', function () { (() => { firebase.auth().setPersistence(); }).should.throw( @@ -945,8 +911,8 @@ describe('auth()', function() { }); }); - describe('signInWithPopup', function() { - it('should throw an unsupported error', function() { + describe('signInWithPopup', function () { + it('should throw an unsupported error', function () { (() => { firebase.auth().signInWithPopup(); }).should.throw( @@ -955,8 +921,8 @@ describe('auth()', function() { }); }); - describe('sendPasswordResetEmail()', function() { - it('should not error', async function() { + describe('sendPasswordResetEmail()', function () { + it('should not error', async function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; await firebase.auth().createUserWithEmailAndPassword(email, random); @@ -970,7 +936,7 @@ describe('auth()', function() { } }); - it('should verify with valid code', async function() { + it('should verify with valid code', async function () { // FIXME Fails on android against auth emulator with: // com.google.firebase.FirebaseException: An internal error has occurred. if (device.getPlatform() === 'ios') { @@ -993,7 +959,7 @@ describe('auth()', function() { } }); - it('should fail to verify with invalid code', async function() { + it('should fail to verify with invalid code', async function () { const random = Utils.randString(12, '#a'); const email = `${random}@${random}.com`; const userCredential = await firebase.auth().createUserWithEmailAndPassword(email, random); @@ -1013,7 +979,7 @@ describe('auth()', function() { } }); - it('should change password correctly OOB', async function() { + it('should change password correctly OOB', async function () { const random = Utils.randString(12, '#a'); const email = `${random}@${random}.com`; const userCredential = await firebase.auth().createUserWithEmailAndPassword(email, random); @@ -1035,7 +1001,7 @@ describe('auth()', function() { } }); - it('should change password correctly via API', async function() { + it('should change password correctly via API', async function () { const random = Utils.randString(12, '#a'); const email = `${random}@${random}.com`; const userCredential = await firebase.auth().createUserWithEmailAndPassword(email, random); @@ -1058,8 +1024,8 @@ describe('auth()', function() { }); }); - describe('signInWithRedirect()', function() { - it('should throw an unsupported error', function() { + describe('signInWithRedirect()', function () { + it('should throw an unsupported error', function () { (() => { firebase.auth().signInWithRedirect(); }).should.throw( @@ -1068,8 +1034,8 @@ describe('auth()', function() { }); }); - describe('useDeviceLanguage()', function() { - it('should throw an unsupported error', function() { + describe('useDeviceLanguage()', function () { + it('should throw an unsupported error', function () { (() => { firebase.auth().useDeviceLanguage(); }).should.throw( @@ -1078,8 +1044,8 @@ describe('auth()', function() { }); }); - describe('useUserAccessGroup()', function() { - it('should return "null" on successful keychain implementation', async function() { + describe('useUserAccessGroup()', function () { + it('should return "null" on successful keychain implementation', async function () { const successfulKeychain = await firebase.auth().useUserAccessGroup('mysecretkeychain'); should.not.exist(successfulKeychain); diff --git a/packages/auth/e2e/emailLink.e2e.js b/packages/auth/e2e/emailLink.e2e.js index 7e777de6ac..812c5d37e4 100644 --- a/packages/auth/e2e/emailLink.e2e.js +++ b/packages/auth/e2e/emailLink.e2e.js @@ -1,15 +1,15 @@ const { getLastOob, signInUser } = require('./helpers'); -describe('auth() -> emailLink Provider', function() { - beforeEach(async function() { +describe('auth() -> emailLink Provider', function () { + beforeEach(async function () { if (firebase.auth().currentUser) { await firebase.auth().signOut(); await Utils.sleep(50); } }); - describe('sendSignInLinkToEmail', function() { - it('should send email', async function() { + describe('sendSignInLinkToEmail', function () { + it('should send email', async function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; // const email = 'MANUAL TEST EMAIL HERE'; @@ -28,7 +28,7 @@ describe('auth() -> emailLink Provider', function() { await firebase.auth().sendSignInLinkToEmail(email, actionCodeSettings); }); - it('sign in via email works', async function() { + it('sign in via email works', async function () { const random = Utils.randString(12, '#aa'); const email = `${random}@${random}.com`; const continueUrl = 'http://localhost:1337/authLinkFoo?bar=' + random; @@ -52,7 +52,7 @@ describe('auth() -> emailLink Provider', function() { signInResponse.should.containEql(oobInfo.oobCode); }); - xit('should send email with defaults', async function() { + xit('should send email with defaults', async function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; @@ -60,8 +60,8 @@ describe('auth() -> emailLink Provider', function() { }); }); - describe('isSignInWithEmailLink', function() { - it('should return true/false', async function() { + describe('isSignInWithEmailLink', function () { + it('should return true/false', async function () { const emailLink1 = 'https://www.example.com/action?mode=signIn&oobCode=oobCode'; const emailLink2 = 'https://www.example.com/action?mode=verifyEmail&oobCode=oobCode'; const emailLink3 = 'https://www.example.com/action?mode=signIn'; @@ -76,8 +76,8 @@ describe('auth() -> emailLink Provider', function() { }); // FOR MANUAL TESTING ONLY - xdescribe('signInWithEmailLink', function() { - it('should signIn', async function() { + xdescribe('signInWithEmailLink', function () { + it('should signIn', async function () { const email = 'MANUAL TEST EMAIL HERE'; const emailLink = 'MANUAL TEST CODE HERE'; diff --git a/packages/auth/e2e/phone.e2e.js b/packages/auth/e2e/phone.e2e.js index 4e3be9f957..d3b363e3f8 100644 --- a/packages/auth/e2e/phone.e2e.js +++ b/packages/auth/e2e/phone.e2e.js @@ -3,8 +3,8 @@ const { clearAllUsers, getLastSmsCode, getRandomPhoneNumber } = require('./helpers'); -describe('auth() => Phone', function() { - before(async function() { +describe('auth() => Phone', function () { + before(async function () { try { await clearAllUsers(); } catch (e) { @@ -14,15 +14,15 @@ describe('auth() => Phone', function() { await Utils.sleep(50); }); - beforeEach(async function() { + beforeEach(async function () { if (firebase.auth().currentUser) { await firebase.auth().signOut(); await Utils.sleep(50); } }); - describe('signInWithPhoneNumber', function() { - it('signs in with a valid code', async function() { + describe('signInWithPhoneNumber', function () { + it('signs in with a valid code', async function () { const testPhone = await getRandomPhoneNumber(); const confirmResult = await firebase.auth().signInWithPhoneNumber(testPhone); confirmResult.verificationId.should.be.a.String(); @@ -36,7 +36,7 @@ describe('auth() => Phone', function() { // userCredential.user.phoneNumber.should.equal(TEST_PHONE_A); }); - it('errors on invalid code', async function() { + it('errors on invalid code', async function () { const testPhone = await getRandomPhoneNumber(); const confirmResult = await firebase.auth().signInWithPhoneNumber(testPhone); confirmResult.verificationId.should.be.a.String(); @@ -54,8 +54,8 @@ describe('auth() => Phone', function() { }); }); - describe('verifyPhoneNumber', function() { - it('successfully verifies', async function() { + describe('verifyPhoneNumber', function () { + it('successfully verifies', async function () { const testPhone = await getRandomPhoneNumber(); const confirmResult = await firebase.auth().signInWithPhoneNumber(testPhone); const lastSmsCode = await getLastSmsCode(testPhone); @@ -63,7 +63,7 @@ describe('auth() => Phone', function() { await firebase.auth().verifyPhoneNumber(testPhone, false, false); }); - it('uses the autoVerifyTimeout when a non boolean autoVerifyTimeoutOrForceResend is provided', async function() { + it('uses the autoVerifyTimeout when a non boolean autoVerifyTimeoutOrForceResend is provided', async function () { const testPhone = await getRandomPhoneNumber(); const confirmResult = await firebase.auth().signInWithPhoneNumber(testPhone); const lastSmsCode = await getLastSmsCode(testPhone); @@ -71,7 +71,7 @@ describe('auth() => Phone', function() { await firebase.auth().verifyPhoneNumber(testPhone, 0, false); }); - it('throws an error with an invalid on event', async function() { + it('throws an error with an invalid on event', async function () { const testPhone = await getRandomPhoneNumber(); try { await firebase @@ -88,7 +88,7 @@ describe('auth() => Phone', function() { } }); - it('throws an error with an invalid observer event', async function() { + it('throws an error with an invalid observer event', async function () { const testPhone = await getRandomPhoneNumber(); try { await firebase @@ -105,7 +105,7 @@ describe('auth() => Phone', function() { } }); - it('successfully runs verification complete handler', async function() { + it('successfully runs verification complete handler', async function () { const testPhone = await getRandomPhoneNumber(); await firebase .auth() @@ -115,7 +115,7 @@ describe('auth() => Phone', function() { return Promise.resolve(); }); - it('successfully runs and adds emitters', async function() { + it('successfully runs and adds emitters', async function () { const testPhone = await getRandomPhoneNumber(); const obervserCb = () => {}; const errorCb = () => {}; @@ -129,7 +129,7 @@ describe('auth() => Phone', function() { .on('state_changed', obervserCb, errorCb, successCb, () => {}); }); - it('catches an error and emits an error event', async function() { + it('catches an error and emits an error event', async function () { return firebase .auth() .verifyPhoneNumber('test') diff --git a/packages/auth/e2e/provider.e2e.js b/packages/auth/e2e/provider.e2e.js index ce1551919b..ac0edea8f3 100644 --- a/packages/auth/e2e/provider.e2e.js +++ b/packages/auth/e2e/provider.e2e.js @@ -1,22 +1,22 @@ -describe('auth() -> Providers', function() { - beforeEach(async function() { +describe('auth() -> Providers', function () { + beforeEach(async function () { if (firebase.auth().currentUser) { await firebase.auth().signOut(); await Utils.sleep(50); } }); - describe('EmailAuthProvider', function() { - describe('constructor', function() { - it('should throw an unsupported error', function() { + describe('EmailAuthProvider', function () { + describe('constructor', function () { + it('should throw an unsupported error', function () { (() => new firebase.auth.EmailAuthProvider()).should.throw( '`new EmailAuthProvider()` is not supported on the native Firebase SDKs.', ); }); }); - describe('credential', function() { - it('should return a credential object', function() { + describe('credential', function () { + it('should return a credential object', function () { const email = 'email@email.com'; const password = 'password'; const credential = firebase.auth.EmailAuthProvider.credential(email, password); @@ -26,8 +26,8 @@ describe('auth() -> Providers', function() { }); }); - describe('credentialWithLink', function() { - it('should return a credential object', function() { + describe('credentialWithLink', function () { + it('should return a credential object', function () { const email = 'email@email.com'; const link = 'link'; const credential = firebase.auth.EmailAuthProvider.credentialWithLink(email, link); @@ -37,36 +37,36 @@ describe('auth() -> Providers', function() { }); }); - describe('EMAIL_PASSWORD_SIGN_IN_METHOD', function() { - it('should return password', function() { + describe('EMAIL_PASSWORD_SIGN_IN_METHOD', function () { + it('should return password', function () { firebase.auth.EmailAuthProvider.EMAIL_PASSWORD_SIGN_IN_METHOD.should.equal('password'); }); }); - describe('EMAIL_LINK_SIGN_IN_METHOD', function() { - it('should return emailLink', function() { + describe('EMAIL_LINK_SIGN_IN_METHOD', function () { + it('should return emailLink', function () { firebase.auth.EmailAuthProvider.EMAIL_LINK_SIGN_IN_METHOD.should.equal('emailLink'); }); }); - describe('PROVIDER_ID', function() { - it('should return password', function() { + describe('PROVIDER_ID', function () { + it('should return password', function () { firebase.auth.EmailAuthProvider.PROVIDER_ID.should.equal('password'); }); }); }); - describe('FacebookAuthProvider', function() { - describe('constructor', function() { - it('should throw an unsupported error', function() { + describe('FacebookAuthProvider', function () { + describe('constructor', function () { + it('should throw an unsupported error', function () { (() => new firebase.auth.FacebookAuthProvider()).should.throw( '`new FacebookAuthProvider()` is not supported on the native Firebase SDKs.', ); }); }); - describe('credential', function() { - it('should return a credential object', function() { + describe('credential', function () { + it('should return a credential object', function () { const token = '123456'; const credential = firebase.auth.FacebookAuthProvider.credential(token); credential.providerId.should.equal('facebook.com'); @@ -75,24 +75,24 @@ describe('auth() -> Providers', function() { }); }); - describe('PROVIDER_ID', function() { - it('should return facebook.com', function() { + describe('PROVIDER_ID', function () { + it('should return facebook.com', function () { firebase.auth.FacebookAuthProvider.PROVIDER_ID.should.equal('facebook.com'); }); }); }); - describe('GithubAuthProvider', function() { - describe('constructor', function() { - it('should throw an unsupported error', function() { + describe('GithubAuthProvider', function () { + describe('constructor', function () { + it('should throw an unsupported error', function () { (() => new firebase.auth.GithubAuthProvider()).should.throw( '`new GithubAuthProvider()` is not supported on the native Firebase SDKs.', ); }); }); - describe('credential', function() { - it('should return a credential object', function() { + describe('credential', function () { + it('should return a credential object', function () { const token = '123456'; const credential = firebase.auth.GithubAuthProvider.credential(token); credential.providerId.should.equal('github.com'); @@ -101,24 +101,24 @@ describe('auth() -> Providers', function() { }); }); - describe('PROVIDER_ID', function() { - it('should return github.com', function() { + describe('PROVIDER_ID', function () { + it('should return github.com', function () { firebase.auth.GithubAuthProvider.PROVIDER_ID.should.equal('github.com'); }); }); }); - describe('GoogleAuthProvider', function() { - describe('constructor', function() { - it('should throw an unsupported error', function() { + describe('GoogleAuthProvider', function () { + describe('constructor', function () { + it('should throw an unsupported error', function () { (() => new firebase.auth.GoogleAuthProvider()).should.throw( '`new GoogleAuthProvider()` is not supported on the native Firebase SDKs.', ); }); }); - describe('credential', function() { - it('should return a credential object', function() { + describe('credential', function () { + it('should return a credential object', function () { const token = '123456'; const secret = '654321'; const credential = firebase.auth.GoogleAuthProvider.credential(token, secret); @@ -128,24 +128,24 @@ describe('auth() -> Providers', function() { }); }); - describe('PROVIDER_ID', function() { - it('should return google.com', function() { + describe('PROVIDER_ID', function () { + it('should return google.com', function () { firebase.auth.GoogleAuthProvider.PROVIDER_ID.should.equal('google.com'); }); }); }); - describe('OAuthProvider', function() { - describe('constructor', function() { - it('should throw an unsupported error', function() { + describe('OAuthProvider', function () { + describe('constructor', function () { + it('should throw an unsupported error', function () { (() => new firebase.auth.OAuthProvider()).should.throw( '`new OAuthProvider()` is not supported on the native Firebase SDKs.', ); }); }); - describe('credential', function() { - it('should return a credential object', function() { + describe('credential', function () { + it('should return a credential object', function () { const idToken = '123456'; const accessToken = '654321'; const credential = firebase.auth.OAuthProvider.credential(idToken, accessToken); @@ -155,24 +155,24 @@ describe('auth() -> Providers', function() { }); }); - describe('PROVIDER_ID', function() { - it('should return oauth', function() { + describe('PROVIDER_ID', function () { + it('should return oauth', function () { firebase.auth.OAuthProvider.PROVIDER_ID.should.equal('oauth'); }); }); }); - describe('PhoneAuthProvider', function() { - describe('constructor', function() { - it('should throw an unsupported error', function() { + describe('PhoneAuthProvider', function () { + describe('constructor', function () { + it('should throw an unsupported error', function () { (() => new firebase.auth.PhoneAuthProvider()).should.throw( '`new PhoneAuthProvider()` is not supported on the native Firebase SDKs.', ); }); }); - describe('credential', function() { - it('should return a credential object', function() { + describe('credential', function () { + it('should return a credential object', function () { const verificationId = '123456'; const code = '654321'; const credential = firebase.auth.PhoneAuthProvider.credential(verificationId, code); @@ -182,24 +182,24 @@ describe('auth() -> Providers', function() { }); }); - describe('PROVIDER_ID', function() { - it('should return phone', function() { + describe('PROVIDER_ID', function () { + it('should return phone', function () { firebase.auth.PhoneAuthProvider.PROVIDER_ID.should.equal('phone'); }); }); }); - describe('TwitterAuthProvider', function() { - describe('constructor', function() { - it('should throw an unsupported error', function() { + describe('TwitterAuthProvider', function () { + describe('constructor', function () { + it('should throw an unsupported error', function () { (() => new firebase.auth.TwitterAuthProvider()).should.throw( '`new TwitterAuthProvider()` is not supported on the native Firebase SDKs.', ); }); }); - describe('credential', function() { - it('should return a credential object', function() { + describe('credential', function () { + it('should return a credential object', function () { const token = '123456'; const secret = '654321'; const credential = firebase.auth.TwitterAuthProvider.credential(token, secret); @@ -209,8 +209,8 @@ describe('auth() -> Providers', function() { }); }); - describe('PROVIDER_ID', function() { - it('should return twitter.com', function() { + describe('PROVIDER_ID', function () { + it('should return twitter.com', function () { firebase.auth.TwitterAuthProvider.PROVIDER_ID.should.equal('twitter.com'); }); }); diff --git a/packages/auth/e2e/rnReload.e2e.js b/packages/auth/e2e/rnReload.e2e.js index 63bbf9e7e1..6da2eae218 100644 --- a/packages/auth/e2e/rnReload.e2e.js +++ b/packages/auth/e2e/rnReload.e2e.js @@ -3,8 +3,8 @@ const TEST_PASS = 'test1234'; const { clearAllUsers } = require('./helpers'); -describe('auth()', function() { - before(async function() { +describe('auth()', function () { + before(async function () { try { await clearAllUsers(); } catch (e) { @@ -17,7 +17,7 @@ describe('auth()', function() { } }); - beforeEach(async function() { + beforeEach(async function () { if (firebase.auth().currentUser) { await firebase.auth().signOut(); await Utils.sleep(50); @@ -26,7 +26,7 @@ describe('auth()', function() { // TODO(salakar): Detox on iOS crashing app on reloads android.describe('firebase.auth().currentUser', () => { - it('exists after reload', async function() { + it('exists after reload', async function () { let currentUser; // before reload await firebase.auth().signInAnonymously(); diff --git a/packages/auth/e2e/user.e2e.js b/packages/auth/e2e/user.e2e.js index 4b7390e721..8b7917bdde 100644 --- a/packages/auth/e2e/user.e2e.js +++ b/packages/auth/e2e/user.e2e.js @@ -9,8 +9,8 @@ const { verifyEmail, } = require('./helpers'); -describe('auth().currentUser', function() { - before(async function() { +describe('auth().currentUser', function () { + before(async function () { try { await clearAllUsers(); } catch (e) { @@ -24,15 +24,15 @@ describe('auth().currentUser', function() { } }); - beforeEach(async function() { + beforeEach(async function () { if (firebase.auth().currentUser) { await firebase.auth().signOut(); await Utils.sleep(50); } }); - describe('getIdToken()', function() { - it('should return a token', async function() { + describe('getIdToken()', function () { + it('should return a token', async function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; @@ -50,8 +50,8 @@ describe('auth().currentUser', function() { }); }); - describe('getIdTokenResult()', function() { - it('should return a valid IdTokenResult Object', async function() { + describe('getIdTokenResult()', function () { + it('should return a valid IdTokenResult Object', async function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; @@ -81,9 +81,9 @@ describe('auth().currentUser', function() { }); }); - describe('linkWithCredential()', function() { + describe('linkWithCredential()', function () { // hanging against auth emulator? - it('should link anonymous account <-> email account', async function() { + it('should link anonymous account <-> email account', async function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; const pass = random; @@ -110,7 +110,7 @@ describe('auth().currentUser', function() { await firebase.auth().currentUser.delete(); }); - it('should error on link anon <-> email if email already exists', async function() { + it('should error on link anon <-> email if email already exists', async function () { await firebase.auth().signInAnonymously(); const { currentUser } = firebase.auth(); @@ -137,8 +137,8 @@ describe('auth().currentUser', function() { }); }); - describe('reauthenticateWithCredential()', function() { - it('should reauthenticate correctly', async function() { + describe('reauthenticateWithCredential()', function () { + it('should reauthenticate correctly', async function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; const pass = random; @@ -159,8 +159,8 @@ describe('auth().currentUser', function() { }); }); - describe('reload()', function() { - it('should not error', async function() { + describe('reload()', function () { + it('should not error', async function () { await firebase.auth().signInAnonymously(); try { @@ -176,8 +176,8 @@ describe('auth().currentUser', function() { }); }); - describe('sendEmailVerification()', function() { - it('should error if actionCodeSettings.url is not present', async function() { + describe('sendEmailVerification()', function () { + it('should error if actionCodeSettings.url is not present', async function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; await firebase.auth().createUserWithEmailAndPassword(email, random); @@ -190,7 +190,7 @@ describe('auth().currentUser', function() { await firebase.auth().currentUser.delete(); }); - it('should error if actionCodeSettings.url is not a string', async function() { + it('should error if actionCodeSettings.url is not a string', async function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; await firebase.auth().createUserWithEmailAndPassword(email, random); @@ -203,7 +203,7 @@ describe('auth().currentUser', function() { await firebase.auth().currentUser.delete(); }); - it('should error if actionCodeSettings.dynamicLinkDomain is not a string', async function() { + it('should error if actionCodeSettings.dynamicLinkDomain is not a string', async function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; await firebase.auth().createUserWithEmailAndPassword(email, random); @@ -220,7 +220,7 @@ describe('auth().currentUser', function() { await firebase.auth().currentUser.delete(); }); - it('should error if handleCodeInApp is not a string', async function() { + it('should error if handleCodeInApp is not a string', async function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; await firebase.auth().createUserWithEmailAndPassword(email, random); @@ -235,7 +235,7 @@ describe('auth().currentUser', function() { await firebase.auth().currentUser.delete(); }); - it('should error if actionCodeSettings.iOS is not an object', async function() { + it('should error if actionCodeSettings.iOS is not an object', async function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; await firebase.auth().createUserWithEmailAndPassword(email, random); @@ -248,7 +248,7 @@ describe('auth().currentUser', function() { await firebase.auth().currentUser.delete(); }); - it('should error if actionCodeSettings.iOS.bundleId is not a string', async function() { + it('should error if actionCodeSettings.iOS.bundleId is not a string', async function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; await firebase.auth().createUserWithEmailAndPassword(email, random); @@ -265,7 +265,7 @@ describe('auth().currentUser', function() { await firebase.auth().currentUser.delete(); }); - it('should error if actionCodeSettings.android is not an object', async function() { + it('should error if actionCodeSettings.android is not an object', async function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; await firebase.auth().createUserWithEmailAndPassword(email, random); @@ -278,7 +278,7 @@ describe('auth().currentUser', function() { await firebase.auth().currentUser.delete(); }); - it('should error if actionCodeSettings.android.packageName is not a string', async function() { + it('should error if actionCodeSettings.android.packageName is not a string', async function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; await firebase.auth().createUserWithEmailAndPassword(email, random); @@ -295,7 +295,7 @@ describe('auth().currentUser', function() { await firebase.auth().currentUser.delete(); }); - it('should error if actionCodeSettings.android.installApp is not a string', async function() { + it('should error if actionCodeSettings.android.installApp is not a string', async function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; await firebase.auth().createUserWithEmailAndPassword(email, random); @@ -313,7 +313,7 @@ describe('auth().currentUser', function() { await firebase.auth().currentUser.delete(); }); - it('should error if actionCodeSettings.android.minimumVersion is not a string', async function() { + it('should error if actionCodeSettings.android.minimumVersion is not a string', async function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; await firebase.auth().createUserWithEmailAndPassword(email, random); @@ -331,7 +331,7 @@ describe('auth().currentUser', function() { await firebase.auth().currentUser.delete(); }); - it('should not error', async function() { + it('should not error', async function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; await firebase.auth().createUserWithEmailAndPassword(email, random); @@ -347,7 +347,7 @@ describe('auth().currentUser', function() { return Promise.resolve(); }); - it('should correctly report emailVerified status', async function() { + it('should correctly report emailVerified status', async function () { const random = Utils.randString(12, '#a'); const email = `${random}@${random}.com`; await firebase.auth().createUserWithEmailAndPassword(email, random); @@ -370,7 +370,7 @@ describe('auth().currentUser', function() { return Promise.resolve(); }); - it('should work with actionCodeSettings', async function() { + it('should work with actionCodeSettings', async function () { const actionCodeSettings = { handleCodeInApp: true, url: 'https://react-native-firebase-testing.firebaseapp.com/foo', @@ -392,7 +392,7 @@ describe('auth().currentUser', function() { return Promise.resolve(); }); - it('should throw an error within an invalid action code url', async function() { + it('should throw an error within an invalid action code url', async function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; await firebase.auth().createUserWithEmailAndPassword(email, random); @@ -405,8 +405,8 @@ describe('auth().currentUser', function() { }); }); - describe('verifyBeforeUpdateEmail()', function() { - it('should error if newEmail is not a string', async function() { + describe('verifyBeforeUpdateEmail()', function () { + it('should error if newEmail is not a string', async function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; @@ -419,7 +419,7 @@ describe('auth().currentUser', function() { } await firebase.auth().currentUser.delete(); }); - it('should error if actionCodeSettings.url is not present', async function() { + it('should error if actionCodeSettings.url is not present', async function () { const random = Utils.randString(12, '#aA'); const random2 = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; @@ -435,7 +435,7 @@ describe('auth().currentUser', function() { await firebase.auth().currentUser.delete(); }); - it('should error if actionCodeSettings.url is not a string', async function() { + it('should error if actionCodeSettings.url is not a string', async function () { const random = Utils.randString(12, '#aA'); const random2 = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; @@ -451,7 +451,7 @@ describe('auth().currentUser', function() { await firebase.auth().currentUser.delete(); }); - it('should error if actionCodeSettings.dynamicLinkDomain is not a string', async function() { + it('should error if actionCodeSettings.dynamicLinkDomain is not a string', async function () { const random = Utils.randString(12, '#aA'); const random2 = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; @@ -472,7 +472,7 @@ describe('auth().currentUser', function() { await firebase.auth().currentUser.delete(); }); - it('should error if handleCodeInApp is not a boolean', async function() { + it('should error if handleCodeInApp is not a boolean', async function () { const random = Utils.randString(12, '#aA'); const random2 = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; @@ -493,7 +493,7 @@ describe('auth().currentUser', function() { await firebase.auth().currentUser.delete(); }); - it('should error if actionCodeSettings.iOS is not an object', async function() { + it('should error if actionCodeSettings.iOS is not an object', async function () { const random = Utils.randString(12, '#aA'); const random2 = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; @@ -512,7 +512,7 @@ describe('auth().currentUser', function() { await firebase.auth().currentUser.delete(); }); - it('should error if actionCodeSettings.iOS.bundleId is not a string', async function() { + it('should error if actionCodeSettings.iOS.bundleId is not a string', async function () { const random = Utils.randString(12, '#aA'); const random2 = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; @@ -533,7 +533,7 @@ describe('auth().currentUser', function() { await firebase.auth().currentUser.delete(); }); - it('should error if actionCodeSettings.android is not an object', async function() { + it('should error if actionCodeSettings.android is not an object', async function () { const random = Utils.randString(12, '#aA'); const random2 = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; @@ -552,7 +552,7 @@ describe('auth().currentUser', function() { await firebase.auth().currentUser.delete(); }); - it('should error if actionCodeSettings.android.packageName is not a string', async function() { + it('should error if actionCodeSettings.android.packageName is not a string', async function () { const random = Utils.randString(12, '#aA'); const random2 = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; @@ -573,7 +573,7 @@ describe('auth().currentUser', function() { await firebase.auth().currentUser.delete(); }); - it('should error if actionCodeSettings.android.installApp is not a boolean', async function() { + it('should error if actionCodeSettings.android.installApp is not a boolean', async function () { const random = Utils.randString(12, '#aA'); const random2 = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; @@ -594,7 +594,7 @@ describe('auth().currentUser', function() { await firebase.auth().currentUser.delete(); }); - it('should error if actionCodeSettings.android.minimumVersion is not a string', async function() { + it('should error if actionCodeSettings.android.minimumVersion is not a string', async function () { const random = Utils.randString(12, '#aA'); const random2 = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; @@ -617,7 +617,7 @@ describe('auth().currentUser', function() { // FIXME ios+android failing with an internal error against auth emulator // com.google.firebase.FirebaseException: An internal error has occurred. [ VERIFY_AND_CHANGE_EMAIL ] - xit('should not error', async function() { + xit('should not error', async function () { const random = Utils.randString(12, '#aA'); const random2 = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; @@ -634,7 +634,7 @@ describe('auth().currentUser', function() { // FIXME ios+android failing with an internal error against auth emulator // com.google.firebase.FirebaseException: An internal error has occurred. [ VERIFY_AND_CHANGE_EMAIL ] - xit('should work with actionCodeSettings', async function() { + xit('should work with actionCodeSettings', async function () { const random = Utils.randString(12, '#aA'); const random2 = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; @@ -659,8 +659,8 @@ describe('auth().currentUser', function() { return Promise.resolve(); }); }); - describe('unlink()', function() { - it('should unlink the email address', async function() { + describe('unlink()', function () { + it('should unlink the email address', async function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; const pass = random; @@ -684,8 +684,8 @@ describe('auth().currentUser', function() { }); }); - describe('updateEmail()', function() { - it('should update the email address', async function() { + describe('updateEmail()', function () { + it('should update the email address', async function () { const random = Utils.randString(12, '#a'); const random2 = Utils.randString(12, '#a'); const email = `${random}@${random}.com`; @@ -705,8 +705,8 @@ describe('auth().currentUser', function() { }); }); - describe('updatePhoneNumber()', function() { - it('should update the phone number', async function() { + describe('updatePhoneNumber()', function () { + it('should update the phone number', async function () { const testPhone = await getRandomPhoneNumber(); const confirmResult = await firebase.auth().signInWithPhoneNumber(testPhone); const smsCode = await getLastSmsCode(testPhone); @@ -748,8 +748,8 @@ describe('auth().currentUser', function() { }); }); - describe('updatePassword()', function() { - it('should update the password', async function() { + describe('updatePassword()', function () { + it('should update the password', async function () { const random = Utils.randString(12, '#aA'); const random2 = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; @@ -777,7 +777,7 @@ describe('auth().currentUser', function() { }); // Can only be run/reproduced locally with Firebase Auth rate limits lowered on the Firebase console. - xit('should throw too many requests when limit has been reached', async function() { + xit('should throw too many requests when limit has been reached', async function () { await Utils.sleep(10000); try { // Setup for creating new accounts @@ -804,8 +804,8 @@ describe('auth().currentUser', function() { }); }); - describe('updateProfile()', function() { - it('should update the profile', async function() { + describe('updateProfile()', function () { + it('should update the profile', async function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; const pass = random; @@ -832,7 +832,7 @@ describe('auth().currentUser', function() { await firebase.auth().currentUser.delete(); }); - it('should return a valid profile when signing in anonymously', async function() { + it('should return a valid profile when signing in anonymously', async function () { // Setup await firebase.auth().signInAnonymously(); const { currentUser } = firebase.auth(); @@ -856,8 +856,8 @@ describe('auth().currentUser', function() { }); }); - describe('linkWithPhoneNumber()', function() { - it('should throw an unsupported error', async function() { + describe('linkWithPhoneNumber()', function () { + it('should throw an unsupported error', async function () { await firebase.auth().signInAnonymously(); (() => { firebase.auth().currentUser.linkWithPhoneNumber(); @@ -868,8 +868,8 @@ describe('auth().currentUser', function() { }); }); - describe('linkWithPopup()', function() { - it('should throw an unsupported error', async function() { + describe('linkWithPopup()', function () { + it('should throw an unsupported error', async function () { await firebase.auth().signInAnonymously(); (() => { firebase.auth().currentUser.linkWithPopup(); @@ -880,8 +880,8 @@ describe('auth().currentUser', function() { }); }); - describe('linkWithRedirect()', function() { - it('should throw an unsupported error', async function() { + describe('linkWithRedirect()', function () { + it('should throw an unsupported error', async function () { await firebase.auth().signInAnonymously(); (() => { firebase.auth().currentUser.linkWithRedirect(); @@ -892,8 +892,8 @@ describe('auth().currentUser', function() { }); }); - describe('reauthenticateWithPhoneNumber()', function() { - it('should throw an unsupported error', async function() { + describe('reauthenticateWithPhoneNumber()', function () { + it('should throw an unsupported error', async function () { await firebase.auth().signInAnonymously(); (() => { firebase.auth().currentUser.reauthenticateWithPhoneNumber(); @@ -904,8 +904,8 @@ describe('auth().currentUser', function() { }); }); - describe('reauthenticateWithPopup()', function() { - it('should throw an unsupported error', async function() { + describe('reauthenticateWithPopup()', function () { + it('should throw an unsupported error', async function () { await firebase.auth().signInAnonymously(); (() => { firebase.auth().currentUser.reauthenticateWithPopup(); @@ -916,8 +916,8 @@ describe('auth().currentUser', function() { }); }); - describe('reauthenticateWithRedirect()', function() { - it('should throw an unsupported error', async function() { + describe('reauthenticateWithRedirect()', function () { + it('should throw an unsupported error', async function () { await firebase.auth().signInAnonymously(); (() => { firebase.auth().currentUser.reauthenticateWithRedirect(); @@ -928,8 +928,8 @@ describe('auth().currentUser', function() { }); }); - describe('refreshToken', function() { - it('should throw an unsupported error', async function() { + describe('refreshToken', function () { + it('should throw an unsupported error', async function () { await firebase.auth().signInAnonymously(); (() => firebase.auth().currentUser.refreshToken).should.throw( 'firebase.auth.User.refreshToken is unsupported by the native Firebase SDKs.', @@ -938,8 +938,8 @@ describe('auth().currentUser', function() { }); }); - describe('user.metadata', function() { - it("should have the properties 'lastSignInTime' & 'creationTime' which are ISO strings", async function() { + describe('user.metadata', function () { + it("should have the properties 'lastSignInTime' & 'creationTime' which are ISO strings", async function () { const random = Utils.randString(12, '#aA'); const email = `${random}@${random}.com`; diff --git a/packages/auth/lib/index.d.ts b/packages/auth/lib/index.d.ts index ecae068cb5..3b2e63ff03 100644 --- a/packages/auth/lib/index.d.ts +++ b/packages/auth/lib/index.d.ts @@ -1082,6 +1082,7 @@ export namespace FirebaseAuthTypes { * const user = firebase.auth().currentUser.toJSON(); * ``` */ + // eslint-disable-next-line @typescript-eslint/ban-types toJSON(): object; /** @@ -1669,6 +1670,7 @@ export default defaultExport; * Attach namespace to `firebase.` and `FirebaseApp.`. */ declare module '@react-native-firebase/app' { + // eslint-disable-next-line @typescript-eslint/no-unused-vars namespace ReactNativeFirebase { import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp; interface Module { diff --git a/packages/crashlytics/__tests__/crashlytics.test.ts b/packages/crashlytics/__tests__/crashlytics.test.ts index 63149a3241..e598ae997d 100644 --- a/packages/crashlytics/__tests__/crashlytics.test.ts +++ b/packages/crashlytics/__tests__/crashlytics.test.ts @@ -1,8 +1,8 @@ import { firebase } from '../lib'; -describe('Crashlytics', function() { - describe('namespace', function() { - it('accessible from firebase.app()', function() { +describe('Crashlytics', function () { + describe('namespace', function () { + it('accessible from firebase.app()', function () { const app = firebase.app(); expect(app.crashlytics).toBeDefined(); expect(app.crashlytics().app).toEqual(app); diff --git a/packages/crashlytics/e2e/crashlytics.e2e.js b/packages/crashlytics/e2e/crashlytics.e2e.js index ae36c4231b..2924e9ba57 100644 --- a/packages/crashlytics/e2e/crashlytics.e2e.js +++ b/packages/crashlytics/e2e/crashlytics.e2e.js @@ -15,10 +15,10 @@ * */ -describe('crashlytics()', function() { +describe('crashlytics()', function () { // Run locally only - flakey on CI - xdescribe('crash()', function() { - it('crashes the app', async function() { + xdescribe('crash()', function () { + it('crashes the app', async function () { jet.context._BEFORE_CRASH_ = 1; firebase.crashlytics().crash(); await Utils.sleep(1500); @@ -28,8 +28,8 @@ describe('crashlytics()', function() { }); }); - describe('log()', function() { - it('accepts any value', async function() { + describe('log()', function () { + it('accepts any value', async function () { firebase.crashlytics().log('invertase'); firebase.crashlytics().log(1337); firebase.crashlytics().log(null); @@ -40,12 +40,12 @@ describe('crashlytics()', function() { }); }); - describe('setUserId()', function() { - it('accepts string values', async function() { + describe('setUserId()', function () { + it('accepts string values', async function () { await firebase.crashlytics().setUserId('invertase'); }); - it('rejects none string values', async function() { + it('rejects none string values', async function () { try { await firebase.crashlytics().setUserId(666.1337); return Promise.reject(new Error('Did not throw.')); @@ -55,12 +55,12 @@ describe('crashlytics()', function() { }); }); - describe('setAttribute()', function() { - it('accepts string values', async function() { + describe('setAttribute()', function () { + it('accepts string values', async function () { await firebase.crashlytics().setAttribute('invertase', '1337'); }); - it('rejects none string values', async function() { + it('rejects none string values', async function () { try { await firebase.crashlytics().setAttribute('invertase', 33.3333); return Promise.reject(new Error('Did not throw.')); @@ -69,7 +69,7 @@ describe('crashlytics()', function() { } }); - it('errors if attribute name is not a string', async function() { + it('errors if attribute name is not a string', async function () { try { await firebase.crashlytics().setAttribute(1337, 'invertase'); return Promise.reject(new Error('Did not throw.')); @@ -79,8 +79,8 @@ describe('crashlytics()', function() { }); }); - describe('setAttributes()', function() { - it('errors if arg is not an object', async function() { + describe('setAttributes()', function () { + it('errors if arg is not an object', async function () { try { await firebase.crashlytics().setAttributes(1337); return Promise.reject(new Error('Did not throw.')); @@ -89,13 +89,13 @@ describe('crashlytics()', function() { } }); - it('accepts string values', async function() { + it('accepts string values', async function () { await firebase.crashlytics().setAttributes({ invertase: '1337' }); }); }); - describe('recordError()', function() { - it('warns if not an error', async function() { + describe('recordError()', function () { + it('warns if not an error', async function () { const orig = jet.context.console.warn; let logged = false; jet.context.console.warn = msg => { @@ -108,12 +108,12 @@ describe('crashlytics()', function() { should.equal(logged, true); }); - it('accepts Error values', async function() { + it('accepts Error values', async function () { firebase.crashlytics().recordError(new Error("I'm a teapot!")); // TODO verify stack obj }); - it('accepts optional jsErrorName', async function() { + it('accepts optional jsErrorName', async function () { firebase .crashlytics() .recordError( @@ -124,14 +124,14 @@ describe('crashlytics()', function() { }); }); - describe('sendUnsentReports()', function() { - it("sends unsent reports to the crashlytic's server", function() { + describe('sendUnsentReports()', function () { + it("sends unsent reports to the crashlytic's server", function () { firebase.crashlytics().sendUnsentReports(); }); }); - describe('checkForUnsentReports()', function() { - it('errors if automatic crash report collection is enabled', async function() { + describe('checkForUnsentReports()', function () { + it('errors if automatic crash report collection is enabled', async function () { await firebase.crashlytics().setCrashlyticsCollectionEnabled(true); try { await firebase.crashlytics().checkForUnsentReports(); @@ -140,7 +140,7 @@ describe('crashlytics()', function() { e.message.should.containEql("has been set to 'true', all reports are automatically sent"); } }); - it("checks device cache for unsent crashlytic's reports", async function() { + it("checks device cache for unsent crashlytic's reports", async function () { await firebase.crashlytics().setCrashlyticsCollectionEnabled(false); const anyUnsentReports = await firebase.crashlytics().checkForUnsentReports(); @@ -148,32 +148,32 @@ describe('crashlytics()', function() { }); }); - describe('deleteUnsentReports()', function() { - it('deletes unsent crashlytics reports', async function() { + describe('deleteUnsentReports()', function () { + it('deletes unsent crashlytics reports', async function () { await firebase.crashlytics().deleteUnsentReports(); }); }); - describe('didCrashOnPreviousExecution()', function() { - it('checks if app crached on previous execution', async function() { + describe('didCrashOnPreviousExecution()', function () { + it('checks if app crached on previous execution', async function () { const didCrash = await firebase.crashlytics().didCrashOnPreviousExecution(); should(didCrash).equal(false); }); }); - describe('setCrashlyticsCollectionEnabled()', function() { - it('true', async function() { + describe('setCrashlyticsCollectionEnabled()', function () { + it('true', async function () { await firebase.crashlytics().setCrashlyticsCollectionEnabled(true); should.equal(firebase.crashlytics().isCrashlyticsCollectionEnabled, true); }); - it('false', async function() { + it('false', async function () { await firebase.crashlytics().setCrashlyticsCollectionEnabled(false); should.equal(firebase.crashlytics().isCrashlyticsCollectionEnabled, false); }); - it('errors if not boolean', async function() { + it('errors if not boolean', async function () { try { await firebase.crashlytics().setCrashlyticsCollectionEnabled(1337); return Promise.reject(new Error('Did not throw.')); diff --git a/packages/crashlytics/lib/index.d.ts b/packages/crashlytics/lib/index.d.ts index 5c1497b6ff..9d51173a79 100644 --- a/packages/crashlytics/lib/index.d.ts +++ b/packages/crashlytics/lib/index.d.ts @@ -268,6 +268,7 @@ export default defaultExport; * Attach namespace to `firebase.` and `FirebaseApp.`. */ declare module '@react-native-firebase/app' { + // eslint-disable-next-line @typescript-eslint/no-unused-vars namespace ReactNativeFirebase { import FirebaseModuleWithStatics = ReactNativeFirebase.FirebaseModuleWithStatics; interface Module { diff --git a/packages/database/e2e/DatabaseStatics.e2e.js b/packages/database/e2e/DatabaseStatics.e2e.js index 2c2dc94eb6..d8b9cf073d 100644 --- a/packages/database/e2e/DatabaseStatics.e2e.js +++ b/packages/database/e2e/DatabaseStatics.e2e.js @@ -19,13 +19,13 @@ const { PATH, wipe } = require('./helpers'); const TEST_PATH = `${PATH}/statics`; -describe('database.X', function() { - after(function() { +describe('database.X', function () { + after(function () { return wipe(TEST_PATH); }); - describe('ServerValue.TIMESTAMP', function() { - it('returns a valid object', function() { + describe('ServerValue.TIMESTAMP', function () { + it('returns a valid object', function () { const { TIMESTAMP } = firebase.database.ServerValue; should.equal(Object.keys(TIMESTAMP).length, 1); TIMESTAMP.should.have.property('.sv'); @@ -33,15 +33,15 @@ describe('database.X', function() { }); }); - describe('ServerValue.increment', function() { - it('returns a valid object', function() { + describe('ServerValue.increment', function () { + it('returns a valid object', function () { const incrementObject = firebase.database.ServerValue.increment(1); should.equal(Object.keys(incrementObject).length, 1); incrementObject.should.have.property('.sv'); incrementObject['.sv'].should.have.property('increment'); }); - it('increments on the server', async function() { + it('increments on the server', async function () { const ref = firebase.database().ref(`${TEST_PATH}/increment`); await ref.set({ increment: 0 }); @@ -55,7 +55,7 @@ describe('database.X', function() { res2.val().increment.should.equal(1); }); - it('increments on the server when no value is present', async function() { + it('increments on the server when no value is present', async function () { const ref = firebase.database().ref(`${TEST_PATH}/increment-empty`); await ref.set({ increment: firebase.database.ServerValue.increment(2) }); diff --git a/packages/database/e2e/database.e2e.js b/packages/database/e2e/database.e2e.js index 34209aa1e2..0cb783e61e 100644 --- a/packages/database/e2e/database.e2e.js +++ b/packages/database/e2e/database.e2e.js @@ -15,43 +15,37 @@ * */ -describe('database()', function() { - describe('namespace', function() { - it('accessible from firebase.app()', function() { +describe('database()', function () { + describe('namespace', function () { + it('accessible from firebase.app()', function () { const app = firebase.app(); should.exist(app.database); app.database().app.should.eql(app); }); - it('supports multiple apps', async function() { + it('supports multiple apps', async function () { firebase.database().app.name.should.eql('[DEFAULT]'); firebase .database(firebase.app('secondaryFromNative')) .app.name.should.eql('secondaryFromNative'); - firebase - .app('secondaryFromNative') - .database() - .app.name.should.eql('secondaryFromNative'); + firebase.app('secondaryFromNative').database().app.name.should.eql('secondaryFromNative'); }); }); - it('supports custom database URL', async function() { + it('supports custom database URL', async function () { firebase.database().app.name.should.eql('[DEFAULT]'); firebase .database(firebase.app('secondaryFromNative')) .app.name.should.eql('secondaryFromNative'); - firebase - .app('secondaryFromNative') - .database() - .app.name.should.eql('secondaryFromNative'); + firebase.app('secondaryFromNative').database().app.name.should.eql('secondaryFromNative'); }); - describe('ref()', function() { - it('throws if path is not a string', async function() { + describe('ref()', function () { + it('throws if path is not a string', async function () { try { firebase.database().ref({ foo: 'bar' }); return Promise.reject(new Error('Did not throw an Error.')); @@ -61,7 +55,7 @@ describe('database()', function() { } }); - it('throws if path is not a valid string', async function() { + it('throws if path is not a valid string', async function () { try { firebase.database().ref('$$$$$'); return Promise.reject(new Error('Did not throw an Error.')); @@ -74,8 +68,8 @@ describe('database()', function() { }); }); - describe('refFromURL()', function() { - it('throws if url is not a url', async function() { + describe('refFromURL()', function () { + it('throws if url is not a url', async function () { try { firebase.database().refFromURL('foobar'); return Promise.reject(new Error('Did not throw an Error.')); @@ -85,7 +79,7 @@ describe('database()', function() { } }); - it('throws if url from a different domain', async function() { + it('throws if url from a different domain', async function () { try { firebase.database().refFromURL('https://foobar.firebaseio.com'); return Promise.reject(new Error('Did not throw an Error.')); @@ -95,7 +89,7 @@ describe('database()', function() { } }); - it('returns a reference', async function() { + it('returns a reference', async function () { const ref1 = firebase.database().refFromURL(firebase.database()._customUrlOrRegion); const ref2 = firebase .database() @@ -109,14 +103,14 @@ describe('database()', function() { }); }); - describe('goOnline()', function() { - it('calls goOnline successfully', async function() { + describe('goOnline()', function () { + it('calls goOnline successfully', async function () { await firebase.database().goOnline(); }); }); - describe('goOffline()', function() { - it('calls goOffline successfully', async function() { + describe('goOffline()', function () { + it('calls goOffline successfully', async function () { // await Utils.sleep(5000); await firebase.database().goOffline(); @@ -124,8 +118,8 @@ describe('database()', function() { }); }); - describe('setPersistenceEnabled()', function() { - it('throws if enabled is not a boolean', async function() { + describe('setPersistenceEnabled()', function () { + it('throws if enabled is not a boolean', async function () { try { firebase.database().setPersistenceEnabled('foo'); return Promise.reject(new Error('Did not throw an Error.')); @@ -135,14 +129,14 @@ describe('database()', function() { } }); - it('calls setPersistenceEnabled successfully', async function() { + it('calls setPersistenceEnabled successfully', async function () { firebase.database().setPersistenceEnabled(true); firebase.database().setPersistenceEnabled(false); }); }); - describe('setLoggingEnabled()', function() { - it('throws if enabled is not a boolean', async function() { + describe('setLoggingEnabled()', function () { + it('throws if enabled is not a boolean', async function () { try { firebase.database().setLoggingEnabled('foo'); return Promise.reject(new Error('Did not throw an Error.')); @@ -152,14 +146,14 @@ describe('database()', function() { } }); - it('calls setLoggingEnabled successfully', async function() { + it('calls setLoggingEnabled successfully', async function () { firebase.database().setLoggingEnabled(true); firebase.database().setLoggingEnabled(false); }); }); - describe('setPersistenceCacheSizeBytes()', function() { - it('throws if bytes is not a number', async function() { + describe('setPersistenceCacheSizeBytes()', function () { + it('throws if bytes is not a number', async function () { try { firebase.database().setPersistenceCacheSizeBytes('foo'); return Promise.reject(new Error('Did not throw an Error.')); @@ -169,7 +163,7 @@ describe('database()', function() { } }); - it('throws if bytes is less than 1MB', async function() { + it('throws if bytes is less than 1MB', async function () { try { firebase.database().setPersistenceCacheSizeBytes(1234); return Promise.reject(new Error('Did not throw an Error.')); @@ -179,7 +173,7 @@ describe('database()', function() { } }); - it('throws if bytes is greater than 10MB', async function() { + it('throws if bytes is greater than 10MB', async function () { try { firebase.database().setPersistenceCacheSizeBytes(100000000000000); return Promise.reject(new Error('Did not throw an Error.')); @@ -189,20 +183,20 @@ describe('database()', function() { } }); - it('calls setPersistenceCacheSizeBytes successfully', async function() { + it('calls setPersistenceCacheSizeBytes successfully', async function () { firebase.database().setPersistenceCacheSizeBytes(1048576); // 1mb }); }); - describe('getServerTime()', function() { - it('returns a valid date', async function() { + describe('getServerTime()', function () { + it('returns a valid date', async function () { const date = firebase.database().getServerTime(); date.getDate.should.be.Function(); }); }); - describe('handles invalid references()', function() { - it('returns a valid date', async function() { + describe('handles invalid references()', function () { + it('returns a valid date', async function () { try { firebase.database().ref('$'); return Promise.reject(new Error('Did not throw an Error.')); diff --git a/packages/database/e2e/helpers.js b/packages/database/e2e/helpers.js index 67a9205a2e..2291f04c5a 100644 --- a/packages/database/e2e/helpers.js +++ b/packages/database/e2e/helpers.js @@ -32,22 +32,13 @@ const CONTENT = { exports.seed = function seed(path) { return Promise.all([ - firebase - .database() - .ref(`${path}/types`) - .set(CONTENT.TYPES), - firebase - .database() - .ref(`${path}/query`) - .set(CONTENT.QUERY), + firebase.database().ref(`${path}/types`).set(CONTENT.TYPES), + firebase.database().ref(`${path}/query`).set(CONTENT.QUERY), ]); }; exports.wipe = function wipe(path) { - return firebase - .database() - .ref(path) - .remove(); + return firebase.database().ref(path).remove(); }; exports.PATH = PATH; diff --git a/packages/database/e2e/internal/connected.e2e.js b/packages/database/e2e/internal/connected.e2e.js index 0d5bbf446f..fb94346078 100644 --- a/packages/database/e2e/internal/connected.e2e.js +++ b/packages/database/e2e/internal/connected.e2e.js @@ -15,33 +15,24 @@ * */ -describe("database().ref('.info/connected')", function() { - after(function() { +describe("database().ref('.info/connected')", function () { + after(function () { return firebase.database().goOnline(); }); // FIXME needs a bug logged for triage - fails e2e testing on ios, android sometimes - xit('returns false when used with once', async function() { - const snapshot = await firebase - .database() - .ref('.info/connected') - .once('value'); + xit('returns false when used with once', async function () { + const snapshot = await firebase.database().ref('.info/connected').once('value'); snapshot.val().should.equal(false); }); - it('returns true when used with once with a previous call', async function() { - await firebase - .database() - .ref('tests') - .once('value'); - const snapshot = await firebase - .database() - .ref('.info/connected') - .once('value'); + it('returns true when used with once with a previous call', async function () { + await firebase.database().ref('tests').once('value'); + const snapshot = await firebase.database().ref('.info/connected').once('value'); snapshot.val().should.equal(true); }); - it('subscribes to online state', async function() { + it('subscribes to online state', async function () { const callback = sinon.spy(); await firebase.database().goOffline(); diff --git a/packages/database/e2e/internal/serverTimeOffset.e2e.js b/packages/database/e2e/internal/serverTimeOffset.e2e.js index 57913797e9..d4b7f86b20 100644 --- a/packages/database/e2e/internal/serverTimeOffset.e2e.js +++ b/packages/database/e2e/internal/serverTimeOffset.e2e.js @@ -15,12 +15,9 @@ * */ -describe("database().ref('.info/serverTimeOffset')", function() { - it('returns a valid number value', async function() { - const snapshot = await firebase - .database() - .ref('.info/serverTimeOffset') - .once('value'); +describe("database().ref('.info/serverTimeOffset')", function () { + it('returns a valid number value', async function () { + const snapshot = await firebase.database().ref('.info/serverTimeOffset').once('value'); should.equal(typeof snapshot.val(), 'number'); }); diff --git a/packages/database/e2e/issues.e2e.js b/packages/database/e2e/issues.e2e.js index cd5d002c75..35a77f5387 100644 --- a/packages/database/e2e/issues.e2e.js +++ b/packages/database/e2e/issues.e2e.js @@ -19,12 +19,12 @@ const { PATH, wipe } = require('./helpers'); const TEST_PATH = `${PATH}/issues`; -describe('database issues', function() { - after(function() { +describe('database issues', function () { + after(function () { return wipe(TEST_PATH); }); - it('#2813 should return a null snapshot key if path is root', async function() { + it('#2813 should return a null snapshot key if path is root', async function () { const ref = firebase .app() .database('https://react-native-firebase-testing-db2.firebaseio.com') @@ -33,7 +33,7 @@ describe('database issues', function() { should.equal(snapshot.key, null); }); - it('#2833 should not mutate modifiers ordering', async function() { + it('#2833 should not mutate modifiers ordering', async function () { const callback = sinon.spy(); const testRef = firebase .database() @@ -54,7 +54,7 @@ describe('database issues', function() { testRef.off('value'); }); - it('#100 array should return null where key is missing', async function() { + it('#100 array should return null where key is missing', async function () { const ref = firebase.database().ref(`${TEST_PATH}/issue_100`); const data = { @@ -87,8 +87,8 @@ describe('database issues', function() { ); }); - describe('#108 filters correctly by float values', function() { - it('returns filtered results', async function() { + describe('#108 filters correctly by float values', function () { + it('returns filtered results', async function () { const ref = firebase.database().ref(`${TEST_PATH}/issue_108/filter`); const data = { @@ -119,7 +119,7 @@ describe('database issues', function() { should.equal(Object.keys(val).length, 1); }); - it('returns correct results when not using float values', async function() { + it('returns correct results when not using float values', async function () { const ref = firebase.database().ref(`${TEST_PATH}/issue_108/integer`); const data = { @@ -138,10 +138,7 @@ describe('database issues', function() { }; await ref.set(data); - const snapshot = await ref - .orderByChild('latitude') - .equalTo(37) - .once('value'); + const snapshot = await ref.orderByChild('latitude').equalTo(37).once('value'); const val = snapshot.val(); @@ -151,7 +148,7 @@ describe('database issues', function() { }); }); - it('#489 reutrns long numbers correctly', async function() { + it('#489 reutrns long numbers correctly', async function () { const LONG = 1508777379000; const ref = firebase.database().ref(`${TEST_PATH}/issue_489`); await ref.set(LONG); diff --git a/packages/database/e2e/onDisconnect/cancel.e2e.js b/packages/database/e2e/onDisconnect/cancel.e2e.js index 9c53a929ce..1f582cfdb2 100644 --- a/packages/database/e2e/onDisconnect/cancel.e2e.js +++ b/packages/database/e2e/onDisconnect/cancel.e2e.js @@ -19,21 +19,18 @@ const { PATH, wipe } = require('../helpers'); const TEST_PATH = `${PATH}/onDisconnectCancel`; -describe('database().ref().onDisconnect().cancel()', function() { - after(function() { +describe('database().ref().onDisconnect().cancel()', function () { + after(function () { return wipe(TEST_PATH); }); - afterEach(function() { + afterEach(function () { // Ensures the db is online before running each test firebase.database().goOnline(); }); - it('throws if onComplete is not a function', function() { - const ref = firebase - .database() - .ref(TEST_PATH) - .onDisconnect(); + it('throws if onComplete is not a function', function () { + const ref = firebase.database().ref(TEST_PATH).onDisconnect(); try { ref.cancel('foo'); return Promise.reject(new Error('Did not throw an Error.')); @@ -43,7 +40,7 @@ describe('database().ref().onDisconnect().cancel()', function() { } }); - it('cancels all previously queued events', async function() { + it('cancels all previously queued events', async function () { const ref = firebase.database().ref(TEST_PATH); await ref.set('foobar'); @@ -58,7 +55,7 @@ describe('database().ref().onDisconnect().cancel()', function() { snapshot.val().should.eql('foobar'); }); - it('calls back to the onComplete function', async function() { + it('calls back to the onComplete function', async function () { const callback = sinon.spy(); const ref = firebase.database().ref(TEST_PATH); diff --git a/packages/database/e2e/onDisconnect/remove.e2e.js b/packages/database/e2e/onDisconnect/remove.e2e.js index 95bb82f173..21b635b3c9 100644 --- a/packages/database/e2e/onDisconnect/remove.e2e.js +++ b/packages/database/e2e/onDisconnect/remove.e2e.js @@ -19,21 +19,18 @@ const { PATH, wipe } = require('../helpers'); const TEST_PATH = `${PATH}/onDisconnectRemove`; -describe('database().ref().onDisconnect().remove()', function() { - after(function() { +describe('database().ref().onDisconnect().remove()', function () { + after(function () { return wipe(TEST_PATH); }); - afterEach(function() { + afterEach(function () { // Ensures the db is online before running each test firebase.database().goOnline(); }); - it('throws if onComplete is not a function', function() { - const ref = firebase - .database() - .ref(TEST_PATH) - .onDisconnect(); + it('throws if onComplete is not a function', function () { + const ref = firebase.database().ref(TEST_PATH).onDisconnect(); try { ref.remove('foo'); return Promise.reject(new Error('Did not throw an Error.')); @@ -43,11 +40,8 @@ describe('database().ref().onDisconnect().remove()', function() { } }); - it('removes a node whilst offline', async function() { - const ref = firebase - .database() - .ref(TEST_PATH) - .child('removeMe'); + it('removes a node whilst offline', async function () { + const ref = firebase.database().ref(TEST_PATH).child('removeMe'); await ref.set('foobar'); @@ -59,12 +53,9 @@ describe('database().ref().onDisconnect().remove()', function() { snapshot.exists().should.eql(false); }); - it('calls back to the onComplete function', async function() { + it('calls back to the onComplete function', async function () { const callback = sinon.spy(); - const ref = firebase - .database() - .ref(TEST_PATH) - .child('removeMe'); + const ref = firebase.database().ref(TEST_PATH).child('removeMe'); // Set an initial value await ref.set('foo'); diff --git a/packages/database/e2e/onDisconnect/set.e2e.js b/packages/database/e2e/onDisconnect/set.e2e.js index 6de9e3d4a5..158cda139f 100644 --- a/packages/database/e2e/onDisconnect/set.e2e.js +++ b/packages/database/e2e/onDisconnect/set.e2e.js @@ -19,21 +19,18 @@ const { PATH, wipe } = require('../helpers'); const TEST_PATH = `${PATH}/onDisconnectSet`; -describe('database().ref().onDisconnect().set()', function() { - after(function() { +describe('database().ref().onDisconnect().set()', function () { + after(function () { return wipe(TEST_PATH); }); - afterEach(function() { + afterEach(function () { // Ensures the db is online before running each test firebase.database().goOnline(); }); - it('throws if value is not a defined', function() { - const ref = firebase - .database() - .ref(TEST_PATH) - .onDisconnect(); + it('throws if value is not a defined', function () { + const ref = firebase.database().ref(TEST_PATH).onDisconnect(); try { ref.set(); return Promise.reject(new Error('Did not throw an Error.')); @@ -43,11 +40,8 @@ describe('database().ref().onDisconnect().set()', function() { } }); - it('throws if onComplete is not a function', function() { - const ref = firebase - .database() - .ref(TEST_PATH) - .onDisconnect(); + it('throws if onComplete is not a function', function () { + const ref = firebase.database().ref(TEST_PATH).onDisconnect(); try { ref.set(null, 'foo'); return Promise.reject(new Error('Did not throw an Error.')); @@ -57,7 +51,7 @@ describe('database().ref().onDisconnect().set()', function() { } }); - it('sets value when disconnected', async function() { + it('sets value when disconnected', async function () { const ref = firebase.database().ref(TEST_PATH); const value = Date.now(); @@ -70,7 +64,7 @@ describe('database().ref().onDisconnect().set()', function() { snapshot.val().should.eql(value); }); - it('calls back to the onComplete function', async function() { + it('calls back to the onComplete function', async function () { const callback = sinon.spy(); const ref = firebase.database().ref(TEST_PATH); diff --git a/packages/database/e2e/onDisconnect/setWithPriority.e2e.js b/packages/database/e2e/onDisconnect/setWithPriority.e2e.js index 9d9420dd2d..e063f01750 100644 --- a/packages/database/e2e/onDisconnect/setWithPriority.e2e.js +++ b/packages/database/e2e/onDisconnect/setWithPriority.e2e.js @@ -19,21 +19,18 @@ const { PATH, wipe } = require('../helpers'); const TEST_PATH = `${PATH}/onDisconnectSetWithPriority`; -describe('database().ref().onDisconnect().setWithPriority()', function() { - after(function() { +describe('database().ref().onDisconnect().setWithPriority()', function () { + after(function () { return wipe(TEST_PATH); }); - afterEach(function() { + afterEach(function () { // Ensures the db is online before running each test firebase.database().goOnline(); }); - it('throws if value is not a defined', function() { - const ref = firebase - .database() - .ref(TEST_PATH) - .onDisconnect(); + it('throws if value is not a defined', function () { + const ref = firebase.database().ref(TEST_PATH).onDisconnect(); try { ref.setWithPriority(); return Promise.reject(new Error('Did not throw an Error.')); @@ -43,11 +40,8 @@ describe('database().ref().onDisconnect().setWithPriority()', function() { } }); - it('throws if priority is not a valid type', function() { - const ref = firebase - .database() - .ref(TEST_PATH) - .onDisconnect(); + it('throws if priority is not a valid type', function () { + const ref = firebase.database().ref(TEST_PATH).onDisconnect(); try { ref.setWithPriority(null, { foo: 'bar' }); return Promise.reject(new Error('Did not throw an Error.')); @@ -57,11 +51,8 @@ describe('database().ref().onDisconnect().setWithPriority()', function() { } }); - it('throws if onComplete is not a function', function() { - const ref = firebase - .database() - .ref(TEST_PATH) - .onDisconnect(); + it('throws if onComplete is not a function', function () { + const ref = firebase.database().ref(TEST_PATH).onDisconnect(); try { ref.setWithPriority(null, 1, 'foo'); return Promise.reject(new Error('Did not throw an Error.')); @@ -71,7 +62,7 @@ describe('database().ref().onDisconnect().setWithPriority()', function() { } }); - it('sets value with priority when disconnected', async function() { + it('sets value with priority when disconnected', async function () { const ref = firebase.database().ref(TEST_PATH); const value = Date.now(); @@ -85,7 +76,7 @@ describe('database().ref().onDisconnect().setWithPriority()', function() { snapshot.exportVal()['.priority'].should.eql(3); }); - it('calls back to the onComplete function', async function() { + it('calls back to the onComplete function', async function () { const callback = sinon.spy(); const ref = firebase.database().ref(TEST_PATH); diff --git a/packages/database/e2e/onDisconnect/update.e2e.js b/packages/database/e2e/onDisconnect/update.e2e.js index e5cec8df7d..f8014ba488 100644 --- a/packages/database/e2e/onDisconnect/update.e2e.js +++ b/packages/database/e2e/onDisconnect/update.e2e.js @@ -19,23 +19,19 @@ const { PATH, wipe } = require('../helpers'); const TEST_PATH = `${PATH}/onDisconnectUpdate`; -describe('database().ref().onDisconnect().update()', function() { - after(function() { +describe('database().ref().onDisconnect().update()', function () { + after(function () { return wipe(TEST_PATH); }); - afterEach(function() { + afterEach(function () { // Ensures the db is online before running each test firebase.database().goOnline(); }); - it('throws if values is not an object', async function() { + it('throws if values is not an object', async function () { try { - await firebase - .database() - .ref(TEST_PATH) - .onDisconnect() - .update('foo'); + await firebase.database().ref(TEST_PATH).onDisconnect().update('foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'values' must be an object"); @@ -43,13 +39,9 @@ describe('database().ref().onDisconnect().update()', function() { } }); - it('throws if values does not contain any values', async function() { + it('throws if values does not contain any values', async function () { try { - await firebase - .database() - .ref(TEST_PATH) - .onDisconnect() - .update({}); + await firebase.database().ref(TEST_PATH).onDisconnect().update({}); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'values' must be an object containing multiple values"); @@ -57,15 +49,11 @@ describe('database().ref().onDisconnect().update()', function() { } }); - it('throws if update paths are not valid', async function() { + it('throws if update paths are not valid', async function () { try { - await firebase - .database() - .ref(TEST_PATH) - .onDisconnect() - .update({ - $$$$: 'foo', - }); + await firebase.database().ref(TEST_PATH).onDisconnect().update({ + $$$$: 'foo', + }); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'values' contains an invalid path."); @@ -73,11 +61,8 @@ describe('database().ref().onDisconnect().update()', function() { } }); - it('throws if onComplete is not a function', function() { - const ref = firebase - .database() - .ref(TEST_PATH) - .onDisconnect(); + it('throws if onComplete is not a function', function () { + const ref = firebase.database().ref(TEST_PATH).onDisconnect(); try { ref.update({ foo: 'bar' }, 'foo'); return Promise.reject(new Error('Did not throw an Error.')); @@ -87,7 +72,7 @@ describe('database().ref().onDisconnect().update()', function() { } }); - it('updates value when disconnected', async function() { + it('updates value when disconnected', async function () { const ref = firebase.database().ref(TEST_PATH); const value = Date.now(); @@ -97,12 +82,9 @@ describe('database().ref().onDisconnect().update()', function() { }, }); - await ref - .child('foo') - .onDisconnect() - .update({ - bar: value, - }); + await ref.child('foo').onDisconnect().update({ + bar: value, + }); await firebase.database().goOffline(); await firebase.database().goOnline(); @@ -114,7 +96,7 @@ describe('database().ref().onDisconnect().update()', function() { ); }); - it('calls back to the onComplete function', async function() { + it('calls back to the onComplete function', async function () { const callback = sinon.spy(); const ref = firebase.database().ref(TEST_PATH); diff --git a/packages/database/e2e/query/endAt.e2e.js b/packages/database/e2e/query/endAt.e2e.js index 42ae0d3fe1..9d5df6b870 100644 --- a/packages/database/e2e/query/endAt.e2e.js +++ b/packages/database/e2e/query/endAt.e2e.js @@ -19,20 +19,17 @@ const { PATH, seed, wipe } = require('../helpers'); const TEST_PATH = `${PATH}/endAt`; -describe('database().ref().endAt()', function() { - before(function() { +describe('database().ref().endAt()', function () { + before(function () { return seed(TEST_PATH); }); - after(function() { + after(function () { return wipe(TEST_PATH); }); - it('throws if an value is undefined', async function() { + it('throws if an value is undefined', async function () { try { - await firebase - .database() - .ref() - .endAt(); + await firebase.database().ref().endAt(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'value' must be a number, string, boolean or null value"); @@ -40,12 +37,9 @@ describe('database().ref().endAt()', function() { } }); - it('throws if an key is not a string', async function() { + it('throws if an key is not a string', async function () { try { - await firebase - .database() - .ref() - .endAt('foo', 1234); + await firebase.database().ref().endAt('foo', 1234); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'key' must be a string value if defined"); @@ -53,13 +47,9 @@ describe('database().ref().endAt()', function() { } }); - it('throws if a ending point has already been set', async function() { + it('throws if a ending point has already been set', async function () { try { - await firebase - .database() - .ref() - .equalTo('foo') - .endAt('foo'); + await firebase.database().ref().equalTo('foo').endAt('foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -69,13 +59,9 @@ describe('database().ref().endAt()', function() { } }); - it('throws if ordering by key and the key param is set', async function() { + it('throws if ordering by key and the key param is set', async function () { try { - await firebase - .database() - .ref() - .orderByKey('foo') - .endAt('foo', 'bar'); + await firebase.database().ref().orderByKey('foo').endAt('foo', 'bar'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -85,13 +71,9 @@ describe('database().ref().endAt()', function() { } }); - it('throws if ordering by key and the value param is not a string', async function() { + it('throws if ordering by key and the value param is not a string', async function () { try { - await firebase - .database() - .ref() - .orderByKey('foo') - .endAt(123); + await firebase.database().ref().orderByKey('foo').endAt(123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -101,13 +83,9 @@ describe('database().ref().endAt()', function() { } }); - it('throws if ordering by priority and the value param is not priority type', async function() { + it('throws if ordering by priority and the value param is not priority type', async function () { try { - await firebase - .database() - .ref() - .orderByPriority() - .endAt(true); + await firebase.database().ref().orderByPriority().endAt(true); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -117,7 +95,7 @@ describe('database().ref().endAt()', function() { } }); - it('snapshot value returns all when no ordering modifier is applied', async function() { + it('snapshot value returns all when no ordering modifier is applied', async function () { const ref = firebase.database().ref(TEST_PATH); await ref.set({ @@ -136,7 +114,7 @@ describe('database().ref().endAt()', function() { }); }); - it('ends at the correct value', async function() { + it('ends at the correct value', async function () { const ref = firebase.database().ref(TEST_PATH); await ref.set({ @@ -146,10 +124,7 @@ describe('database().ref().endAt()', function() { d: 4, }); - const snapshot = await ref - .orderByValue() - .endAt(2) - .once('value'); + const snapshot = await ref.orderByValue().endAt(2).once('value'); const expected = ['a', 'b']; diff --git a/packages/database/e2e/query/equalTo.e2e.js b/packages/database/e2e/query/equalTo.e2e.js index 67394a7653..ed66947eef 100644 --- a/packages/database/e2e/query/equalTo.e2e.js +++ b/packages/database/e2e/query/equalTo.e2e.js @@ -19,20 +19,17 @@ const { PATH, seed, wipe } = require('../helpers'); const TEST_PATH = `${PATH}/equalTo`; -describe('database().ref().equalTo()', function() { - before(function() { +describe('database().ref().equalTo()', function () { + before(function () { return seed(TEST_PATH); }); - after(function() { + after(function () { return wipe(TEST_PATH); }); - it('throws if value is not a valid type', async function() { + it('throws if value is not a valid type', async function () { try { - await firebase - .database() - .ref() - .equalTo({ foo: 'bar' }); + await firebase.database().ref().equalTo({ foo: 'bar' }); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'value' must be a number, string, boolean or null value"); @@ -40,12 +37,9 @@ describe('database().ref().equalTo()', function() { } }); - it('throws if key is not a string', async function() { + it('throws if key is not a string', async function () { try { - await firebase - .database() - .ref() - .equalTo('bar', 123); + await firebase.database().ref().equalTo('bar', 123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'key' must be a string value if defined"); @@ -53,13 +47,9 @@ describe('database().ref().equalTo()', function() { } }); - it('throws if a starting point has already been set', async function() { + it('throws if a starting point has already been set', async function () { try { - await firebase - .database() - .ref() - .startAt('foo') - .equalTo('bar'); + await firebase.database().ref().startAt('foo').equalTo('bar'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -69,13 +59,9 @@ describe('database().ref().equalTo()', function() { } }); - it('throws if a ending point has already been set', async function() { + it('throws if a ending point has already been set', async function () { try { - await firebase - .database() - .ref() - .endAt('foo') - .equalTo('bar'); + await firebase.database().ref().endAt('foo').equalTo('bar'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -85,7 +71,7 @@ describe('database().ref().equalTo()', function() { } }); - it('snapshot value is null when no ordering modifier is applied', async function() { + it('snapshot value is null when no ordering modifier is applied', async function () { const ref = firebase.database().ref(TEST_PATH); await ref.set({ @@ -99,7 +85,7 @@ describe('database().ref().equalTo()', function() { should.equal(snapshot.val(), null); }); - it('returns the correct equal to values', async function() { + it('returns the correct equal to values', async function () { const ref = firebase.database().ref(TEST_PATH); await ref.set({ @@ -110,10 +96,7 @@ describe('database().ref().equalTo()', function() { e: 2, }); - const snapshot = await ref - .orderByValue() - .equalTo(2) - .once('value'); + const snapshot = await ref.orderByValue().equalTo(2).once('value'); const expected = ['b', 'e']; diff --git a/packages/database/e2e/query/isEqual.e2e.js b/packages/database/e2e/query/isEqual.e2e.js index 595ab5261a..199d9093ff 100644 --- a/packages/database/e2e/query/isEqual.e2e.js +++ b/packages/database/e2e/query/isEqual.e2e.js @@ -15,13 +15,10 @@ * */ -describe('database().ref().isEqual()', function() { - it('throws if limit other param is not a query instance', async function() { +describe('database().ref().isEqual()', function () { + it('throws if limit other param is not a query instance', async function () { try { - await firebase - .database() - .ref() - .isEqual('foo'); + await firebase.database().ref().isEqual('foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'other' must be an instance of Query."); @@ -29,33 +26,22 @@ describe('database().ref().isEqual()', function() { } }); - it('returns true if the query is the same instance', async function() { + it('returns true if the query is the same instance', async function () { const query = await firebase.database().ref(); const same = query.isEqual(query); same.should.eql(true); }); - it('returns false if the query is different', async function() { + it('returns false if the query is different', async function () { const query = await firebase.database().ref(); - const other = await firebase - .database() - .ref() - .limitToLast(2); + const other = await firebase.database().ref().limitToLast(2); const same = query.isEqual(other); same.should.eql(false); }); - it('returns true if the query is created differently', async function() { - const query = await firebase - .database() - .ref() - .limitToFirst(1) - .orderByChild('foo'); - const other = await firebase - .database() - .ref() - .orderByChild('foo') - .limitToFirst(1); + it('returns true if the query is created differently', async function () { + const query = await firebase.database().ref().limitToFirst(1).orderByChild('foo'); + const other = await firebase.database().ref().orderByChild('foo').limitToFirst(1); const same = query.isEqual(other); same.should.eql(true); }); diff --git a/packages/database/e2e/query/keepSynced.e2e.js b/packages/database/e2e/query/keepSynced.e2e.js index 726b3f9ec4..c567b54d35 100644 --- a/packages/database/e2e/query/keepSynced.e2e.js +++ b/packages/database/e2e/query/keepSynced.e2e.js @@ -15,13 +15,10 @@ * */ -describe('database().ref().keepSynced()', function() { - it('throws if bool is not a valid type', async function() { +describe('database().ref().keepSynced()', function () { + it('throws if bool is not a valid type', async function () { try { - await firebase - .database() - .ref() - .keepSynced('foo'); + await firebase.database().ref().keepSynced('foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'bool' value must be a boolean value."); @@ -29,11 +26,8 @@ describe('database().ref().keepSynced()', function() { } }); - it('toggles keepSynced on and off without throwing', async function() { - const ref = firebase - .database() - .ref('noop') - .orderByValue(); + it('toggles keepSynced on and off without throwing', async function () { + const ref = firebase.database().ref('noop').orderByValue(); await ref.keepSynced(true); await ref.keepSynced(false); }); diff --git a/packages/database/e2e/query/limitToFirst.e2e.js b/packages/database/e2e/query/limitToFirst.e2e.js index 939eef631d..2046054009 100644 --- a/packages/database/e2e/query/limitToFirst.e2e.js +++ b/packages/database/e2e/query/limitToFirst.e2e.js @@ -19,20 +19,17 @@ const { PATH, seed, wipe } = require('../helpers'); const TEST_PATH = `${PATH}/limitToFirst`; -describe('database().ref().limitToFirst()', function() { - before(function() { +describe('database().ref().limitToFirst()', function () { + before(function () { return seed(TEST_PATH); }); - after(function() { + after(function () { return wipe(TEST_PATH); }); - it('throws if limit is invalid', async function() { + it('throws if limit is invalid', async function () { try { - await firebase - .database() - .ref() - .limitToFirst('foo'); + await firebase.database().ref().limitToFirst('foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'limit' must be a positive integer value"); @@ -40,13 +37,9 @@ describe('database().ref().limitToFirst()', function() { } }); - it('throws if limit has already been set', async function() { + it('throws if limit has already been set', async function () { try { - await firebase - .database() - .ref() - .limitToLast(2) - .limitToFirst(3); + await firebase.database().ref().limitToLast(2).limitToFirst(3); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -56,7 +49,7 @@ describe('database().ref().limitToFirst()', function() { } }); - it('returns a limited array data set', async function() { + it('returns a limited array data set', async function () { const ref = firebase.database().ref(`${TEST_PATH}`); const initial = { @@ -76,7 +69,7 @@ describe('database().ref().limitToFirst()', function() { }); }); - it('returns a limited object data set', async function() { + it('returns a limited object data set', async function () { const ref = firebase.database().ref(`${TEST_PATH}`); const initial = { @@ -101,7 +94,7 @@ describe('database().ref().limitToFirst()', function() { }); }); - it('returns a null value when not possible to limit', async function() { + it('returns a null value when not possible to limit', async function () { const ref = firebase.database().ref(`${TEST_PATH}`); const initial = 'foo'; diff --git a/packages/database/e2e/query/limitToLast.e2e.js b/packages/database/e2e/query/limitToLast.e2e.js index 40a99bee7f..32fe9707a5 100644 --- a/packages/database/e2e/query/limitToLast.e2e.js +++ b/packages/database/e2e/query/limitToLast.e2e.js @@ -19,20 +19,17 @@ const { PATH, seed, wipe } = require('../helpers'); const TEST_PATH = `${PATH}/limitToLast`; -describe('database().ref().limitToLast()', function() { - before(function() { +describe('database().ref().limitToLast()', function () { + before(function () { return seed(TEST_PATH); }); - after(function() { + after(function () { return wipe(TEST_PATH); }); - it('throws if limit is invalid', async function() { + it('throws if limit is invalid', async function () { try { - await firebase - .database() - .ref() - .limitToLast('foo'); + await firebase.database().ref().limitToLast('foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'limit' must be a positive integer value"); @@ -40,13 +37,9 @@ describe('database().ref().limitToLast()', function() { } }); - it('throws if limit has already been set', async function() { + it('throws if limit has already been set', async function () { try { - await firebase - .database() - .ref() - .limitToFirst(3) - .limitToLast(2); + await firebase.database().ref().limitToFirst(3).limitToLast(2); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -56,7 +49,7 @@ describe('database().ref().limitToLast()', function() { } }); - it('returns a limited array data set', async function() { + it('returns a limited array data set', async function () { const ref = firebase.database().ref(`${TEST_PATH}`); const initial = { @@ -76,7 +69,7 @@ describe('database().ref().limitToLast()', function() { }); }); - it('returns a limited object data set', async function() { + it('returns a limited object data set', async function () { const ref = firebase.database().ref(`${TEST_PATH}`); const initial = { @@ -101,7 +94,7 @@ describe('database().ref().limitToLast()', function() { }); }); - it('returns a null value when not possible to limit', async function() { + it('returns a null value when not possible to limit', async function () { const ref = firebase.database().ref(`${TEST_PATH}`); const initial = 'foo'; diff --git a/packages/database/e2e/query/on.e2e.js b/packages/database/e2e/query/on.e2e.js index 0ba30a26aa..d19136007c 100644 --- a/packages/database/e2e/query/on.e2e.js +++ b/packages/database/e2e/query/on.e2e.js @@ -20,13 +20,10 @@ const { PATH } = require('../helpers'); const TEST_PATH = `${PATH}/on`; // TODO flakey on CI - improve database paths so no current test conflicts & remove sleep util usage -xdescribe('database().ref().on()', function() { - it('throws if event type is invalid', async function() { +xdescribe('database().ref().on()', function () { + it('throws if event type is invalid', async function () { try { - await firebase - .database() - .ref() - .on('foo'); + await firebase.database().ref().on('foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'eventType' must be one of"); @@ -34,12 +31,9 @@ xdescribe('database().ref().on()', function() { } }); - it('throws if callback is not a function', async function() { + it('throws if callback is not a function', async function () { try { - await firebase - .database() - .ref() - .on('value', 'foo'); + await firebase.database().ref().on('value', 'foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'callback' must be a function"); @@ -47,7 +41,7 @@ xdescribe('database().ref().on()', function() { } }); - it('throws if cancel callback is not a function', async function() { + it('throws if cancel callback is not a function', async function () { try { await firebase .database() @@ -60,7 +54,7 @@ xdescribe('database().ref().on()', function() { } }); - it('throws if context is not an object', async function() { + it('throws if context is not an object', async function () { try { await firebase .database() @@ -78,7 +72,7 @@ xdescribe('database().ref().on()', function() { } }); // TODO test flakey on CI - swap out Util.sleep - xit('should callback with an initial value', async function() { + xit('should callback with an initial value', async function () { const callback = sinon.spy(); const ref = firebase.database().ref(`${TEST_PATH}/init`); const value = Date.now(); @@ -95,7 +89,7 @@ xdescribe('database().ref().on()', function() { ref.off('value'); }); - it('should callback multiple times when the value changes', async function() { + it('should callback multiple times when the value changes', async function () { const callback = sinon.spy(); const ref = firebase.database().ref(`${TEST_PATH}/changes`); await ref.set('foo'); @@ -114,7 +108,7 @@ xdescribe('database().ref().on()', function() { callback.getCall(1).args[0].should.equal('bar'); }); - it('should cancel when something goes wrong', async function() { + it('should cancel when something goes wrong', async function () { const successCallback = sinon.spy(); const cancelCallback = sinon.spy(); const ref = firebase.database().ref('nope'); @@ -138,7 +132,7 @@ xdescribe('database().ref().on()', function() { cancelCallback.should.be.calledOnce(); }); - it('subscribe to child added events', async function() { + it('subscribe to child added events', async function () { const successCallback = sinon.spy(); const cancelCallback = sinon.spy(); const ref = firebase.database().ref(`${TEST_PATH}/childAdded`); @@ -164,7 +158,7 @@ xdescribe('database().ref().on()', function() { cancelCallback.should.be.callCount(0); }); - it('subscribe to child changed events', async function() { + it('subscribe to child changed events', async function () { const successCallback = sinon.spy(); const cancelCallback = sinon.spy(); const ref = firebase.database().ref(`${TEST_PATH}/childChanged`); @@ -195,7 +189,7 @@ xdescribe('database().ref().on()', function() { cancelCallback.should.be.callCount(0); }); - it('subscribe to child removed events', async function() { + it('subscribe to child removed events', async function () { const successCallback = sinon.spy(); const cancelCallback = sinon.spy(); const ref = firebase.database().ref(`${TEST_PATH}/childRemoved`); @@ -221,7 +215,7 @@ xdescribe('database().ref().on()', function() { cancelCallback.should.be.callCount(0); }); - it('subscribe to child moved events', async function() { + it('subscribe to child moved events', async function () { const callback = sinon.spy(); const ref = firebase.database().ref(`${TEST_PATH}/childMoved`); const orderedRef = ref.orderByChild('nuggets'); diff --git a/packages/database/e2e/query/once.e2e.js b/packages/database/e2e/query/once.e2e.js index fb5a073500..65ab9700b5 100644 --- a/packages/database/e2e/query/once.e2e.js +++ b/packages/database/e2e/query/once.e2e.js @@ -20,20 +20,17 @@ const { PATH, CONTENT, seed, wipe } = require('../helpers'); const TEST_PATH = `${PATH}/once`; // TODO flakey on CI - improve database paths so no current test conflicts & remove sleep util usage -describe('database().ref().once()', function() { - before(function() { +describe('database().ref().once()', function () { + before(function () { return seed(TEST_PATH); }); - after(function() { + after(function () { return wipe(TEST_PATH); }); - it('throws if event type is invalid', async function() { + it('throws if event type is invalid', async function () { try { - await firebase - .database() - .ref() - .once('foo'); + await firebase.database().ref().once('foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'eventType' must be one of"); @@ -41,12 +38,9 @@ describe('database().ref().once()', function() { } }); - it('throws if success callback is not a function', async function() { + it('throws if success callback is not a function', async function () { try { - await firebase - .database() - .ref() - .once('value', 'foo'); + await firebase.database().ref().once('value', 'foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'successCallBack' must be a function"); @@ -54,7 +48,7 @@ describe('database().ref().once()', function() { } }); - it('throws if failure callback is not a function', async function() { + it('throws if failure callback is not a function', async function () { try { await firebase .database() @@ -67,7 +61,7 @@ describe('database().ref().once()', function() { } }); - it('throws if context is not an object', async function() { + it('throws if context is not an object', async function () { try { await firebase .database() @@ -85,13 +79,13 @@ describe('database().ref().once()', function() { } }); - it('returns a promise', async function() { + it('returns a promise', async function () { const ref = firebase.database().ref('tests/types/number'); const returnValue = ref.once('value'); returnValue.should.be.Promise(); }); - it('resolves with the correct values', async function() { + it('resolves with the correct values', async function () { const ref = firebase.database().ref(`${TEST_PATH}/types`); await Promise.all( @@ -103,7 +97,7 @@ describe('database().ref().once()', function() { ); }); - it('is is called when the value is changed', async function() { + it('is is called when the value is changed', async function () { const callback = sinon.spy(); const ref = firebase.database().ref(`${TEST_PATH}/types/number`); ref.once('value').then(callback); @@ -111,7 +105,7 @@ describe('database().ref().once()', function() { callback.should.be.calledOnce(); }); - it('errors if permission denied', async function() { + it('errors if permission denied', async function () { const ref = firebase.database().ref('nope'); try { await ref.once('value'); @@ -122,7 +116,7 @@ describe('database().ref().once()', function() { } }); - it('it calls when a child is added', async function() { + it('it calls when a child is added', async function () { const value = Date.now(); const callback = sinon.spy(); const ref = firebase.database().ref(`${TEST_PATH}/childAdded`); @@ -135,7 +129,7 @@ describe('database().ref().once()', function() { callback.should.be.calledWith(value); }); - it('resolves when a child is changed', async function() { + it('resolves when a child is changed', async function () { const callback = sinon.spy(); const ref = firebase.database().ref(`${TEST_PATH}/childChanged`); @@ -148,7 +142,7 @@ describe('database().ref().once()', function() { callback.should.be.calledWith(2); }); - it('resolves when a child is removed', async function() { + it('resolves when a child is removed', async function () { const callback = sinon.spy(); const ref = firebase.database().ref(`${TEST_PATH}/childRemoved`); const child = ref.child('removeme'); @@ -164,7 +158,7 @@ describe('database().ref().once()', function() { }); // https://github.com/firebase/firebase-js-sdk/blob/6b53e0058483c9002d2fe56119f86fc9fb96b56c/packages/database/test/order_by.test.ts#L104 - it('resolves when a child is moved', async function() { + it('resolves when a child is moved', async function () { const callback = sinon.spy(); const ref = firebase.database().ref(`${TEST_PATH}/childMoved`); const orderedRef = ref.orderByChild('nuggets'); diff --git a/packages/database/e2e/query/orderByChild.e2e.js b/packages/database/e2e/query/orderByChild.e2e.js index 52cd492257..a15fe279bf 100644 --- a/packages/database/e2e/query/orderByChild.e2e.js +++ b/packages/database/e2e/query/orderByChild.e2e.js @@ -19,20 +19,17 @@ const { PATH, seed, wipe } = require('../helpers'); const TEST_PATH = `${PATH}/orderByChild`; -describe('database().ref().orderByChild()', function() { - before(function() { +describe('database().ref().orderByChild()', function () { + before(function () { return seed(TEST_PATH); }); - after(function() { + after(function () { return wipe(TEST_PATH); }); - it('throws if path is not a string value', async function() { + it('throws if path is not a string value', async function () { try { - await firebase - .database() - .ref() - .orderByChild({ foo: 'bar' }); + await firebase.database().ref().orderByChild({ foo: 'bar' }); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'path' must be a string value"); @@ -40,12 +37,9 @@ describe('database().ref().orderByChild()', function() { } }); - it('throws if path is an empty path', async function() { + it('throws if path is an empty path', async function () { try { - await firebase - .database() - .ref() - .orderByChild('/'); + await firebase.database().ref().orderByChild('/'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'path' cannot be empty. Use orderByValue instead"); @@ -53,13 +47,9 @@ describe('database().ref().orderByChild()', function() { } }); - it('throws if an orderBy call has already been set', async function() { + it('throws if an orderBy call has already been set', async function () { try { - await firebase - .database() - .ref() - .orderByKey() - .orderByChild('foo'); + await firebase.database().ref().orderByKey().orderByChild('foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("You can't combine multiple orderBy calls"); @@ -67,14 +57,11 @@ describe('database().ref().orderByChild()', function() { } }); - it('order by a child value', async function() { + it('order by a child value', async function () { const ref = firebase.database().ref(TEST_PATH); try { - const snapshot = await ref - .child('query') - .orderByChild('number') - .once('value'); + const snapshot = await ref.child('query').orderByChild('number').once('value'); const expected = ['b', 'c', 'a']; diff --git a/packages/database/e2e/query/orderByKey.e2e.js b/packages/database/e2e/query/orderByKey.e2e.js index 0e72fff71a..785dc2096d 100644 --- a/packages/database/e2e/query/orderByKey.e2e.js +++ b/packages/database/e2e/query/orderByKey.e2e.js @@ -19,21 +19,17 @@ const { PATH, seed, wipe } = require('../helpers'); const TEST_PATH = `${PATH}/orderByKey`; -describe('database().ref().orderByKey()', function() { - before(function() { +describe('database().ref().orderByKey()', function () { + before(function () { return seed(TEST_PATH); }); - after(function() { + after(function () { return wipe(TEST_PATH); }); - it('throws if an orderBy call has already been set', async function() { + it('throws if an orderBy call has already been set', async function () { try { - await firebase - .database() - .ref() - .orderByChild('foo') - .orderByKey(); + await firebase.database().ref().orderByChild('foo').orderByKey(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("You can't combine multiple orderBy calls"); @@ -41,14 +37,11 @@ describe('database().ref().orderByKey()', function() { } }); - it('order by a key', async function() { + it('order by a key', async function () { const ref = firebase.database().ref(TEST_PATH); try { - const snapshot = await ref - .child('query') - .orderByKey() - .once('value'); + const snapshot = await ref.child('query').orderByKey().once('value'); const expected = ['a', 'b', 'c']; diff --git a/packages/database/e2e/query/orderByPriority.e2e.js b/packages/database/e2e/query/orderByPriority.e2e.js index 65c8c9dcc5..367ee97d31 100644 --- a/packages/database/e2e/query/orderByPriority.e2e.js +++ b/packages/database/e2e/query/orderByPriority.e2e.js @@ -19,21 +19,17 @@ const { PATH, seed, wipe } = require('../helpers'); const TEST_PATH = `${PATH}/orderByPriority`; -describe('database().ref().orderByPriority()', function() { - before(function() { +describe('database().ref().orderByPriority()', function () { + before(function () { return seed(TEST_PATH); }); - after(function() { + after(function () { return wipe(TEST_PATH); }); - it('throws if an orderBy call has already been set', async function() { + it('throws if an orderBy call has already been set', async function () { try { - await firebase - .database() - .ref() - .orderByChild('foo') - .orderByPriority(); + await firebase.database().ref().orderByChild('foo').orderByPriority(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("You can't combine multiple orderBy calls"); @@ -41,11 +37,8 @@ describe('database().ref().orderByPriority()', function() { } }); - it('order by priority', async function() { - const ref = firebase - .database() - .ref(TEST_PATH) - .child('query'); + it('order by priority', async function () { + const ref = firebase.database().ref(TEST_PATH).child('query'); await Promise.all([ ref.child('a').setPriority(2), diff --git a/packages/database/e2e/query/orderByValue.e2e.js b/packages/database/e2e/query/orderByValue.e2e.js index db52dd29b9..3a9bb4e9b4 100644 --- a/packages/database/e2e/query/orderByValue.e2e.js +++ b/packages/database/e2e/query/orderByValue.e2e.js @@ -19,21 +19,17 @@ const { PATH, seed, wipe } = require('../helpers'); const TEST_PATH = `${PATH}/orderByValue`; -describe('database().ref().orderByValue()', function() { - before(function() { +describe('database().ref().orderByValue()', function () { + before(function () { return seed(TEST_PATH); }); - after(function() { + after(function () { return wipe(TEST_PATH); }); - it('throws if an orderBy call has already been set', async function() { + it('throws if an orderBy call has already been set', async function () { try { - await firebase - .database() - .ref() - .orderByChild('foo') - .orderByValue(); + await firebase.database().ref().orderByChild('foo').orderByValue(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("You can't combine multiple orderBy calls"); @@ -41,11 +37,8 @@ describe('database().ref().orderByValue()', function() { } }); // TODO potentially flakey on CI iOS - possible crash - xit('order by value', async function() { - const ref = firebase - .database() - .ref(TEST_PATH) - .child('query'); + xit('order by value', async function () { + const ref = firebase.database().ref(TEST_PATH).child('query'); await ref.set({ a: 2, diff --git a/packages/database/e2e/query/query.e2e.js b/packages/database/e2e/query/query.e2e.js index 1b37dc205a..ccf72f8543 100644 --- a/packages/database/e2e/query/query.e2e.js +++ b/packages/database/e2e/query/query.e2e.js @@ -14,8 +14,8 @@ * limitations under the License. */ -describe('DatabaseQuery/DatabaseQueryModifiers', function() { - it('should not mutate previous queries (#2691)', async function() { +describe('DatabaseQuery/DatabaseQueryModifiers', function () { + it('should not mutate previous queries (#2691)', async function () { const queryBefore = firebase.database().ref(); queryBefore._modifiers._modifiers.length.should.equal(0); diff --git a/packages/database/e2e/query/startAt.e2e.js b/packages/database/e2e/query/startAt.e2e.js index 5e018acea2..b0bc2ab5e2 100644 --- a/packages/database/e2e/query/startAt.e2e.js +++ b/packages/database/e2e/query/startAt.e2e.js @@ -19,20 +19,17 @@ const { PATH, seed, wipe } = require('../helpers'); const TEST_PATH = `${PATH}/startAt`; -describe('database().ref().startAt()', function() { - before(function() { +describe('database().ref().startAt()', function () { + before(function () { return seed(TEST_PATH); }); - after(function() { + after(function () { return wipe(TEST_PATH); }); - it('throws if an value is undefined', async function() { + it('throws if an value is undefined', async function () { try { - await firebase - .database() - .ref() - .startAt(); + await firebase.database().ref().startAt(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'value' must be a number, string, boolean or null value"); @@ -40,12 +37,9 @@ describe('database().ref().startAt()', function() { } }); - it('throws if an key is not a string', async function() { + it('throws if an key is not a string', async function () { try { - await firebase - .database() - .ref() - .startAt('foo', 1234); + await firebase.database().ref().startAt('foo', 1234); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'key' must be a string value if defined"); @@ -53,13 +47,9 @@ describe('database().ref().startAt()', function() { } }); - it('throws if a starting point has already been set', async function() { + it('throws if a starting point has already been set', async function () { try { - await firebase - .database() - .ref() - .equalTo('foo') - .startAt('foo'); + await firebase.database().ref().equalTo('foo').startAt('foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -69,13 +59,9 @@ describe('database().ref().startAt()', function() { } }); - it('throws if ordering by key and the key param is set', async function() { + it('throws if ordering by key and the key param is set', async function () { try { - await firebase - .database() - .ref() - .orderByKey('foo') - .startAt('foo', 'bar'); + await firebase.database().ref().orderByKey('foo').startAt('foo', 'bar'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -85,13 +71,9 @@ describe('database().ref().startAt()', function() { } }); - it('throws if ordering by key and the value param is not a string', async function() { + it('throws if ordering by key and the value param is not a string', async function () { try { - await firebase - .database() - .ref() - .orderByKey('foo') - .startAt(123); + await firebase.database().ref().orderByKey('foo').startAt(123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -101,13 +83,9 @@ describe('database().ref().startAt()', function() { } }); - it('throws if ordering by priority and the value param is not priority type', async function() { + it('throws if ordering by priority and the value param is not priority type', async function () { try { - await firebase - .database() - .ref() - .orderByPriority() - .startAt(true); + await firebase.database().ref().orderByPriority().startAt(true); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -117,7 +95,7 @@ describe('database().ref().startAt()', function() { } }); - it('snapshot value is null when no ordering modifier is applied', async function() { + it('snapshot value is null when no ordering modifier is applied', async function () { const ref = firebase.database().ref(TEST_PATH); await ref.set({ @@ -131,7 +109,7 @@ describe('database().ref().startAt()', function() { should.equal(snapshot.val(), null); }); - it('starts at the correct value', async function() { + it('starts at the correct value', async function () { const ref = firebase.database().ref(TEST_PATH); await ref.set({ @@ -141,10 +119,7 @@ describe('database().ref().startAt()', function() { d: 4, }); - const snapshot = await ref - .orderByValue() - .startAt(2) - .once('value'); + const snapshot = await ref.orderByValue().startAt(2).once('value'); const expected = ['b', 'c', 'd']; diff --git a/packages/database/e2e/query/toJSON.e2e.js b/packages/database/e2e/query/toJSON.e2e.js index 1c85b8694f..96a5e94f32 100644 --- a/packages/database/e2e/query/toJSON.e2e.js +++ b/packages/database/e2e/query/toJSON.e2e.js @@ -15,12 +15,9 @@ * */ -describe('database().ref().toJSON()', function() { - it('returns a string version of the current query path', async function() { - const res = firebase - .database() - .ref('foo/bar/baz') - .toJSON(); +describe('database().ref().toJSON()', function () { + it('returns a string version of the current query path', async function () { + const res = firebase.database().ref('foo/bar/baz').toJSON(); const expected = `${firebase.database()._customUrlOrRegion}/foo/bar/baz`; should.equal(res, expected); }); diff --git a/packages/database/e2e/reference/child.e2e.js b/packages/database/e2e/reference/child.e2e.js index 28c63014c5..2827b7a8eb 100644 --- a/packages/database/e2e/reference/child.e2e.js +++ b/packages/database/e2e/reference/child.e2e.js @@ -15,13 +15,10 @@ * */ -describe('database().ref().child()', function() { - it('throws if path is not a string', async function() { +describe('database().ref().child()', function () { + it('throws if path is not a string', async function () { try { - firebase - .database() - .ref() - .child({ foo: 'bar' }); + firebase.database().ref().child({ foo: 'bar' }); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'path' must be a string value"); @@ -29,12 +26,9 @@ describe('database().ref().child()', function() { } }); - it('throws if path is not a valid string', async function() { + it('throws if path is not a valid string', async function () { try { - firebase - .database() - .ref() - .child('$$$$$'); + firebase.database().ref().child('$$$$$'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( diff --git a/packages/database/e2e/reference/key.e2e.js b/packages/database/e2e/reference/key.e2e.js index 8189351fad..bcccdd22c1 100644 --- a/packages/database/e2e/reference/key.e2e.js +++ b/packages/database/e2e/reference/key.e2e.js @@ -15,13 +15,13 @@ * */ -describe('database().ref().key', function() { - it('returns null when no reference path is provides', function() { +describe('database().ref().key', function () { + it('returns null when no reference path is provides', function () { const ref = firebase.database().ref(); should.equal(ref.key, null); }); - it('return last token in reference path', function() { + it('return last token in reference path', function () { const ref1 = firebase.database().ref('foo'); const ref2 = firebase.database().ref('foo/bar/baz'); ref1.key.should.equal('foo'); diff --git a/packages/database/e2e/reference/onDisconnect.e2e.js b/packages/database/e2e/reference/onDisconnect.e2e.js index e477cfa79b..e308e7f6e2 100644 --- a/packages/database/e2e/reference/onDisconnect.e2e.js +++ b/packages/database/e2e/reference/onDisconnect.e2e.js @@ -17,12 +17,9 @@ // See onDisconnect directory for specific tests -describe('database().ref().onDisconnect()', function() { - it('returns a new DatabaseOnDisconnect instance', function() { - const instance = firebase - .database() - .ref() - .onDisconnect(); +describe('database().ref().onDisconnect()', function () { + it('returns a new DatabaseOnDisconnect instance', function () { + const instance = firebase.database().ref().onDisconnect(); instance.constructor.name.should.eql('DatabaseOnDisconnect'); }); }); diff --git a/packages/database/e2e/reference/parent.e2e.js b/packages/database/e2e/reference/parent.e2e.js index a0fb8e0e8e..592b6e2f12 100644 --- a/packages/database/e2e/reference/parent.e2e.js +++ b/packages/database/e2e/reference/parent.e2e.js @@ -15,13 +15,13 @@ * */ -describe('database().ref().parent', function() { - it('returns null when no reference path is provides', function() { +describe('database().ref().parent', function () { + it('returns null when no reference path is provides', function () { const ref = firebase.database().ref(); should.equal(ref.parent, null); }); - it('return last token in reference path', function() { + it('return last token in reference path', function () { const ref1 = firebase.database().ref('/foo').parent; const ref2 = firebase.database().ref('/foo/bar/baz').parent; should.equal(ref1, null); diff --git a/packages/database/e2e/reference/push.e2e.js b/packages/database/e2e/reference/push.e2e.js index 6390a055c3..b859260c42 100644 --- a/packages/database/e2e/reference/push.e2e.js +++ b/packages/database/e2e/reference/push.e2e.js @@ -19,13 +19,10 @@ const { PATH } = require('../helpers'); const TEST_PATH = `${PATH}/push`; -describe('database().ref().push()', function() { - it('throws if on complete callback is not a function', function() { +describe('database().ref().push()', function () { + it('throws if on complete callback is not a function', function () { try { - firebase - .database() - .ref(TEST_PATH) - .push('foo', 'bar'); + firebase.database().ref(TEST_PATH).push('foo', 'bar'); return Promise.reject(new Error('Did not throw Error')); } catch (error) { error.message.should.containEql("'onComplete' must be a function if provided"); @@ -33,7 +30,7 @@ describe('database().ref().push()', function() { } }); - it('returns a promise when no value is passed', function() { + it('returns a promise when no value is passed', function () { const ref = firebase.database().ref(`${TEST_PATH}/boop`); const pushed = ref.push(); return pushed @@ -48,7 +45,7 @@ describe('database().ref().push()', function() { }); }); - it('returns a promise and sets the provided value', function() { + it('returns a promise and sets the provided value', function () { const ref = firebase.database().ref(`${TEST_PATH}/value`); const pushed = ref.push(6); return pushed @@ -63,7 +60,7 @@ describe('database().ref().push()', function() { }); }); - it('returns a to the callback if provided once set', async function() { + it('returns a to the callback if provided once set', async function () { const callback = sinon.spy(); const ref = firebase.database().ref(`${TEST_PATH}/callback`); const value = Date.now(); @@ -74,7 +71,7 @@ describe('database().ref().push()', function() { callback.should.be.calledOnce(); }); - it('throws if push errors', async function() { + it('throws if push errors', async function () { const ref = firebase.database().ref('nope'); return ref.push('foo').catch(error => { error.message.should.containEql("doesn't have permission to access"); @@ -82,7 +79,7 @@ describe('database().ref().push()', function() { }); }); - it('returns an error to the callback', async function() { + it('returns an error to the callback', async function () { const callback = sinon.spy(); const ref = firebase.database().ref('nope'); ref.push('foo', error => { diff --git a/packages/database/e2e/reference/remove.e2e.js b/packages/database/e2e/reference/remove.e2e.js index 50f89b20c1..4b62800801 100644 --- a/packages/database/e2e/reference/remove.e2e.js +++ b/packages/database/e2e/reference/remove.e2e.js @@ -19,13 +19,10 @@ const { PATH } = require('../helpers'); const TEST_PATH = `${PATH}/remove`; -describe('database().ref().remove()', function() { - it('throws if onComplete is not a function', async function() { +describe('database().ref().remove()', function () { + it('throws if onComplete is not a function', async function () { try { - await firebase - .database() - .ref(TEST_PATH) - .remove('foo'); + await firebase.database().ref(TEST_PATH).remove('foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'onComplete' must be a function if provided"); @@ -33,7 +30,7 @@ describe('database().ref().remove()', function() { } }); - it('removes a value at the path', async function() { + it('removes a value at the path', async function () { const ref = firebase.database().ref(TEST_PATH); await ref.set('foo'); await ref.remove(); diff --git a/packages/database/e2e/reference/root.e2e.js b/packages/database/e2e/reference/root.e2e.js index f75f426dfc..c7677ce9ee 100644 --- a/packages/database/e2e/reference/root.e2e.js +++ b/packages/database/e2e/reference/root.e2e.js @@ -15,8 +15,8 @@ * */ -describe('database().ref().root', function() { - it('returns a root reference', function() { +describe('database().ref().root', function () { + it('returns a root reference', function () { const ref = firebase.database().ref('foo/bar/baz'); should.equal(ref.root.key, null); }); diff --git a/packages/database/e2e/reference/set.e2e.js b/packages/database/e2e/reference/set.e2e.js index 863fc25cfc..c3a3149589 100644 --- a/packages/database/e2e/reference/set.e2e.js +++ b/packages/database/e2e/reference/set.e2e.js @@ -19,20 +19,17 @@ const { PATH, seed, wipe } = require('../helpers'); const TEST_PATH = `${PATH}/set`; -describe('database().ref().set()', function() { - before(function() { +describe('database().ref().set()', function () { + before(function () { return seed(TEST_PATH); }); - after(function() { + after(function () { return wipe(TEST_PATH); }); - it('throws if no value is provided', async function() { + it('throws if no value is provided', async function () { try { - await firebase - .database() - .ref(TEST_PATH) - .set(); + await firebase.database().ref(TEST_PATH).set(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'value' must be defined"); @@ -40,12 +37,9 @@ describe('database().ref().set()', function() { } }); - it('throws if onComplete is not a function', async function() { + it('throws if onComplete is not a function', async function () { try { - await firebase - .database() - .ref(TEST_PATH) - .set(null, 'foo'); + await firebase.database().ref(TEST_PATH).set(null, 'foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'onComplete' must be a function if provided"); @@ -53,7 +47,7 @@ describe('database().ref().set()', function() { } }); - it('sets a new value', async function() { + it('sets a new value', async function () { const value = Date.now(); const ref = firebase.database().ref(TEST_PATH); await ref.set(value); @@ -61,23 +55,17 @@ describe('database().ref().set()', function() { snapshot.val().should.eql(value); }); - it('callback if function is passed', async function() { + it('callback if function is passed', async function () { const value = Date.now(); return new Promise(async resolve => { - await firebase - .database() - .ref(TEST_PATH) - .set(value, resolve); + await firebase.database().ref(TEST_PATH).set(value, resolve); }); }); - it('throws if permission defined', async function() { + it('throws if permission defined', async function () { const value = Date.now(); try { - await firebase - .database() - .ref('nope/foo') - .set(value); + await firebase.database().ref('nope/foo').set(value); return Promise.reject(new Error('Did not throw error.')); } catch (error) { error.code.includes('database/permission-denied').should.be.true(); diff --git a/packages/database/e2e/reference/setPriority.e2e.js b/packages/database/e2e/reference/setPriority.e2e.js index c7c383ebf2..471a17bd67 100644 --- a/packages/database/e2e/reference/setPriority.e2e.js +++ b/packages/database/e2e/reference/setPriority.e2e.js @@ -19,20 +19,17 @@ const { PATH, CONTENT, seed, wipe } = require('../helpers'); const TEST_PATH = `${PATH}/priority`; -describe('database().ref().setPriority()', function() { - before(function() { +describe('database().ref().setPriority()', function () { + before(function () { return seed(TEST_PATH); }); - after(function() { + after(function () { return wipe(TEST_PATH); }); - it('throws if priority is not a valid type', async function() { + it('throws if priority is not a valid type', async function () { try { - await firebase - .database() - .ref() - .setPriority({}); + await firebase.database().ref().setPriority({}); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'priority' must be a number, string or null value"); @@ -40,12 +37,9 @@ describe('database().ref().setPriority()', function() { } }); - it('throws if onComplete is not a function', async function() { + it('throws if onComplete is not a function', async function () { try { - await firebase - .database() - .ref() - .setPriority(null, 'foo'); + await firebase.database().ref().setPriority(null, 'foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'onComplete' must be a function if provided"); @@ -53,7 +47,7 @@ describe('database().ref().setPriority()', function() { } }); - it('should correctly set a priority for all non-null values', async function() { + it('should correctly set a priority for all non-null values', async function () { await Promise.all( Object.keys(CONTENT.TYPES).map(async dataRef => { const ref = firebase.database().ref(`${TEST_PATH}/types/${dataRef}`); @@ -66,22 +60,16 @@ describe('database().ref().setPriority()', function() { ); }); - it('callback if function is passed', async function() { + it('callback if function is passed', async function () { const value = Date.now(); return new Promise(async resolve => { - await firebase - .database() - .ref(`${TEST_PATH}/types/string`) - .set(value, resolve); + await firebase.database().ref(`${TEST_PATH}/types/string`).set(value, resolve); }); }); - it('throws if setting priority on non-existent node', async function() { + it('throws if setting priority on non-existent node', async function () { try { - await firebase - .database() - .ref('tests/siudfhsuidfj') - .setPriority(1); + await firebase.database().ref('tests/siudfhsuidfj').setPriority(1); return Promise.reject(new Error('Did not throw error.')); } catch (error) { // WEB SDK: INVALID_PARAMETERS: could not set priority on non-existent node @@ -90,12 +78,9 @@ describe('database().ref().setPriority()', function() { } }); - it('throws if permission defined', async function() { + it('throws if permission defined', async function () { try { - await firebase - .database() - .ref('nope/foo') - .setPriority(1); + await firebase.database().ref('nope/foo').setPriority(1); return Promise.reject(new Error('Did not throw error.')); } catch (error) { error.code.includes('database/permission-denied').should.be.true(); diff --git a/packages/database/e2e/reference/setWithPriority.e2e.js b/packages/database/e2e/reference/setWithPriority.e2e.js index 99e7ea667a..65d245a7cd 100644 --- a/packages/database/e2e/reference/setWithPriority.e2e.js +++ b/packages/database/e2e/reference/setWithPriority.e2e.js @@ -19,20 +19,17 @@ const { PATH, seed, wipe } = require('../helpers'); const TEST_PATH = `${PATH}/setWithPriority`; -describe('database().ref().setWithPriority()', function() { - before(function() { +describe('database().ref().setWithPriority()', function () { + before(function () { return seed(TEST_PATH); }); - after(function() { + after(function () { return wipe(TEST_PATH); }); - it('throws if newVal is not defined', async function() { + it('throws if newVal is not defined', async function () { try { - await firebase - .database() - .ref() - .setWithPriority(); + await firebase.database().ref().setWithPriority(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'newVal' must be defined"); @@ -40,12 +37,9 @@ describe('database().ref().setWithPriority()', function() { } }); - it('throws if newPriority is incorrect type', async function() { + it('throws if newPriority is incorrect type', async function () { try { - await firebase - .database() - .ref() - .setWithPriority(null, { foo: 'bar' }); + await firebase.database().ref().setWithPriority(null, { foo: 'bar' }); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'newPriority' must be a number, string or null value"); @@ -53,12 +47,9 @@ describe('database().ref().setWithPriority()', function() { } }); - it('throws if onComplete is not a function', async function() { + it('throws if onComplete is not a function', async function () { try { - await firebase - .database() - .ref() - .setWithPriority(null, null, 'foo'); + await firebase.database().ref().setWithPriority(null, null, 'foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'onComplete' must be a function if provided"); @@ -66,7 +57,7 @@ describe('database().ref().setWithPriority()', function() { } }); - it('callback if function is passed', async function() { + it('callback if function is passed', async function () { const value = Date.now(); return new Promise(async resolve => { await firebase @@ -76,7 +67,7 @@ describe('database().ref().setWithPriority()', function() { }); }); - it('sets with a new value and priority', async function() { + it('sets with a new value and priority', async function () { const value = Date.now(); const ref = firebase.database().ref(`${TEST_PATH}/setValue`); await ref.setWithPriority(value, 2); diff --git a/packages/database/e2e/reference/transaction.e2e.js b/packages/database/e2e/reference/transaction.e2e.js index 709a878fe2..6c82c79dd8 100644 --- a/packages/database/e2e/reference/transaction.e2e.js +++ b/packages/database/e2e/reference/transaction.e2e.js @@ -20,20 +20,17 @@ const { PATH, seed, wipe } = require('../helpers'); const TEST_PATH = `${PATH}/transaction`; const NOOP = () => {}; -describe('database().ref().transaction()', function() { - before(function() { +describe('database().ref().transaction()', function () { + before(function () { return seed(TEST_PATH); }); - after(function() { + after(function () { return wipe(TEST_PATH); }); - it('throws if no transactionUpdate is provided', async function() { + it('throws if no transactionUpdate is provided', async function () { try { - await firebase - .database() - .ref(TEST_PATH) - .transaction(); + await firebase.database().ref(TEST_PATH).transaction(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'transactionUpdate' must be a function"); @@ -41,12 +38,9 @@ describe('database().ref().transaction()', function() { } }); - it('throws if onComplete is not a function', async function() { + it('throws if onComplete is not a function', async function () { try { - await firebase - .database() - .ref() - .transaction(NOOP, 'foo'); + await firebase.database().ref().transaction(NOOP, 'foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'onComplete' must be a function if provided"); @@ -54,12 +48,9 @@ describe('database().ref().transaction()', function() { } }); - it('throws if applyLocally is not a boolean', async function() { + it('throws if applyLocally is not a boolean', async function () { try { - await firebase - .database() - .ref() - .transaction(NOOP, NOOP, 'foo'); + await firebase.database().ref().transaction(NOOP, NOOP, 'foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'applyLocally' must be a boolean value if provided"); @@ -69,10 +60,7 @@ describe('database().ref().transaction()', function() { // FIXME not working for android in CI ? ios.it('updates the value via a transaction', async () => { - const ref = firebase - .database() - .ref(TEST_PATH) - .child('transaction'); + const ref = firebase.database().ref(TEST_PATH).child('transaction'); await ref.set(1); const { committed, snapshot } = await ref.transaction(value => { @@ -83,11 +71,8 @@ describe('database().ref().transaction()', function() { snapshot.val().should.equal(2); }); - it('aborts transaction if undefined returned', async function() { - const ref = firebase - .database() - .ref(TEST_PATH) - .child('transaction'); + it('aborts transaction if undefined returned', async function () { + const ref = firebase.database().ref(TEST_PATH).child('transaction'); await ref.set(1); return new Promise((resolve, reject) => { @@ -111,13 +96,10 @@ describe('database().ref().transaction()', function() { }); // FIXME failing for me locally on android and ios as well - xit('passes valid data through the callback', async function() { + xit('passes valid data through the callback', async function () { // FIXME failing in CI if (!global.isCI) { - const ref = firebase - .database() - .ref(TEST_PATH) - .child('transaction'); + const ref = firebase.database().ref(TEST_PATH).child('transaction'); await ref.set(1); return new Promise((resolve, reject) => { @@ -143,7 +125,7 @@ describe('database().ref().transaction()', function() { }); // FIXME failing for me locally on android and ios as well - xit('throws when an error occurs', async function() { + xit('throws when an error occurs', async function () { // FIXME failing in CI if (!global.isCI) { const ref = firebase.database().ref('nope'); @@ -163,7 +145,7 @@ describe('database().ref().transaction()', function() { }); // FIXME failing for me locally on android and ios as well - xit('passes error back to the callback', async function() { + xit('passes error back to the callback', async function () { // FIXME failing in CI if (!global.isCI) { const ref = firebase.database().ref('nope'); @@ -197,13 +179,10 @@ describe('database().ref().transaction()', function() { }); // FIXME failing for me locally on android and ios as well - xit('sets a value if one does not exist', async function() { + xit('sets a value if one does not exist', async function () { // FIXME failing in CI if (!global.isCI) { - const ref = firebase - .database() - .ref(TEST_PATH) - .child('create'); + const ref = firebase.database().ref(TEST_PATH).child('create'); await ref.remove(); // Ensure it's clear const value = Date.now(); diff --git a/packages/database/e2e/reference/update.e2e.js b/packages/database/e2e/reference/update.e2e.js index ee40fd922e..c7fb754843 100644 --- a/packages/database/e2e/reference/update.e2e.js +++ b/packages/database/e2e/reference/update.e2e.js @@ -19,20 +19,14 @@ const { PATH } = require('../helpers'); const TEST_PATH = `${PATH}/update`; -describe('database().ref().update()', function() { - after(async function() { - await firebase - .database() - .ref(TEST_PATH) - .remove(); +describe('database().ref().update()', function () { + after(async function () { + await firebase.database().ref(TEST_PATH).remove(); }); - it('throws if values is not an object', async function() { + it('throws if values is not an object', async function () { try { - await firebase - .database() - .ref(TEST_PATH) - .update('foo'); + await firebase.database().ref(TEST_PATH).update('foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'values' must be an object"); @@ -40,12 +34,9 @@ describe('database().ref().update()', function() { } }); - it('throws if values does not contain any values', async function() { + it('throws if values does not contain any values', async function () { try { - await firebase - .database() - .ref(TEST_PATH) - .update({}); + await firebase.database().ref(TEST_PATH).update({}); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'values' must be an object containing multiple values"); @@ -53,14 +44,11 @@ describe('database().ref().update()', function() { } }); - it('throws if update paths are not valid', async function() { + it('throws if update paths are not valid', async function () { try { - await firebase - .database() - .ref(TEST_PATH) - .update({ - $$$$: 'foo', - }); + await firebase.database().ref(TEST_PATH).update({ + $$$$: 'foo', + }); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'values' contains an invalid path."); @@ -68,17 +56,14 @@ describe('database().ref().update()', function() { } }); - it('throws if onComplete is not a function', async function() { + it('throws if onComplete is not a function', async function () { try { - await firebase - .database() - .ref(TEST_PATH) - .update( - { - foo: 'bar', - }, - 'foo', - ); + await firebase.database().ref(TEST_PATH).update( + { + foo: 'bar', + }, + 'foo', + ); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'onComplete' must be a function if provided"); @@ -86,7 +71,7 @@ describe('database().ref().update()', function() { } }); - it('updates values', async function() { + it('updates values', async function () { const value = Date.now(); const ref = firebase.database().ref(TEST_PATH); await ref.update({ @@ -100,18 +85,15 @@ describe('database().ref().update()', function() { ); }); - it('callback if function is passed', async function() { + it('callback if function is passed', async function () { const value = Date.now(); return new Promise(async resolve => { - await firebase - .database() - .ref(TEST_PATH) - .update( - { - foo: value, - }, - resolve, - ); + await firebase.database().ref(TEST_PATH).update( + { + foo: value, + }, + resolve, + ); }); }); }); diff --git a/packages/database/e2e/snapshot/snapshot.e2e.js b/packages/database/e2e/snapshot/snapshot.e2e.js index 667596e255..954700f4eb 100644 --- a/packages/database/e2e/snapshot/snapshot.e2e.js +++ b/packages/database/e2e/snapshot/snapshot.e2e.js @@ -19,57 +19,37 @@ const { PATH, CONTENT, seed, wipe } = require('../helpers'); const TEST_PATH = `${PATH}/snapshot`; -describe('database()...snapshot', function() { - before(function() { +describe('database()...snapshot', function () { + before(function () { return seed(TEST_PATH); }); - after(function() { + after(function () { return wipe(TEST_PATH); }); - it('returns the snapshot key', async function() { - const snapshot = await firebase - .database() - .ref(TEST_PATH) - .child('types/boolean') - .once('value'); + it('returns the snapshot key', async function () { + const snapshot = await firebase.database().ref(TEST_PATH).child('types/boolean').once('value'); snapshot.key.should.equal('boolean'); }); - it('returns the snapshot reference', async function() { - const snapshot = await firebase - .database() - .ref(TEST_PATH) - .child('types/boolean') - .once('value'); + it('returns the snapshot reference', async function () { + const snapshot = await firebase.database().ref(TEST_PATH).child('types/boolean').once('value'); snapshot.ref.key.should.equal('boolean'); }); - it('returns the correct boolean for exists', async function() { - const snapshot1 = await firebase - .database() - .ref(TEST_PATH) - .child('types/boolean') - .once('value'); + it('returns the correct boolean for exists', async function () { + const snapshot1 = await firebase.database().ref(TEST_PATH).child('types/boolean').once('value'); - const snapshot2 = await firebase - .database() - .ref(TEST_PATH) - .child('types/nope') - .once('value'); + const snapshot2 = await firebase.database().ref(TEST_PATH).child('types/nope').once('value'); snapshot1.exists().should.equal(true); snapshot2.exists().should.equal(false); }); - it('exports a valid object', async function() { - const snapshot = await firebase - .database() - .ref(TEST_PATH) - .child('types/string') - .once('value'); + it('exports a valid object', async function () { + const snapshot = await firebase.database().ref(TEST_PATH).child('types/string').once('value'); const exported = snapshot.exportVal(); @@ -79,12 +59,8 @@ describe('database()...snapshot', function() { should.equal(exported['.priority'], null); }); - it('exports a valid object with a object value', async function() { - const snapshot = await firebase - .database() - .ref(TEST_PATH) - .child('types/object') - .once('value'); + it('exports a valid object with a object value', async function () { + const snapshot = await firebase.database().ref(TEST_PATH).child('types/object').once('value'); const exported = snapshot.exportVal(); @@ -94,11 +70,8 @@ describe('database()...snapshot', function() { should.equal(exported['.priority'], null); }); - it('forEach throws if action param is not a function', async function() { - const ref = firebase - .database() - .ref(TEST_PATH) - .child('unorderedList'); + it('forEach throws if action param is not a function', async function () { + const ref = firebase.database().ref(TEST_PATH).child('unorderedList'); await ref.set({ a: 3, @@ -115,11 +88,8 @@ describe('database()...snapshot', function() { } }); - it('forEach returns an ordered list of snapshots', async function() { - const ref = firebase - .database() - .ref(TEST_PATH) - .child('unorderedList'); + it('forEach returns an ordered list of snapshots', async function () { + const ref = firebase.database().ref(TEST_PATH).child('unorderedList'); await ref.set({ a: 3, @@ -136,12 +106,9 @@ describe('database()...snapshot', function() { }); }); - it('forEach works with arrays', async function() { + it('forEach works with arrays', async function () { const callback = sinon.spy(); - const ref = firebase - .database() - .ref(TEST_PATH) - .child('types'); + const ref = firebase.database().ref(TEST_PATH).child('types'); const snapshot = await ref.once('value'); @@ -154,13 +121,9 @@ describe('database()...snapshot', function() { callback.should.be.callCount(snapshot.child('array').numChildren()); }); - it('forEach works with objects and cancels when returning true', async function() { + it('forEach works with objects and cancels when returning true', async function () { const callback = sinon.spy(); - const ref = firebase - .database() - .ref(TEST_PATH) - .child('types/object') - .orderByKey(); + const ref = firebase.database().ref(TEST_PATH).child('types/object').orderByKey(); const snapshot = await ref.once('value'); @@ -174,12 +137,9 @@ describe('database()...snapshot', function() { callback.should.be.calledOnce(); }); - it('forEach works with arrays and cancels when returning true', async function() { + it('forEach works with arrays and cancels when returning true', async function () { const callback = sinon.spy(); - const ref = firebase - .database() - .ref(TEST_PATH) - .child('types'); + const ref = firebase.database().ref(TEST_PATH).child('types'); const snapshot = await ref.once('value'); @@ -193,12 +153,9 @@ describe('database()...snapshot', function() { callback.should.be.calledOnce(); }); - it('forEach returns false when no child keys', async function() { + it('forEach returns false when no child keys', async function () { const callback = sinon.spy(); - const ref = firebase - .database() - .ref(TEST_PATH) - .child('types/boolean'); + const ref = firebase.database().ref(TEST_PATH).child('types/boolean'); const snapshot = await ref.once('value'); @@ -210,12 +167,9 @@ describe('database()...snapshot', function() { callback.should.be.callCount(0); }); - it('forEach cancels iteration when returning true', async function() { + it('forEach cancels iteration when returning true', async function () { const callback = sinon.spy(); - const ref = firebase - .database() - .ref(TEST_PATH) - .child('types/array'); + const ref = firebase.database().ref(TEST_PATH).child('types/array'); const snapshot = await ref.orderByValue().once('value'); @@ -229,11 +183,8 @@ describe('database()...snapshot', function() { callback.getCall(0).args[0].should.equal(0); }); - it('getPriority returns the correct value', async function() { - const ref = firebase - .database() - .ref(TEST_PATH) - .child('getPriority'); + it('getPriority returns the correct value', async function () { + const ref = firebase.database().ref(TEST_PATH).child('getPriority'); await ref.setWithPriority('foo', 'bar'); const snapshot = await ref.once('value'); @@ -241,11 +192,8 @@ describe('database()...snapshot', function() { snapshot.getPriority().should.equal('bar'); }); - it('hasChild throws if path is not a string value', async function() { - const ref = firebase - .database() - .ref(TEST_PATH) - .child('types/boolean'); + it('hasChild throws if path is not a string value', async function () { + const ref = firebase.database().ref(TEST_PATH).child('types/boolean'); const snapshot = await ref.once('value'); @@ -256,7 +204,7 @@ describe('database()...snapshot', function() { } }); - it('hasChild returns the correct boolean value', async function() { + it('hasChild returns the correct boolean value', async function () { const ref = firebase.database().ref(TEST_PATH); const snapshot1 = await ref.child('types/boolean').once('value'); @@ -266,13 +214,13 @@ describe('database()...snapshot', function() { snapshot2.hasChild('boolean').should.equal(true); }); - it('hasChildren returns the correct boolean value', async function() { + it('hasChildren returns the correct boolean value', async function () { const ref = firebase.database().ref(TEST_PATH); const snapshot = await ref.child('types/object').once('value'); snapshot.hasChildren().should.equal(true); }); - it('numChildren returns the correct number value', async function() { + it('numChildren returns the correct number value', async function () { const ref = firebase.database().ref(TEST_PATH); const snapshot1 = await ref.child('types/boolean').once('value'); @@ -284,7 +232,7 @@ describe('database()...snapshot', function() { snapshot3.numChildren().should.equal(Object.keys(CONTENT.TYPES.object).length); }); - it('toJSON returns the value of the snapshot', async function() { + it('toJSON returns the value of the snapshot', async function () { const ref = firebase.database().ref(TEST_PATH); const snapshot1 = await ref.child('types/string').once('value'); @@ -294,7 +242,7 @@ describe('database()...snapshot', function() { snapshot2.toJSON().should.eql(jet.contextify(CONTENT.TYPES.object)); }); - it('val returns the value of the snapshot', async function() { + it('val returns the value of the snapshot', async function () { const ref = firebase.database().ref(TEST_PATH); const snapshot1 = await ref.child('types/string').once('value'); diff --git a/packages/database/lib/index.d.ts b/packages/database/lib/index.d.ts index 1a390855a1..b15605f5d0 100644 --- a/packages/database/lib/index.d.ts +++ b/packages/database/lib/index.d.ts @@ -72,6 +72,7 @@ export namespace FirebaseDatabaseTypes { * }); * ``` */ + // eslint-disable-next-line @typescript-eslint/ban-types TIMESTAMP: object; /** @@ -87,6 +88,7 @@ export namespace FirebaseDatabaseTypes { * * @param delta The amount to modify the current value atomically. */ + // eslint-disable-next-line @typescript-eslint/ban-types increment(delta: number): object; } @@ -224,7 +226,7 @@ export namespace FirebaseDatabaseTypes { * @param value The value to be written (string, number, boolean, object, array, or null). * @param onComplete Callback called when write to server is complete. Contains the parameters (Error | null). */ - set(value: any, onComplete?: Function): Promise; + set(value: any, onComplete?: (error: Error | null) => void): Promise; /** * Writes multiple values to the Database at once. @@ -264,7 +266,10 @@ export namespace FirebaseDatabaseTypes { * @param values Object containing multiple values. * @param onComplete Callback called when write to server is complete. Contains the parameters (Error | null). */ - update(values: { [key: string]: any }, onComplete?: Function): Promise; + update( + values: { [key: string]: any }, + onComplete?: (error: Error | null) => void, + ): Promise; /** * Sets a priority for the data at this Database location. Setting null removes any priority at this location. @@ -282,7 +287,10 @@ export namespace FirebaseDatabaseTypes { * @param priority The priority value. * @param onComplete Callback called when write to server is complete. Contains the parameters (Error | null). */ - setPriority(priority: string | number | null, onComplete?: Function): Promise; + setPriority( + priority: string | number | null, + onComplete?: (error: Error | null) => void, + ): Promise; /** * Writes data the Database location. Like `set()` but also specifies the priority for that data. @@ -306,7 +314,7 @@ export namespace FirebaseDatabaseTypes { setWithPriority( newVal: any, newPriority: string | number | null, - onComplete?: Function, + onComplete?: (error: Error | null) => void, ): Promise; /** @@ -330,7 +338,7 @@ export namespace FirebaseDatabaseTypes { * * @param onComplete Callback called when write to server is complete. Contains the parameters (Error | null). */ - remove(onComplete?: Function): Promise; + remove(onComplete?: (error: Error | null) => void): Promise; /** * Atomically modifies the data at this location. @@ -366,13 +374,14 @@ export namespace FirebaseDatabaseTypes { * }); * ``` * - * @param transactionUpdate A developer-supplied function which will be passed the current data stored at this location (as a JavaScript object). The function should return the new value it would like written (as a JavaScript object). If undefined is returned (i.e. you return with no arguments) the transaction will be aborted and the data at this location will not be modified. + * @param transactionUpdate A developer-supplied function which will be passed the current data stored at this location (as a JavaScript object). The function should return the new value it would like written (as a JavaScript object). If undefined is returned (i.e. you return with no result) the transaction will be aborted and the data at this location will not be modified. * @param onComplete A callback function that will be called when the transaction completes. The callback is passed three arguments: a possibly-null Error, a boolean indicating whether the transaction was committed, and a DataSnapshot indicating the final result. If the transaction failed abnormally, the first argument will be an Error object indicating the failure cause. If the transaction finished normally, but no data was committed because no data was returned from transactionUpdate, then second argument will be false. If the transaction completed and committed data to Firebase, the second argument will be true. Regardless, the third argument will be a DataSnapshot containing the resulting data in this location. * @param applyLocally By default, events are raised each time the transaction update function runs. So if it is run multiple times, you may see intermediate states. You can set this to false to suppress these intermediate states and instead wait until the transaction has completed before events are raised. */ transaction( - transactionUpdate: Function, - onComplete?: Function, + // eslint-disable-next-line @typescript-eslint/ban-types + transactionUpdate: (currentData: object) => object | undefined, + onComplete?: (error: Error | null, committed: boolean, finalResult: DataSnapshot) => void, applyLocally?: boolean, ): Promise; @@ -403,7 +412,7 @@ export namespace FirebaseDatabaseTypes { * @param value Optional value to be written at the generated location. * @param onComplete Callback called when write to server is complete. */ - push(value?: any, onComplete?: Function): ThenableReference; + push(value?: any, onComplete?: () => void): ThenableReference; /** * Returns an {@link database.OnDisconnect} instance. @@ -590,7 +599,7 @@ export namespace FirebaseDatabaseTypes { * @param callback The callback function that was passed to `on()` or `undefined` to remove all callbacks. * @param context The context that was passed to `on()`. */ - off(eventType?: EventType, callback?: Function, context?: Record): void; + off(eventType?: EventType, callback?: () => void, context?: Record): void; /** * Listens for data changes at a particular location. @@ -646,10 +655,10 @@ export namespace FirebaseDatabaseTypes { */ on( eventType?: EventType, - callback?: Function, + callback?: (data: DataSnapshot, previousChildKey?: string) => void, cancelCallbackOrContext?: Record, context?: Record | null, - ): Function; + ): () => void; /** * Listens for exactly one event of the specified event type, and then stops listening. @@ -772,6 +781,7 @@ export namespace FirebaseDatabaseTypes { /** * Returns a JSON-serializable representation of this object. */ + // eslint-disable-next-line @typescript-eslint/ban-types toJSON(): object; /** @@ -844,14 +854,14 @@ export namespace FirebaseDatabaseTypes { * * @param onComplete An optional callback function that will be called when synchronization to the server has completed. The callback will be passed a single parameter: null for success, or an Error object indicating a failure. */ - cancel(onComplete?: Function): Promise; + cancel(onComplete?: (error: Error | null) => void): Promise; /** * Ensures the data at this location is deleted when the client is disconnected (due to closing the browser, navigating to a new page, or network issues). * * @param onComplete An optional callback function that will be called when synchronization to the server has completed. The callback will be passed a single parameter: null for success, or an Error object indicating a failure. */ - remove(onComplete?: Function): Promise; + remove(onComplete?: (error: Error | null) => void): Promise; /** * Ensures the data at this location is set to the specified value when the client is disconnected @@ -873,7 +883,7 @@ export namespace FirebaseDatabaseTypes { * @param value The value to be written to this location on disconnect (can be an object, array, string, number, boolean, or null). * @param onComplete An optional callback function that will be called when synchronization to the Database server has completed. The callback will be passed a single parameter: null for success, or an Error object indicating a failure. */ - set(value: any, onComplete?: Function): Promise; + set(value: any, onComplete?: (error: Error | null) => void): Promise; /** * Ensures the data at this location is set to the specified value and priority when the client is disconnected (due to closing the browser, navigating to a new page, or network issues). @@ -885,7 +895,7 @@ export namespace FirebaseDatabaseTypes { setWithPriority( value: any, priority: string | number | null, - onComplete?: Function, + onComplete?: (error: Error | null) => void, ): Promise; /** @@ -915,7 +925,10 @@ export namespace FirebaseDatabaseTypes { * @param values Object containing multiple values. * @param onComplete An optional callback function that will be called when synchronization to the server has completed. The callback will be passed a single parameter: null for success, or an Error object indicating a failure. */ - update(values: { [key: string]: any }, onComplete?: Function): Promise; + update( + values: { [key: string]: any }, + onComplete?: (error: Error | null) => void, + ): Promise; } export type EventType = @@ -1012,7 +1025,7 @@ export namespace FirebaseDatabaseTypes { * * @param action A function that will be called for each child DataSnapshot. The callback can return true to cancel further enumeration. */ - forEach(action: Function): boolean; + forEach(action: (child: DataSnapshot) => true | undefined): boolean; /** * Gets the priority value of the data in this DataSnapshot. @@ -1058,6 +1071,7 @@ export namespace FirebaseDatabaseTypes { /** * Returns a JSON-serializable representation of this object. */ + // eslint-disable-next-line @typescript-eslint/ban-types toJSON(): object | null; /** @@ -1266,6 +1280,7 @@ export default defaultExport; * Attach namespace to `firebase.` and `FirebaseApp.`. */ declare module '@react-native-firebase/app' { + // eslint-disable-next-line @typescript-eslint/no-unused-vars namespace ReactNativeFirebase { import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp; interface Module { diff --git a/packages/dynamic-links/e2e/builder.analytics.e2e.js b/packages/dynamic-links/e2e/builder.analytics.e2e.js index 01ec7777da..a489488450 100644 --- a/packages/dynamic-links/e2e/builder.analytics.e2e.js +++ b/packages/dynamic-links/e2e/builder.analytics.e2e.js @@ -17,8 +17,8 @@ const { baseParams } = require('./dynamicLinks.e2e'); -describe('dynamicLinks() dynamicLinkParams.analytics', function() { - it('throws if analytics is not an object', function() { +describe('dynamicLinks() dynamicLinkParams.analytics', function () { + it('throws if analytics is not an object', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -31,7 +31,7 @@ describe('dynamicLinks() dynamicLinkParams.analytics', function() { } }); - it('throws if analytics.campaign is not a string', function() { + it('throws if analytics.campaign is not a string', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -46,7 +46,7 @@ describe('dynamicLinks() dynamicLinkParams.analytics', function() { } }); - it('throws if analytics.content is not a string', function() { + it('throws if analytics.content is not a string', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -61,7 +61,7 @@ describe('dynamicLinks() dynamicLinkParams.analytics', function() { } }); - it('throws if analytics.medium is not a string', function() { + it('throws if analytics.medium is not a string', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -76,7 +76,7 @@ describe('dynamicLinks() dynamicLinkParams.analytics', function() { } }); - it('throws if analytics.source is not a string', function() { + it('throws if analytics.source is not a string', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -91,7 +91,7 @@ describe('dynamicLinks() dynamicLinkParams.analytics', function() { } }); - it('throws if analytics.term is not a string', function() { + it('throws if analytics.term is not a string', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, diff --git a/packages/dynamic-links/e2e/builder.android.e2e.js b/packages/dynamic-links/e2e/builder.android.e2e.js index dbbd063348..5f9c156512 100644 --- a/packages/dynamic-links/e2e/builder.android.e2e.js +++ b/packages/dynamic-links/e2e/builder.android.e2e.js @@ -17,8 +17,8 @@ const { baseParams } = require('./dynamicLinks.e2e'); -describe('dynamicLinks() dynamicLinkParams.android', function() { - it('throws if android is not an object', function() { +describe('dynamicLinks() dynamicLinkParams.android', function () { + it('throws if android is not an object', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -31,7 +31,7 @@ describe('dynamicLinks() dynamicLinkParams.android', function() { } }); - it('throws if android.fallbackUrl is not a string', function() { + it('throws if android.fallbackUrl is not a string', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -46,7 +46,7 @@ describe('dynamicLinks() dynamicLinkParams.android', function() { } }); - it('throws if android.minimumVersion is not a string', function() { + it('throws if android.minimumVersion is not a string', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -61,7 +61,7 @@ describe('dynamicLinks() dynamicLinkParams.android', function() { } }); - it('throws if android.packageName is not a string', function() { + it('throws if android.packageName is not a string', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -76,7 +76,7 @@ describe('dynamicLinks() dynamicLinkParams.android', function() { } }); - it('throws if android.packageName is not set', function() { + it('throws if android.packageName is not set', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, diff --git a/packages/dynamic-links/e2e/builder.e2e.js b/packages/dynamic-links/e2e/builder.e2e.js index 29304f7450..18c3913c15 100644 --- a/packages/dynamic-links/e2e/builder.e2e.js +++ b/packages/dynamic-links/e2e/builder.e2e.js @@ -15,8 +15,8 @@ * */ -describe('dynamicLinks() dynamicLinkParams', function() { - it('throws if params are not an object', function() { +describe('dynamicLinks() dynamicLinkParams', function () { + it('throws if params are not an object', function () { try { firebase.dynamicLinks().buildLink(123); return Promise.reject(new Error('Did not throw Error.')); @@ -26,7 +26,7 @@ describe('dynamicLinks() dynamicLinkParams', function() { } }); - it('throws if link is not provided', function() { + it('throws if link is not provided', function () { try { firebase.dynamicLinks().buildLink({}); return Promise.reject(new Error('Did not throw Error.')); @@ -36,7 +36,7 @@ describe('dynamicLinks() dynamicLinkParams', function() { } }); - it('throws if link is not a string', function() { + it('throws if link is not a string', function () { try { firebase.dynamicLinks().buildLink({ link: 123, @@ -48,7 +48,7 @@ describe('dynamicLinks() dynamicLinkParams', function() { } }); - it('throws if link is invalid', function() { + it('throws if link is invalid', function () { try { firebase.dynamicLinks().buildLink({ link: 'invertase.io', @@ -62,7 +62,7 @@ describe('dynamicLinks() dynamicLinkParams', function() { } }); - it('throws if domainUriPrefix is not provided', function() { + it('throws if domainUriPrefix is not provided', function () { try { firebase.dynamicLinks().buildLink({ link: 'https://invertase.io', @@ -74,7 +74,7 @@ describe('dynamicLinks() dynamicLinkParams', function() { } }); - it('throws if domainUriPrefix is not a string', function() { + it('throws if domainUriPrefix is not a string', function () { try { firebase.dynamicLinks().buildLink({ link: 'https://invertase.io', @@ -87,7 +87,7 @@ describe('dynamicLinks() dynamicLinkParams', function() { } }); - it('throws if domainUriPrefix is invalid', function() { + it('throws if domainUriPrefix is invalid', function () { try { firebase.dynamicLinks().buildLink({ link: 'https://invertase.io', diff --git a/packages/dynamic-links/e2e/builder.ios.e2e.js b/packages/dynamic-links/e2e/builder.ios.e2e.js index 938d4370e3..6eefa9cb73 100644 --- a/packages/dynamic-links/e2e/builder.ios.e2e.js +++ b/packages/dynamic-links/e2e/builder.ios.e2e.js @@ -17,8 +17,8 @@ const { baseParams } = require('./dynamicLinks.e2e'); -describe('dynamicLinks() dynamicLinkParams.ios', function() { - it('throws if ios is not an object', function() { +describe('dynamicLinks() dynamicLinkParams.ios', function () { + it('throws if ios is not an object', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -31,7 +31,7 @@ describe('dynamicLinks() dynamicLinkParams.ios', function() { } }); - it('throws if ios.appStoreId is not a string', function() { + it('throws if ios.appStoreId is not a string', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -46,7 +46,7 @@ describe('dynamicLinks() dynamicLinkParams.ios', function() { } }); - it('throws if ios.bundleId is not a string', function() { + it('throws if ios.bundleId is not a string', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -61,7 +61,7 @@ describe('dynamicLinks() dynamicLinkParams.ios', function() { } }); - it('throws if ios.customScheme is not a string', function() { + it('throws if ios.customScheme is not a string', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -76,7 +76,7 @@ describe('dynamicLinks() dynamicLinkParams.ios', function() { } }); - it('throws if ios.fallbackUrl is not a string', function() { + it('throws if ios.fallbackUrl is not a string', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -91,7 +91,7 @@ describe('dynamicLinks() dynamicLinkParams.ios', function() { } }); - it('throws if ios.iPadBundleId is not a string', function() { + it('throws if ios.iPadBundleId is not a string', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -106,7 +106,7 @@ describe('dynamicLinks() dynamicLinkParams.ios', function() { } }); - it('throws if ios.iPadFallbackUrl is not a string', function() { + it('throws if ios.iPadFallbackUrl is not a string', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -121,7 +121,7 @@ describe('dynamicLinks() dynamicLinkParams.ios', function() { } }); - it('throws if ios.minimumVersion is not a string', function() { + it('throws if ios.minimumVersion is not a string', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -136,7 +136,7 @@ describe('dynamicLinks() dynamicLinkParams.ios', function() { } }); - it('throws if ios.bundleId is not set', function() { + it('throws if ios.bundleId is not set', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, diff --git a/packages/dynamic-links/e2e/builder.itunes.e2e.js b/packages/dynamic-links/e2e/builder.itunes.e2e.js index af76e766b2..283a623d72 100644 --- a/packages/dynamic-links/e2e/builder.itunes.e2e.js +++ b/packages/dynamic-links/e2e/builder.itunes.e2e.js @@ -17,8 +17,8 @@ const { baseParams } = require('./dynamicLinks.e2e'); -describe('dynamicLinks() dynamicLinkParams.itunes', function() { - it('throws if itunes is not an object', function() { +describe('dynamicLinks() dynamicLinkParams.itunes', function () { + it('throws if itunes is not an object', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -31,7 +31,7 @@ describe('dynamicLinks() dynamicLinkParams.itunes', function() { } }); - it('throws if itunes.affiliateToken is not a string', function() { + it('throws if itunes.affiliateToken is not a string', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -46,7 +46,7 @@ describe('dynamicLinks() dynamicLinkParams.itunes', function() { } }); - it('throws if itunes.campaignToken is not a string', function() { + it('throws if itunes.campaignToken is not a string', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -61,7 +61,7 @@ describe('dynamicLinks() dynamicLinkParams.itunes', function() { } }); - it('throws if itunes.providerToken is not a string', function() { + it('throws if itunes.providerToken is not a string', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, diff --git a/packages/dynamic-links/e2e/builder.navigation.e2e.js b/packages/dynamic-links/e2e/builder.navigation.e2e.js index 2b5aa48c2b..3e87d556ab 100644 --- a/packages/dynamic-links/e2e/builder.navigation.e2e.js +++ b/packages/dynamic-links/e2e/builder.navigation.e2e.js @@ -17,8 +17,8 @@ const { baseParams } = require('./dynamicLinks.e2e'); -describe('dynamicLinks() dynamicLinkParams.navigation', function() { - it('throws if navigation is not an object', function() { +describe('dynamicLinks() dynamicLinkParams.navigation', function () { + it('throws if navigation is not an object', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -31,7 +31,7 @@ describe('dynamicLinks() dynamicLinkParams.navigation', function() { } }); - it('throws if navigation.forcedRedirectEnabled is not a boolean', function() { + it('throws if navigation.forcedRedirectEnabled is not a boolean', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, diff --git a/packages/dynamic-links/e2e/builder.social.e2e.js b/packages/dynamic-links/e2e/builder.social.e2e.js index be6c78e260..ccee19f857 100644 --- a/packages/dynamic-links/e2e/builder.social.e2e.js +++ b/packages/dynamic-links/e2e/builder.social.e2e.js @@ -17,8 +17,8 @@ const { baseParams } = require('./dynamicLinks.e2e'); -describe('dynamicLinks() dynamicLinkParams.social', function() { - it('throws if social is not an object', function() { +describe('dynamicLinks() dynamicLinkParams.social', function () { + it('throws if social is not an object', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -31,7 +31,7 @@ describe('dynamicLinks() dynamicLinkParams.social', function() { } }); - it('throws if social.descriptionText is not a string', function() { + it('throws if social.descriptionText is not a string', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -46,7 +46,7 @@ describe('dynamicLinks() dynamicLinkParams.social', function() { } }); - it('throws if social.imageUrl is not a string', function() { + it('throws if social.imageUrl is not a string', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, @@ -61,7 +61,7 @@ describe('dynamicLinks() dynamicLinkParams.social', function() { } }); - it('throws if social.title is not a string', function() { + it('throws if social.title is not a string', function () { try { firebase.dynamicLinks().buildLink({ ...baseParams, diff --git a/packages/dynamic-links/e2e/dynamicLinks.e2e.js b/packages/dynamic-links/e2e/dynamicLinks.e2e.js index d3b7ef7564..d7dda7cadf 100644 --- a/packages/dynamic-links/e2e/dynamicLinks.e2e.js +++ b/packages/dynamic-links/e2e/dynamicLinks.e2e.js @@ -28,31 +28,31 @@ const TEST_LINK3 = 'https://invertase.io'; module.exports.baseParams = baseParams; -describe('dynamicLinks()', function() { - describe('namespace', function() { - it('accessible from firebase.app()', function() { +describe('dynamicLinks()', function () { + describe('namespace', function () { + it('accessible from firebase.app()', function () { const app = firebase.app(); should.exist(app.dynamicLinks); app.dynamicLinks().app.should.equal(app); }); }); - describe('buildLink()', function() { - it('returns a dynamic link', async function() { + describe('buildLink()', function () { + it('returns a dynamic link', async function () { const link = await firebase.dynamicLinks().buildLink(baseParams); link.should.be.String(); link.length.should.be.greaterThan(6); }); }); - describe('buildShortLink()', function() { - it('returns a short link', async function() { + describe('buildShortLink()', function () { + it('returns a short link', async function () { const link = await firebase.dynamicLinks().buildShortLink(baseParams); link.should.be.String(); link.length.should.be.greaterThan(6); }); - it('throws if type is invalid', function() { + it('throws if type is invalid', function () { try { firebase.dynamicLinks().buildShortLink(baseParams, 'LONG'); return Promise.reject(new Error('Did not throw Error.')); @@ -65,15 +65,15 @@ describe('dynamicLinks()', function() { }); }); - describe('resolveLink()', function() { - it('resolves a long link', async function() { + describe('resolveLink()', function () { + it('resolves a long link', async function () { const link = await firebase.dynamicLinks().resolveLink(TEST_LINK2); link.should.be.an.Object(); link.url.should.equal('https://invertase.io/hire-us'); should.equal(link.minimumAppVersion, null); }); - it('resolves a short link', async function() { + it('resolves a short link', async function () { const shortLink = await firebase.dynamicLinks().buildShortLink( { ...baseParams, @@ -101,7 +101,7 @@ describe('dynamicLinks()', function() { parseInt(link.minimumAppVersion, 10).should.equal(123); }); - it('throws on links that do not exist', async function() { + it('throws on links that do not exist', async function () { try { await firebase.dynamicLinks().resolveLink(baseParams.domainUriPrefix + '/not-a-valid-link'); return Promise.reject(new Error('Did not throw Error.')); @@ -112,7 +112,7 @@ describe('dynamicLinks()', function() { } }); - it('throws on static links', async function() { + it('throws on static links', async function () { try { await firebase.dynamicLinks().resolveLink(TEST_LINK3); return Promise.reject(new Error('Did not throw Error.')); @@ -122,7 +122,7 @@ describe('dynamicLinks()', function() { } }); - it('throws on invalid links', async function() { + it('throws on invalid links', async function () { try { await firebase.dynamicLinks().resolveLink(null); return Promise.reject(new Error('Did not throw Error.')); @@ -146,7 +146,7 @@ describe('dynamicLinks()', function() { }); ios.describe('getInitialLink()', () => { - it('should return the dynamic link instance that launched the app', async function() { + it('should return the dynamic link instance that launched the app', async function () { await device.openURL({ url: TEST_LINK, }); @@ -159,7 +159,7 @@ describe('dynamicLinks()', function() { }); ios.describe('onLink()', () => { - it('should emit dynamic links', async function() { + it('should emit dynamic links', async function () { const spy = sinon.spy(); firebase.dynamicLinks().onLink(spy); diff --git a/packages/dynamic-links/lib/index.d.ts b/packages/dynamic-links/lib/index.d.ts index fd956a59c8..f1c7c8140d 100644 --- a/packages/dynamic-links/lib/index.d.ts +++ b/packages/dynamic-links/lib/index.d.ts @@ -540,7 +540,7 @@ export namespace FirebaseDynamicLinksTypes { * @returns Unsubscribe function, call the returned function to unsubscribe from all future events. * @param listener The listener callback, called with Dynamic Link instances. */ - onLink(listener: (link: DynamicLink) => void): Function; + onLink(listener: (link: DynamicLink) => void): () => void; /** * Resolve a given dynamic link (short or long) directly. @@ -584,6 +584,7 @@ export default defaultExport; * Attach namespace to `firebase.` and `FirebaseApp.`. */ declare module '@react-native-firebase/app' { + // eslint-disable-next-line @typescript-eslint/no-unused-vars namespace ReactNativeFirebase { import FirebaseModuleWithStatics = ReactNativeFirebase.FirebaseModuleWithStatics; diff --git a/packages/firestore/e2e/Blob.e2e.js b/packages/firestore/e2e/Blob.e2e.js index bd95109a51..7e5479b8f3 100644 --- a/packages/firestore/e2e/Blob.e2e.js +++ b/packages/firestore/e2e/Blob.e2e.js @@ -25,8 +25,8 @@ const testStringLarge = JSON.stringify(testObjectLarge); const testBufferLarge = Buffer.from(testStringLarge); const testBase64Large = testBufferLarge.toString('base64'); -describe('firestore.Blob', function() { - it('should throw if constructed manually', function() { +describe('firestore.Blob', function () { + it('should throw if constructed manually', function () { try { new firebase.firestore.Blob(); return Promise.reject(new Error('Did not throw an Error.')); @@ -36,12 +36,12 @@ describe('firestore.Blob', function() { } }); - it('should be exported as a static', function() { + it('should be exported as a static', function () { const { Blob } = firebase.firestore; should.exist(Blob); }); - it('.fromBase64String() -> returns new instance of Blob', async function() { + it('.fromBase64String() -> returns new instance of Blob', async function () { const { Blob } = firebase.firestore; const myBlob = Blob.fromBase64String(testBase64); myBlob.should.be.instanceOf(Blob); @@ -53,7 +53,7 @@ describe('firestore.Blob', function() { ); }); - it('.fromBase64String() -> throws if arg not typeof string and length > 0', async function() { + it('.fromBase64String() -> throws if arg not typeof string and length > 0', async function () { const { Blob } = firebase.firestore; const myBlob = Blob.fromBase64String(testBase64); myBlob.should.be.instanceOf(Blob); @@ -61,7 +61,7 @@ describe('firestore.Blob', function() { (() => Blob.fromBase64String('')).should.throwError(); }); - it('.fromUint8Array() -> returns new instance of Blob', async function() { + it('.fromUint8Array() -> returns new instance of Blob', async function () { const testUInt8Array = new jet.context.window.Uint8Array(testBuffer); const { Blob } = firebase.firestore; const myBlob = Blob.fromUint8Array(testUInt8Array); @@ -70,7 +70,7 @@ describe('firestore.Blob', function() { json.hello.should.equal('world'); }); - it('.fromUint8Array() -> throws if arg not instanceof Uint8Array', async function() { + it('.fromUint8Array() -> throws if arg not instanceof Uint8Array', async function () { const testUInt8Array = new jet.context.window.Uint8Array(testBuffer); const { Blob } = firebase.firestore; const myBlob = Blob.fromUint8Array(testUInt8Array); @@ -78,7 +78,7 @@ describe('firestore.Blob', function() { (() => Blob.fromUint8Array('derp')).should.throwError(); }); - it('.toString() -> returns string representation of blob instance', async function() { + it('.toString() -> returns string representation of blob instance', async function () { const { Blob } = firebase.firestore; const myBlob = Blob.fromBase64String(testBase64); myBlob.should.be.instanceOf(Blob); @@ -89,7 +89,7 @@ describe('firestore.Blob', function() { ); }); - it('.isEqual() -> returns true or false', async function() { + it('.isEqual() -> returns true or false', async function () { const { Blob } = firebase.firestore; const myBlob = Blob.fromBase64String(testBase64); const myBlob2 = Blob.fromBase64String(testBase64Large); @@ -97,7 +97,7 @@ describe('firestore.Blob', function() { myBlob2.isEqual(myBlob).should.equal(false); }); - it('.isEqual() -> throws if arg not instanceof Blob', async function() { + it('.isEqual() -> throws if arg not instanceof Blob', async function () { const { Blob } = firebase.firestore; const myBlob = Blob.fromBase64String(testBase64); const myBlob2 = Blob.fromBase64String(testBase64Large); @@ -105,14 +105,14 @@ describe('firestore.Blob', function() { (() => myBlob2.isEqual('derp')).should.throwError(); }); - it('.toBase64() -> returns base64 string', async function() { + it('.toBase64() -> returns base64 string', async function () { const { Blob } = firebase.firestore; const myBlob = Blob.fromBase64String(testBase64); myBlob.should.be.instanceOf(Blob); myBlob.toBase64().should.equal(testBase64); }); - it('.toUint8Array() -> returns Uint8Array', async function() { + it('.toUint8Array() -> returns Uint8Array', async function () { const { Blob } = firebase.firestore; const myBlob = Blob.fromBase64String(testBase64); const testUInt8Array = new jet.context.window.Uint8Array(testBuffer); diff --git a/packages/firestore/e2e/CollectionReference/add.e2e.js b/packages/firestore/e2e/CollectionReference/add.e2e.js index 6bc382102d..6acfde75e0 100644 --- a/packages/firestore/e2e/CollectionReference/add.e2e.js +++ b/packages/firestore/e2e/CollectionReference/add.e2e.js @@ -17,16 +17,13 @@ const { wipe } = require('../helpers'); const COLLECTION = 'firestore'; -describe('firestore.collection().add()', function() { - before(function() { +describe('firestore.collection().add()', function () { + before(function () { return wipe(); }); - it('throws if data is not an object', function() { + it('throws if data is not an object', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .add(123); + firebase.firestore().collection(COLLECTION).add(123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'data' must be an object"); @@ -34,12 +31,9 @@ describe('firestore.collection().add()', function() { } }); - it('adds a new document', async function() { + it('adds a new document', async function () { const data = { foo: 'bar' }; - const docRef = await firebase - .firestore() - .collection(COLLECTION) - .add(data); + const docRef = await firebase.firestore().collection(COLLECTION).add(data); should.equal(docRef.constructor.name, 'FirestoreDocumentReference'); const docSnap = await docRef.get(); docSnap.data().should.eql(jet.contextify(data)); diff --git a/packages/firestore/e2e/CollectionReference/doc.e2e.js b/packages/firestore/e2e/CollectionReference/doc.e2e.js index 6bbd1a3b1b..9be4063783 100644 --- a/packages/firestore/e2e/CollectionReference/doc.e2e.js +++ b/packages/firestore/e2e/CollectionReference/doc.e2e.js @@ -17,16 +17,13 @@ const { wipe } = require('../helpers'); const COLLECTION = 'firestore'; -describe('firestore.collection().doc()', function() { - before(function() { +describe('firestore.collection().doc()', function () { + before(function () { return wipe(); }); - it('throws if path is not a document', function() { + it('throws if path is not a document', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .doc('bar/baz'); + firebase.firestore().collection(COLLECTION).doc('bar/baz'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'documentPath' must point to a document"); @@ -34,19 +31,13 @@ describe('firestore.collection().doc()', function() { } }); - it('generates an ID if no path is provided', function() { - const instance = firebase - .firestore() - .collection(COLLECTION) - .doc(); + it('generates an ID if no path is provided', function () { + const instance = firebase.firestore().collection(COLLECTION).doc(); should.equal(20, instance.id.length); }); - it('uses path if provided', function() { - const instance = firebase - .firestore() - .collection(COLLECTION) - .doc('bar'); + it('uses path if provided', function () { + const instance = firebase.firestore().collection(COLLECTION).doc('bar'); instance.id.should.eql('bar'); }); }); diff --git a/packages/firestore/e2e/CollectionReference/properties.e2e.js b/packages/firestore/e2e/CollectionReference/properties.e2e.js index 4742e7dd4d..a0aa3e63dc 100644 --- a/packages/firestore/e2e/CollectionReference/properties.e2e.js +++ b/packages/firestore/e2e/CollectionReference/properties.e2e.js @@ -17,41 +17,33 @@ const { wipe } = require('../helpers'); const COLLECTION = 'firestore'; -describe('firestore.collection()', function() { - before(function() { +describe('firestore.collection()', function () { + before(function () { return wipe(); }); - it('returns the firestore instance', function() { + it('returns the firestore instance', function () { const instance = firebase.firestore().collection(COLLECTION); instance.firestore.app.name.should.eql('[DEFAULT]'); }); - it('returns the collection id', function() { + it('returns the collection id', function () { const instance1 = firebase.firestore().collection(COLLECTION); const instance2 = firebase.firestore().collection(`${COLLECTION}/bar/baz`); instance1.id.should.eql(COLLECTION); instance2.id.should.eql('baz'); }); - it('returns the collection parent', function() { + it('returns the collection parent', function () { const instance1 = firebase.firestore().collection(COLLECTION); should.equal(instance1.parent, null); - const instance2 = firebase - .firestore() - .collection('foo') - .doc('bar') - .collection('baz'); + const instance2 = firebase.firestore().collection('foo').doc('bar').collection('baz'); should.equal(instance2.parent.id, 'bar'); }); - it('returns the firestore path', function() { + it('returns the firestore path', function () { const instance1 = firebase.firestore().collection(COLLECTION); instance1.path.should.eql(COLLECTION); - const instance2 = firebase - .firestore() - .collection(COLLECTION) - .doc('bar') - .collection(COLLECTION); + const instance2 = firebase.firestore().collection(COLLECTION).doc('bar').collection(COLLECTION); instance2.path.should.eql(`${COLLECTION}/bar/${COLLECTION}`); }); }); diff --git a/packages/firestore/e2e/DocumentChange.e2e.js b/packages/firestore/e2e/DocumentChange.e2e.js index f96a47ca65..17015f3b71 100644 --- a/packages/firestore/e2e/DocumentChange.e2e.js +++ b/packages/firestore/e2e/DocumentChange.e2e.js @@ -17,11 +17,11 @@ const { wipe } = require('./helpers'); const COLLECTION = 'firestore'; -describe('firestore.DocumentChange', function() { - before(function() { +describe('firestore.DocumentChange', function () { + before(function () { return wipe(); }); - it('.doc -> returns a DocumentSnapshot', async function() { + it('.doc -> returns a DocumentSnapshot', async function () { const colRef = firebase.firestore().collection(COLLECTION); await colRef.add({}); const snapshot = await colRef.limit(1).get(); @@ -32,7 +32,7 @@ describe('firestore.DocumentChange', function() { docChange.doc.constructor.name.should.eql('FirestoreDocumentSnapshot'); }); - it('returns the correct metadata when adding and removing', async function() { + it('returns the correct metadata when adding and removing', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/docChanges/docChangesCollection`); const doc1 = firebase.firestore().doc(`${COLLECTION}/docChanges/docChangesCollection/doc1`); @@ -72,7 +72,7 @@ describe('firestore.DocumentChange', function() { unsub(); }); - it('returns the correct metadata when modifying documents', async function() { + it('returns the correct metadata when modifying documents', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/docChanges/docMovedCollection`); const doc1 = firebase.firestore().doc(`${COLLECTION}/docChanges/docMovedCollection/doc1`); diff --git a/packages/firestore/e2e/DocumentReference/collection.e2e.js b/packages/firestore/e2e/DocumentReference/collection.e2e.js index 9615035914..1cb8a05f42 100644 --- a/packages/firestore/e2e/DocumentReference/collection.e2e.js +++ b/packages/firestore/e2e/DocumentReference/collection.e2e.js @@ -17,13 +17,10 @@ const COLLECTION = 'firestore'; -describe('firestore.doc().collection()', function() { - it('throws if path is not a string', function() { +describe('firestore.doc().collection()', function () { + it('throws if path is not a string', function () { try { - firebase - .firestore() - .doc('bar/baz') - .collection(123); + firebase.firestore().doc('bar/baz').collection(123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'collectionPath' must be a string value"); @@ -31,12 +28,9 @@ describe('firestore.doc().collection()', function() { } }); - it('throws if path empty', function() { + it('throws if path empty', function () { try { - firebase - .firestore() - .doc('bar/baz') - .collection(''); + firebase.firestore().doc('bar/baz').collection(''); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'collectionPath' must be a non-empty string"); @@ -44,12 +38,9 @@ describe('firestore.doc().collection()', function() { } }); - it('throws if path does not point to a collection', function() { + it('throws if path does not point to a collection', function () { try { - firebase - .firestore() - .doc('bar/baz') - .collection(`${COLLECTION}/bar`); + firebase.firestore().doc('bar/baz').collection(`${COLLECTION}/bar`); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'collectionPath' must point to a collection"); @@ -57,16 +48,9 @@ describe('firestore.doc().collection()', function() { } }); - it('returns a collection instance', function() { - const instance1 = firebase - .firestore() - .doc(`${COLLECTION}/bar`) - .collection(COLLECTION); - const instance2 = firebase - .firestore() - .collection(COLLECTION) - .doc('bar') - .collection(COLLECTION); + it('returns a collection instance', function () { + const instance1 = firebase.firestore().doc(`${COLLECTION}/bar`).collection(COLLECTION); + const instance2 = firebase.firestore().collection(COLLECTION).doc('bar').collection(COLLECTION); should.equal(instance1.constructor.name, 'FirestoreCollectionReference'); should.equal(instance2.constructor.name, 'FirestoreCollectionReference'); instance1.id.should.equal(COLLECTION); diff --git a/packages/firestore/e2e/DocumentReference/delete.e2e.js b/packages/firestore/e2e/DocumentReference/delete.e2e.js index c856f767e4..c9fa45e62f 100644 --- a/packages/firestore/e2e/DocumentReference/delete.e2e.js +++ b/packages/firestore/e2e/DocumentReference/delete.e2e.js @@ -17,11 +17,11 @@ const { wipe } = require('../helpers'); const COLLECTION = 'firestore'; -describe('firestore.doc().delete()', function() { - before(function() { +describe('firestore.doc().delete()', function () { + before(function () { return wipe(); }); - it('deletes a document', async function() { + it('deletes a document', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/deleteme`); await ref.set({ foo: 'bar' }); const snapshot1 = await ref.get(); diff --git a/packages/firestore/e2e/DocumentReference/get.e2e.js b/packages/firestore/e2e/DocumentReference/get.e2e.js index bb12c683f8..b4ddd576e8 100644 --- a/packages/firestore/e2e/DocumentReference/get.e2e.js +++ b/packages/firestore/e2e/DocumentReference/get.e2e.js @@ -17,16 +17,13 @@ const { wipe } = require('../helpers'); const COLLECTION = 'firestore'; -describe('firestore.doc().get()', function() { - before(function() { +describe('firestore.doc().get()', function () { + before(function () { return wipe(); }); - it('throws if get options are not an object', function() { + it('throws if get options are not an object', function () { try { - firebase - .firestore() - .doc('bar/baz') - .get('foo'); + firebase.firestore().doc('bar/baz').get('foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'options' must be an object is provided"); @@ -34,12 +31,9 @@ describe('firestore.doc().get()', function() { } }); - it('throws if get options are invalid', function() { + it('throws if get options are invalid', function () { try { - firebase - .firestore() - .doc('bar/baz') - .get({ source: 'nope' }); + firebase.firestore().doc('bar/baz').get({ source: 'nope' }); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -49,7 +43,7 @@ describe('firestore.doc().get()', function() { } }); - it('gets data from default source', async function() { + it('gets data from default source', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/get`); const data = { foo: 'bar', bar: 123 }; await ref.set(data); @@ -58,7 +52,7 @@ describe('firestore.doc().get()', function() { await ref.delete(); }); - it('gets data from the server', async function() { + it('gets data from the server', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/get`); const data = { foo: 'bar', bar: 123 }; await ref.set(data); @@ -68,7 +62,7 @@ describe('firestore.doc().get()', function() { await ref.delete(); }); - it('gets data from cache', async function() { + it('gets data from cache', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/get`); const data = { foo: 'bar', bar: 123 }; await ref.set(data); diff --git a/packages/firestore/e2e/DocumentReference/isEqual.e2e.js b/packages/firestore/e2e/DocumentReference/isEqual.e2e.js index 019c10f37b..06293b98bc 100644 --- a/packages/firestore/e2e/DocumentReference/isEqual.e2e.js +++ b/packages/firestore/e2e/DocumentReference/isEqual.e2e.js @@ -16,13 +16,10 @@ */ const COLLECTION = 'firestore'; -describe('firestore.doc().isEqual()', function() { - it('throws if other is not a DocumentReference', function() { +describe('firestore.doc().isEqual()', function () { + it('throws if other is not a DocumentReference', function () { try { - firebase - .firestore() - .doc('bar/baz') - .isEqual(123); + firebase.firestore().doc('bar/baz').isEqual(123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'other' expected a DocumentReference instance"); @@ -30,7 +27,7 @@ describe('firestore.doc().isEqual()', function() { } }); - it('returns false when not equal', function() { + it('returns false when not equal', function () { const docRef = firebase.firestore().doc(`${COLLECTION}/baz`); const eql1 = docRef.isEqual(firebase.firestore().doc(`${COLLECTION}/foo`)); @@ -42,7 +39,7 @@ describe('firestore.doc().isEqual()', function() { eql2.should.be.False(); }); - it('returns true when equal', function() { + it('returns true when equal', function () { const docRef = firebase.firestore().doc(`${COLLECTION}/baz`); const eql1 = docRef.isEqual(docRef); diff --git a/packages/firestore/e2e/DocumentReference/onSnapshot.e2e.js b/packages/firestore/e2e/DocumentReference/onSnapshot.e2e.js index 5c8bf69dd6..3d596aa404 100644 --- a/packages/firestore/e2e/DocumentReference/onSnapshot.e2e.js +++ b/packages/firestore/e2e/DocumentReference/onSnapshot.e2e.js @@ -18,16 +18,13 @@ const COLLECTION = 'firestore'; const NO_RULE_COLLECTION = 'no_rules'; const { wipe } = require('../helpers'); -describe('firestore().doc().onSnapshot()', function() { - before(function() { +describe('firestore().doc().onSnapshot()', function () { + before(function () { return wipe(); }); - it('throws if no arguments are provided', function() { + it('throws if no arguments are provided', function () { try { - firebase - .firestore() - .doc(`${COLLECTION}/foo`) - .onSnapshot(); + firebase.firestore().doc(`${COLLECTION}/foo`).onSnapshot(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('expected at least one argument'); @@ -35,7 +32,7 @@ describe('firestore().doc().onSnapshot()', function() { } }); - it('returns an unsubscribe function', function() { + it('returns an unsubscribe function', function () { const unsub = firebase .firestore() .doc(`${COLLECTION}/foo`) @@ -45,12 +42,9 @@ describe('firestore().doc().onSnapshot()', function() { unsub(); }); - it('accepts a single callback function with snapshot', async function() { + it('accepts a single callback function with snapshot', async function () { const callback = sinon.spy(); - const unsub = firebase - .firestore() - .doc(`${COLLECTION}/foo`) - .onSnapshot(callback); + const unsub = firebase.firestore().doc(`${COLLECTION}/foo`).onSnapshot(callback); await Utils.spyToBeCalledOnceAsync(callback); @@ -60,12 +54,9 @@ describe('firestore().doc().onSnapshot()', function() { unsub(); }); - it('accepts a single callback function with Error', async function() { + it('accepts a single callback function with Error', async function () { const callback = sinon.spy(); - const unsub = firebase - .firestore() - .doc(`${NO_RULE_COLLECTION}/nope`) - .onSnapshot(callback); + const unsub = firebase.firestore().doc(`${NO_RULE_COLLECTION}/nope`).onSnapshot(callback); await Utils.spyToBeCalledOnceAsync(callback); @@ -75,14 +66,11 @@ describe('firestore().doc().onSnapshot()', function() { unsub(); }); - describe('multiple callbacks', function() { - it('calls onNext when successful', async function() { + describe('multiple callbacks', function () { + it('calls onNext when successful', async function () { const onNext = sinon.spy(); const onError = sinon.spy(); - const unsub = firebase - .firestore() - .doc(`${COLLECTION}/foo`) - .onSnapshot(onNext, onError); + const unsub = firebase.firestore().doc(`${COLLECTION}/foo`).onSnapshot(onNext, onError); await Utils.spyToBeCalledOnceAsync(onNext); @@ -93,7 +81,7 @@ describe('firestore().doc().onSnapshot()', function() { unsub(); }); - it('calls onError with Error', async function() { + it('calls onError with Error', async function () { const onNext = sinon.spy(); const onError = sinon.spy(); const unsub = firebase @@ -111,17 +99,14 @@ describe('firestore().doc().onSnapshot()', function() { }); }); - describe('objects of callbacks', function() { - it('calls next when successful', async function() { + describe('objects of callbacks', function () { + it('calls next when successful', async function () { const onNext = sinon.spy(); const onError = sinon.spy(); - const unsub = firebase - .firestore() - .doc(`${COLLECTION}/foo`) - .onSnapshot({ - next: onNext, - error: onError, - }); + const unsub = firebase.firestore().doc(`${COLLECTION}/foo`).onSnapshot({ + next: onNext, + error: onError, + }); await Utils.spyToBeCalledOnceAsync(onNext); @@ -132,16 +117,13 @@ describe('firestore().doc().onSnapshot()', function() { unsub(); }); - it('calls error with Error', async function() { + it('calls error with Error', async function () { const onNext = sinon.spy(); const onError = sinon.spy(); - const unsub = firebase - .firestore() - .doc(`${NO_RULE_COLLECTION}/nope`) - .onSnapshot({ - next: onNext, - error: onError, - }); + const unsub = firebase.firestore().doc(`${NO_RULE_COLLECTION}/nope`).onSnapshot({ + next: onNext, + error: onError, + }); await Utils.spyToBeCalledOnceAsync(onError); @@ -153,18 +135,15 @@ describe('firestore().doc().onSnapshot()', function() { }); }); - describe('SnapshotListenerOptions + callbacks', function() { - it('calls callback with snapshot when successful', async function() { + describe('SnapshotListenerOptions + callbacks', function () { + it('calls callback with snapshot when successful', async function () { const callback = sinon.spy(); - const unsub = firebase - .firestore() - .doc(`${COLLECTION}/foo`) - .onSnapshot( - { - includeMetadataChanges: false, - }, - callback, - ); + const unsub = firebase.firestore().doc(`${COLLECTION}/foo`).onSnapshot( + { + includeMetadataChanges: false, + }, + callback, + ); await Utils.spyToBeCalledOnceAsync(callback); @@ -174,17 +153,14 @@ describe('firestore().doc().onSnapshot()', function() { unsub(); }); - it('calls callback with Error', async function() { + it('calls callback with Error', async function () { const callback = sinon.spy(); - const unsub = firebase - .firestore() - .doc(`${NO_RULE_COLLECTION}/nope`) - .onSnapshot( - { - includeMetadataChanges: false, - }, - callback, - ); + const unsub = firebase.firestore().doc(`${NO_RULE_COLLECTION}/nope`).onSnapshot( + { + includeMetadataChanges: false, + }, + callback, + ); await Utils.spyToBeCalledOnceAsync(callback); @@ -194,19 +170,16 @@ describe('firestore().doc().onSnapshot()', function() { unsub(); }); - it('calls next with snapshot when successful', async function() { + it('calls next with snapshot when successful', async function () { const onNext = sinon.spy(); const onError = sinon.spy(); - const unsub = firebase - .firestore() - .doc(`${COLLECTION}/foo`) - .onSnapshot( - { - includeMetadataChanges: false, - }, - onNext, - onError, - ); + const unsub = firebase.firestore().doc(`${COLLECTION}/foo`).onSnapshot( + { + includeMetadataChanges: false, + }, + onNext, + onError, + ); await Utils.spyToBeCalledOnceAsync(onNext); @@ -217,19 +190,16 @@ describe('firestore().doc().onSnapshot()', function() { unsub(); }); - it('calls error with Error', async function() { + it('calls error with Error', async function () { const onNext = sinon.spy(); const onError = sinon.spy(); - const unsub = firebase - .firestore() - .doc(`${NO_RULE_COLLECTION}/nope`) - .onSnapshot( - { - includeMetadataChanges: false, - }, - onNext, - onError, - ); + const unsub = firebase.firestore().doc(`${NO_RULE_COLLECTION}/nope`).onSnapshot( + { + includeMetadataChanges: false, + }, + onNext, + onError, + ); await Utils.spyToBeCalledOnceAsync(onError); @@ -241,22 +211,19 @@ describe('firestore().doc().onSnapshot()', function() { }); }); - describe('SnapshotListenerOptions + object of callbacks', function() { - it('calls next with snapshot when successful', async function() { + describe('SnapshotListenerOptions + object of callbacks', function () { + it('calls next with snapshot when successful', async function () { const onNext = sinon.spy(); const onError = sinon.spy(); - const unsub = firebase - .firestore() - .doc(`${COLLECTION}/foo`) - .onSnapshot( - { - includeMetadataChanges: false, - }, - { - next: onNext, - error: onError, - }, - ); + const unsub = firebase.firestore().doc(`${COLLECTION}/foo`).onSnapshot( + { + includeMetadataChanges: false, + }, + { + next: onNext, + error: onError, + }, + ); await Utils.spyToBeCalledOnceAsync(onNext); @@ -267,21 +234,18 @@ describe('firestore().doc().onSnapshot()', function() { unsub(); }); - it('calls error with Error', async function() { + it('calls error with Error', async function () { const onNext = sinon.spy(); const onError = sinon.spy(); - const unsub = firebase - .firestore() - .doc(`${NO_RULE_COLLECTION}/nope`) - .onSnapshot( - { - includeMetadataChanges: false, - }, - { - next: onNext, - error: onError, - }, - ); + const unsub = firebase.firestore().doc(`${NO_RULE_COLLECTION}/nope`).onSnapshot( + { + includeMetadataChanges: false, + }, + { + next: onNext, + error: onError, + }, + ); await Utils.spyToBeCalledOnceAsync(onError); @@ -293,14 +257,11 @@ describe('firestore().doc().onSnapshot()', function() { }); }); - it('throws if SnapshotListenerOptions is invalid', function() { + it('throws if SnapshotListenerOptions is invalid', function () { try { - firebase - .firestore() - .doc(`${NO_RULE_COLLECTION}/nope`) - .onSnapshot({ - includeMetadataChanges: 123, - }); + firebase.firestore().doc(`${NO_RULE_COLLECTION}/nope`).onSnapshot({ + includeMetadataChanges: 123, + }); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -310,14 +271,11 @@ describe('firestore().doc().onSnapshot()', function() { } }); - it('throws if next callback is invalid', function() { + it('throws if next callback is invalid', function () { try { - firebase - .firestore() - .doc(`${NO_RULE_COLLECTION}/nope`) - .onSnapshot({ - next: 'foo', - }); + firebase.firestore().doc(`${NO_RULE_COLLECTION}/nope`).onSnapshot({ + next: 'foo', + }); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'observer.next' or 'onNext' expected a function"); @@ -325,14 +283,11 @@ describe('firestore().doc().onSnapshot()', function() { } }); - it('throws if error callback is invalid', function() { + it('throws if error callback is invalid', function () { try { - firebase - .firestore() - .doc(`${NO_RULE_COLLECTION}/nope`) - .onSnapshot({ - error: 'foo', - }); + firebase.firestore().doc(`${NO_RULE_COLLECTION}/nope`).onSnapshot({ + error: 'foo', + }); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'observer.error' or 'onError' expected a function"); @@ -340,7 +295,7 @@ describe('firestore().doc().onSnapshot()', function() { } }); - it('unsubscribes from further updates', async function() { + it('unsubscribes from further updates', async function () { const callback = sinon.spy(); const doc = firebase.firestore().doc(`${COLLECTION}/unsub`); diff --git a/packages/firestore/e2e/DocumentReference/properties.e2e.js b/packages/firestore/e2e/DocumentReference/properties.e2e.js index 23c31ccdea..50432a40df 100644 --- a/packages/firestore/e2e/DocumentReference/properties.e2e.js +++ b/packages/firestore/e2e/DocumentReference/properties.e2e.js @@ -17,28 +17,25 @@ const COLLECTION = 'firestore'; -describe('firestore.doc()', function() { - it('returns a Firestore instance', function() { +describe('firestore.doc()', function () { + it('returns a Firestore instance', function () { const instance = firebase.firestore().doc(`${COLLECTION}/bar`); should.equal(instance.firestore.constructor.name, 'FirebaseFirestoreModule'); }); - it('returns the document id', function() { + it('returns the document id', function () { const instance = firebase.firestore().doc(`${COLLECTION}/bar`); instance.id.should.equal('bar'); }); - it('returns the parent collection reference', function() { + it('returns the parent collection reference', function () { const instance = firebase.firestore().doc(`${COLLECTION}/bar`); instance.parent.id.should.equal(COLLECTION); }); - it('returns the path', function() { + it('returns the path', function () { const instance1 = firebase.firestore().doc(`${COLLECTION}/bar`); - const instance2 = firebase - .firestore() - .collection(COLLECTION) - .doc('bar'); + const instance2 = firebase.firestore().collection(COLLECTION).doc('bar'); instance1.path.should.equal(`${COLLECTION}/bar`); instance2.path.should.equal(`${COLLECTION}/bar`); }); diff --git a/packages/firestore/e2e/DocumentReference/set.e2e.js b/packages/firestore/e2e/DocumentReference/set.e2e.js index ebec2c78f5..22f301712c 100644 --- a/packages/firestore/e2e/DocumentReference/set.e2e.js +++ b/packages/firestore/e2e/DocumentReference/set.e2e.js @@ -17,16 +17,13 @@ const { wipe } = require('../helpers'); const COLLECTION = 'firestore'; -describe('firestore.doc().set()', function() { - before(function() { +describe('firestore.doc().set()', function () { + before(function () { return wipe(); }); - it('throws if data is not an object', function() { + it('throws if data is not an object', function () { try { - firebase - .firestore() - .doc(`${COLLECTION}/baz`) - .set('foo'); + firebase.firestore().doc(`${COLLECTION}/baz`).set('foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'data' must be an object"); @@ -34,12 +31,9 @@ describe('firestore.doc().set()', function() { } }); - it('throws if options is not an object', function() { + it('throws if options is not an object', function () { try { - firebase - .firestore() - .doc(`${COLLECTION}/baz`) - .set({}, 'foo'); + firebase.firestore().doc(`${COLLECTION}/baz`).set({}, 'foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'options' must be an object"); @@ -47,18 +41,15 @@ describe('firestore.doc().set()', function() { } }); - it('throws if options contains both merge types', function() { + it('throws if options contains both merge types', function () { try { - firebase - .firestore() - .doc(`${COLLECTION}/baz`) - .set( - {}, - { - merge: true, - mergeFields: [], - }, - ); + firebase.firestore().doc(`${COLLECTION}/baz`).set( + {}, + { + merge: true, + mergeFields: [], + }, + ); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'options' must not contain both 'merge' & 'mergeFields'"); @@ -66,17 +57,14 @@ describe('firestore.doc().set()', function() { } }); - it('throws if merge is not a boolean', function() { + it('throws if merge is not a boolean', function () { try { - firebase - .firestore() - .doc(`${COLLECTION}/baz`) - .set( - {}, - { - merge: 'foo', - }, - ); + firebase.firestore().doc(`${COLLECTION}/baz`).set( + {}, + { + merge: 'foo', + }, + ); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'options.merge' must be a boolean value"); @@ -84,17 +72,14 @@ describe('firestore.doc().set()', function() { } }); - it('throws if mergeFields is not an array', function() { + it('throws if mergeFields is not an array', function () { try { - firebase - .firestore() - .doc(`${COLLECTION}/baz`) - .set( - {}, - { - mergeFields: 'foo', - }, - ); + firebase.firestore().doc(`${COLLECTION}/baz`).set( + {}, + { + mergeFields: 'foo', + }, + ); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'options.mergeFields' must be an array"); @@ -102,7 +87,7 @@ describe('firestore.doc().set()', function() { } }); - it('throws if mergeFields contains invalid data', function() { + it('throws if mergeFields contains invalid data', function () { try { firebase .firestore() @@ -127,7 +112,7 @@ describe('firestore.doc().set()', function() { } }); - it('sets new data', async function() { + it('sets new data', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/set`); const data1 = { foo: 'bar' }; const data2 = { foo: 'baz', bar: 123 }; @@ -140,7 +125,7 @@ describe('firestore.doc().set()', function() { await ref.delete(); }); - it('merges all fields', async function() { + it('merges all fields', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/merge`); const data1 = { foo: 'bar' }; const data2 = { bar: 'baz' }; @@ -156,7 +141,7 @@ describe('firestore.doc().set()', function() { await ref.delete(); }); - it('merges specific fields', async function() { + it('merges specific fields', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/merge`); const data1 = { foo: '123', bar: 123, baz: '456' }; const data2 = { foo: '234', bar: 234, baz: '678' }; diff --git a/packages/firestore/e2e/DocumentReference/update.e2e.js b/packages/firestore/e2e/DocumentReference/update.e2e.js index a04086c19c..2e517f7c59 100644 --- a/packages/firestore/e2e/DocumentReference/update.e2e.js +++ b/packages/firestore/e2e/DocumentReference/update.e2e.js @@ -17,16 +17,13 @@ const { wipe } = require('../helpers'); const COLLECTION = 'firestore'; -describe('firestore.doc().update()', function() { - before(function() { +describe('firestore.doc().update()', function () { + before(function () { return wipe(); }); - it('throws if no arguments are provided', function() { + it('throws if no arguments are provided', function () { try { - firebase - .firestore() - .doc(`${COLLECTION}/baz`) - .update(); + firebase.firestore().doc(`${COLLECTION}/baz`).update(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -36,12 +33,9 @@ describe('firestore.doc().update()', function() { } }); - it('throws if document does not exist', async function() { + it('throws if document does not exist', async function () { try { - await firebase - .firestore() - .doc(`${COLLECTION}/idonotexistonthedatabase`) - .update({}); + await firebase.firestore().doc(`${COLLECTION}/idonotexistonthedatabase`).update({}); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.code.should.containEql('firestore/not-found'); @@ -49,12 +43,9 @@ describe('firestore.doc().update()', function() { } }); - it('throws if field/value sequence is invalid', function() { + it('throws if field/value sequence is invalid', function () { try { - firebase - .firestore() - .doc(`${COLLECTION}/baz`) - .update('foo', 'bar', 'baz'); + firebase.firestore().doc(`${COLLECTION}/baz`).update('foo', 'bar', 'baz'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('or equal numbers of key/value pairs'); @@ -62,7 +53,7 @@ describe('firestore.doc().update()', function() { } }); - it('updates data with an object value', async function() { + it('updates data with an object value', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/update-obj`); const value = Date.now(); const data1 = { foo: value }; @@ -76,7 +67,7 @@ describe('firestore.doc().update()', function() { await ref.delete(); }); - it('updates data with an key/value pairs', async function() { + it('updates data with an key/value pairs', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/update-obj`); const value = Date.now(); const data1 = { foo: value, bar: value }; diff --git a/packages/firestore/e2e/DocumentSnapshot/data.e2e.js b/packages/firestore/e2e/DocumentSnapshot/data.e2e.js index f392f9b65f..53be5cb13d 100644 --- a/packages/firestore/e2e/DocumentSnapshot/data.e2e.js +++ b/packages/firestore/e2e/DocumentSnapshot/data.e2e.js @@ -23,17 +23,17 @@ const blobString = JSON.stringify(blobObject); const blobBuffer = Buffer.from(blobString); const blobBase64 = blobBuffer.toString('base64'); -describe('firestore().doc() -> snapshot.data()', function() { - before(function() { +describe('firestore().doc() -> snapshot.data()', function () { + before(function () { return wipe(); }); - it('returns undefined if documet does not exist', async function() { + it('returns undefined if documet does not exist', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/idonotexist`); const snapshot = await ref.get(); should.equal(snapshot.data(), undefined); }); - it('returns an object if exists', async function() { + it('returns an object if exists', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/getData`); const data = { foo: 'bar' }; await ref.set(data); @@ -42,7 +42,7 @@ describe('firestore().doc() -> snapshot.data()', function() { await ref.delete(); }); - it('returns an object when document is empty', async function() { + it('returns an object when document is empty', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/getData`); const data = {}; await ref.set(data); @@ -51,11 +51,11 @@ describe('firestore().doc() -> snapshot.data()', function() { await ref.delete(); }); - xit('handles SnapshotOptions', function() { + xit('handles SnapshotOptions', function () { // TODO }); - it('handles all data types', async function() { + it('handles all data types', async function () { const types = { string: '123456', stringEmpty: '', diff --git a/packages/firestore/e2e/DocumentSnapshot/get.e2e.js b/packages/firestore/e2e/DocumentSnapshot/get.e2e.js index d31807804f..c90872ca1f 100644 --- a/packages/firestore/e2e/DocumentSnapshot/get.e2e.js +++ b/packages/firestore/e2e/DocumentSnapshot/get.e2e.js @@ -17,11 +17,11 @@ const { wipe } = require('../helpers'); const COLLECTION = 'firestore'; -describe('firestore().doc() -> snapshot.get()', function() { - before(function() { +describe('firestore().doc() -> snapshot.get()', function () { + before(function () { return wipe(); }); - it('throws if invalid fieldPath argument', async function() { + it('throws if invalid fieldPath argument', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/foo`); const snapshot = await ref.get(); @@ -34,7 +34,7 @@ describe('firestore().doc() -> snapshot.get()', function() { } }); - it('throws if fieldPath is an empty string', async function() { + it('throws if fieldPath is an empty string', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/foo`); const snapshot = await ref.get(); @@ -47,7 +47,7 @@ describe('firestore().doc() -> snapshot.get()', function() { } }); - it('throws if fieldPath starts with a period (.)', async function() { + it('throws if fieldPath starts with a period (.)', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/foo`); const snapshot = await ref.get(); @@ -60,7 +60,7 @@ describe('firestore().doc() -> snapshot.get()', function() { } }); - it('throws if fieldPath ends with a period (.)', async function() { + it('throws if fieldPath ends with a period (.)', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/foo`); const snapshot = await ref.get(); @@ -73,7 +73,7 @@ describe('firestore().doc() -> snapshot.get()', function() { } }); - it('throws if fieldPath contains ..', async function() { + it('throws if fieldPath contains ..', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/foo`); const snapshot = await ref.get(); @@ -86,7 +86,7 @@ describe('firestore().doc() -> snapshot.get()', function() { } }); - it('returns undefined if the data does not exist', async function() { + it('returns undefined if the data does not exist', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/foo`); const snapshot = await ref.get(); @@ -103,7 +103,7 @@ describe('firestore().doc() -> snapshot.get()', function() { should.equal(val5, undefined); }); - it('returns the correct data with string fieldPath', async function() { + it('returns the correct data with string fieldPath', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/foo`); const types = { string: '12345', @@ -133,7 +133,7 @@ describe('firestore().doc() -> snapshot.get()', function() { await ref.delete(); }); - it('returns the correct data with FieldPath', async function() { + it('returns the correct data with FieldPath', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/foo`); const types = { string: '12345', diff --git a/packages/firestore/e2e/DocumentSnapshot/isEqual.e2e.js b/packages/firestore/e2e/DocumentSnapshot/isEqual.e2e.js index e0d91f9553..2d9e86a4ce 100644 --- a/packages/firestore/e2e/DocumentSnapshot/isEqual.e2e.js +++ b/packages/firestore/e2e/DocumentSnapshot/isEqual.e2e.js @@ -16,8 +16,8 @@ */ const COLLECTION = 'firestore'; -describe('firestore.doc() -> snapshot.isEqual()', function() { - it('throws if other is not a DocumentSnapshot', async function() { +describe('firestore.doc() -> snapshot.isEqual()', function () { + it('throws if other is not a DocumentSnapshot', async function () { try { const docRef = firebase.firestore().doc(`${COLLECTION}/baz`); @@ -30,15 +30,12 @@ describe('firestore.doc() -> snapshot.isEqual()', function() { } }); - it('returns false when not equal', async function() { + it('returns false when not equal', async function () { const docRef = firebase.firestore().doc(`${COLLECTION}/isEqual-false-exists`); await docRef.set({ foo: 'bar' }); const docSnapshot1 = await docRef.get(); - const docSnapshot2 = await firebase - .firestore() - .doc(`${COLLECTION}/idonotexist`) - .get(); + const docSnapshot2 = await firebase.firestore().doc(`${COLLECTION}/idonotexist`).get(); await docRef.set({ foo: 'baz' }); const docSnapshot3 = await docRef.get(); @@ -49,7 +46,7 @@ describe('firestore.doc() -> snapshot.isEqual()', function() { eql2.should.be.False(); }); - it('returns true when equal', async function() { + it('returns true when equal', async function () { const docRef = firebase.firestore().doc(`${COLLECTION}/isEqual-true-exists`); await docRef.set({ foo: 'bar' }); diff --git a/packages/firestore/e2e/DocumentSnapshot/properties.e2e.js b/packages/firestore/e2e/DocumentSnapshot/properties.e2e.js index 7c667a40b9..1ece46495c 100644 --- a/packages/firestore/e2e/DocumentSnapshot/properties.e2e.js +++ b/packages/firestore/e2e/DocumentSnapshot/properties.e2e.js @@ -17,11 +17,11 @@ const { wipe } = require('../helpers'); const COLLECTION = 'firestore'; -describe('firestore().doc() -> snapshot', function() { - before(function() { +describe('firestore().doc() -> snapshot', function () { + before(function () { return wipe(); }); - it('.exists -> returns a boolean for exists', async function() { + it('.exists -> returns a boolean for exists', async function () { const ref1 = firebase.firestore().doc(`${COLLECTION}/exists`); const ref2 = firebase.firestore().doc(`${COLLECTION}/idonotexist`); await ref1.set({ foo: ' bar' }); @@ -33,7 +33,7 @@ describe('firestore().doc() -> snapshot', function() { await ref1.delete(); }); - it('.id -> returns the correct id', async function() { + it('.id -> returns the correct id', async function () { const ref1 = firebase.firestore().doc(`${COLLECTION}/exists`); const ref2 = firebase.firestore().doc(`${COLLECTION}/idonotexist`); await ref1.set({ foo: ' bar' }); @@ -45,13 +45,13 @@ describe('firestore().doc() -> snapshot', function() { await ref1.delete(); }); - it('.metadata -> returns a SnapshotMetadata instance', async function() { + it('.metadata -> returns a SnapshotMetadata instance', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/exists`); const snapshot = await ref.get(); snapshot.metadata.constructor.name.should.eql('FirestoreSnapshotMetadata'); }); - it('.ref -> returns the correct document ref', async function() { + it('.ref -> returns the correct document ref', async function () { const ref1 = firebase.firestore().doc(`${COLLECTION}/exists`); const ref2 = firebase.firestore().doc(`${COLLECTION}/idonotexist`); await ref1.set({ foo: ' bar' }); diff --git a/packages/firestore/e2e/FieldPath.e2e.js b/packages/firestore/e2e/FieldPath.e2e.js index 16682a5872..d6d02fa73c 100644 --- a/packages/firestore/e2e/FieldPath.e2e.js +++ b/packages/firestore/e2e/FieldPath.e2e.js @@ -16,8 +16,8 @@ */ const COLLECTION = 'firestore'; -describe('firestore.FieldPath', function() { - it('should throw if no segments', function() { +describe('firestore.FieldPath', function () { + it('should throw if no segments', function () { try { new firebase.firestore.FieldPath(); return Promise.reject(new Error('Did not throw an Error.')); @@ -27,7 +27,7 @@ describe('firestore.FieldPath', function() { } }); - it('should throw if any segments are empty strings', function() { + it('should throw if any segments are empty strings', function () { try { new firebase.firestore.FieldPath('foo', ''); return Promise.reject(new Error('Did not throw an Error.')); @@ -37,7 +37,7 @@ describe('firestore.FieldPath', function() { } }); - it('should throw if any segments are not strings', function() { + it('should throw if any segments are not strings', function () { try { new firebase.firestore.FieldPath('foo', 123); return Promise.reject(new Error('Did not throw an Error.')); @@ -47,13 +47,10 @@ describe('firestore.FieldPath', function() { } }); - it('should throw if string fieldPath is invalid', function() { + it('should throw if string fieldPath is invalid', function () { try { // Dummy create - firebase - .firestore() - .collection(COLLECTION) - .where('.foo', '<', 123); + firebase.firestore().collection(COLLECTION).where('.foo', '<', 123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('Invalid field path'); @@ -61,13 +58,10 @@ describe('firestore.FieldPath', function() { } }); - it('should throw if string fieldPath contains invalid characters', function() { + it('should throw if string fieldPath contains invalid characters', function () { try { // Dummy create - firebase - .firestore() - .collection(COLLECTION) - .where('foo/bar', '<', 123); + firebase.firestore().collection(COLLECTION).where('foo/bar', '<', 123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('Paths must not contain'); @@ -75,27 +69,27 @@ describe('firestore.FieldPath', function() { } }); - it('should provide access to segments as array', function() { + it('should provide access to segments as array', function () { const expect = ['foo', 'bar', 'baz']; const path = new firebase.firestore.FieldPath('foo', 'bar', 'baz'); path._segments.should.eql(jet.contextify(expect)); }); - it('should provide access to string dot notated path', function() { + it('should provide access to string dot notated path', function () { const expect = 'foo.bar.baz'; const path = new firebase.firestore.FieldPath('foo', 'bar', 'baz'); path._toPath().should.equal(expect); }); - it('should return document ID path', function() { + it('should return document ID path', function () { const expect = '__name__'; const path = firebase.firestore.FieldPath.documentId(); path._segments.length.should.equal(1); path._toPath().should.equal(expect); }); - describe('isEqual()', function() { - it('throws if other isnt a FieldPath', function() { + describe('isEqual()', function () { + it('throws if other isnt a FieldPath', function () { try { const path = new firebase.firestore.FieldPath('foo'); path.isEqual({}); @@ -106,13 +100,13 @@ describe('firestore.FieldPath', function() { } }); - it('should return true if isEqual', function() { + it('should return true if isEqual', function () { const path1 = new firebase.firestore.FieldPath('foo', 'bar'); const path2 = new firebase.firestore.FieldPath('foo', 'bar'); path1.isEqual(path2).should.equal(true); }); - it('should return false if not isEqual', function() { + it('should return false if not isEqual', function () { const path1 = new firebase.firestore.FieldPath('foo', 'bar'); const path2 = new firebase.firestore.FieldPath('foo', 'baz'); path1.isEqual(path2).should.equal(false); diff --git a/packages/firestore/e2e/FieldValue.e2e.js b/packages/firestore/e2e/FieldValue.e2e.js index b159f3c619..768fd69f98 100644 --- a/packages/firestore/e2e/FieldValue.e2e.js +++ b/packages/firestore/e2e/FieldValue.e2e.js @@ -17,11 +17,11 @@ const { wipe } = require('./helpers'); const COLLECTION = 'firestore'; -describe('firestore.FieldValue', function() { - before(function() { +describe('firestore.FieldValue', function () { + before(function () { return wipe(); }); - it('should throw if constructed manually', function() { + it('should throw if constructed manually', function () { try { new firebase.firestore.FieldValue(); return Promise.reject(new Error('Did not throw an Error.')); @@ -31,8 +31,8 @@ describe('firestore.FieldValue', function() { } }); - describe('isEqual()', function() { - it('throws if other is not a FieldValue', function() { + describe('isEqual()', function () { + it('throws if other is not a FieldValue', function () { try { firebase.firestore.FieldValue.increment(1).isEqual(1); return Promise.reject(new Error('Did not throw an Error.')); @@ -42,7 +42,7 @@ describe('firestore.FieldValue', function() { } }); - it('returns false if not equal', function() { + it('returns false if not equal', function () { const fv = firebase.firestore.FieldValue.increment(1); const fieldValue1 = firebase.firestore.FieldValue.increment(2); @@ -55,7 +55,7 @@ describe('firestore.FieldValue', function() { eql2.should.be.False(); }); - it('returns true if equal', function() { + it('returns true if equal', function () { const fv = firebase.firestore.FieldValue.arrayUnion(1, '123', 3); const fieldValue1 = firebase.firestore.FieldValue.arrayUnion(1, '123', 3); @@ -66,8 +66,8 @@ describe('firestore.FieldValue', function() { }); }); - describe('increment()', function() { - it('throws if value is not a number', function() { + describe('increment()', function () { + it('throws if value is not a number', function () { try { firebase.firestore.FieldValue.increment('1'); return Promise.reject(new Error('Did not throw an Error.')); @@ -77,7 +77,7 @@ describe('firestore.FieldValue', function() { } }); - it('increments a number if it exists', async function() { + it('increments a number if it exists', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/increment`); await ref.set({ foo: 2 }); await ref.update({ foo: firebase.firestore.FieldValue.increment(1) }); @@ -86,7 +86,7 @@ describe('firestore.FieldValue', function() { await ref.delete(); }); - it('sets the value if it doesnt exist or being set', async function() { + it('sets the value if it doesnt exist or being set', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/increment`); await ref.set({ foo: firebase.firestore.FieldValue.increment(1) }); const snapshot = await ref.get(); @@ -95,8 +95,8 @@ describe('firestore.FieldValue', function() { }); }); - describe('serverTime()', function() { - it('sets a new server time value', async function() { + describe('serverTime()', function () { + it('sets a new server time value', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/servertime`); await ref.set({ foo: firebase.firestore.FieldValue.serverTimestamp() }); const snapshot = await ref.get(); @@ -104,7 +104,7 @@ describe('firestore.FieldValue', function() { await ref.delete(); }); - it('updates a server time value', async function() { + it('updates a server time value', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/servertime`); await ref.set({ foo: firebase.firestore.FieldValue.serverTimestamp() }); const snapshot1 = await ref.get(); @@ -119,8 +119,8 @@ describe('firestore.FieldValue', function() { }); }); - describe('delete()', function() { - it('removes a value', async function() { + describe('delete()', function () { + it('removes a value', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/valuedelete`); await ref.set({ foo: 'bar', bar: 'baz' }); await ref.update({ bar: firebase.firestore.FieldValue.delete() }); @@ -130,8 +130,8 @@ describe('firestore.FieldValue', function() { }); }); - describe('arrayUnion()', function() { - it('throws if attempting to use own class', function() { + describe('arrayUnion()', function () { + it('throws if attempting to use own class', function () { try { firebase.firestore.FieldValue.arrayUnion(firebase.firestore.FieldValue.serverTimestamp()); return Promise.reject(new Error('Did not throw an Error.')); @@ -143,7 +143,7 @@ describe('firestore.FieldValue', function() { } }); - it('throws if using nested arrays', function() { + it('throws if using nested arrays', function () { try { firebase.firestore.FieldValue.arrayUnion([1]); return Promise.reject(new Error('Did not throw an Error.')); @@ -153,7 +153,7 @@ describe('firestore.FieldValue', function() { } }); - it('updates an existing array', async function() { + it('updates an existing array', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/arrayunion`); await ref.set({ foo: [1, 2], @@ -167,7 +167,7 @@ describe('firestore.FieldValue', function() { await ref.delete(); }); - it('sets an array if existing value isnt an array with update', async function() { + it('sets an array if existing value isnt an array with update', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/arrayunion`); await ref.set({ foo: 123, @@ -181,7 +181,7 @@ describe('firestore.FieldValue', function() { await ref.delete(); }); - it('sets an existing array to the new array with set', async function() { + it('sets an existing array to the new array with set', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/arrayunion`); await ref.set({ foo: [1, 2], @@ -196,8 +196,8 @@ describe('firestore.FieldValue', function() { }); }); - describe('arrayRemove()', function() { - it('throws if attempting to use own class', function() { + describe('arrayRemove()', function () { + it('throws if attempting to use own class', function () { try { firebase.firestore.FieldValue.arrayRemove(firebase.firestore.FieldValue.serverTimestamp()); return Promise.reject(new Error('Did not throw an Error.')); @@ -209,7 +209,7 @@ describe('firestore.FieldValue', function() { } }); - it('throws if using nested arrays', function() { + it('throws if using nested arrays', function () { try { firebase.firestore.FieldValue.arrayRemove([1]); return Promise.reject(new Error('Did not throw an Error.')); @@ -219,7 +219,7 @@ describe('firestore.FieldValue', function() { } }); - it('removes items in an array', async function() { + it('removes items in an array', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/arrayremove`); await ref.set({ foo: [1, 2, 3, 4], @@ -233,7 +233,7 @@ describe('firestore.FieldValue', function() { await ref.delete(); }); - it('removes all items in the array if existing value isnt array with update', async function() { + it('removes all items in the array if existing value isnt array with update', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/arrayunion`); await ref.set({ foo: 123, @@ -247,7 +247,7 @@ describe('firestore.FieldValue', function() { await ref.delete(); }); - it('removes all items in the array if existing value isnt array with set', async function() { + it('removes all items in the array if existing value isnt array with set', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/arrayunion`); await ref.set({ foo: 123, diff --git a/packages/firestore/e2e/FirestoreStatics.e2e.js b/packages/firestore/e2e/FirestoreStatics.e2e.js index 3bc620c0c5..b422578aec 100644 --- a/packages/firestore/e2e/FirestoreStatics.e2e.js +++ b/packages/firestore/e2e/FirestoreStatics.e2e.js @@ -15,9 +15,9 @@ * */ -describe('firestore.X', function() { - describe('setLogLevel', function() { - it('throws if invalid level', function() { +describe('firestore.X', function () { + describe('setLogLevel', function () { + it('throws if invalid level', function () { try { firebase.firestore.setLogLevel('verbose'); return Promise.reject(new Error('Did not throw an Error.')); @@ -27,7 +27,7 @@ describe('firestore.X', function() { } }); - it('enabled and disables logging', function() { + it('enabled and disables logging', function () { firebase.firestore.setLogLevel('silent'); firebase.firestore.setLogLevel('debug'); }); diff --git a/packages/firestore/e2e/GeoPoint.e2e.js b/packages/firestore/e2e/GeoPoint.e2e.js index 7ee489143d..cbe57698df 100644 --- a/packages/firestore/e2e/GeoPoint.e2e.js +++ b/packages/firestore/e2e/GeoPoint.e2e.js @@ -16,11 +16,11 @@ */ const COLLECTION = 'firestore'; const { wipe } = require('./helpers'); -describe('firestore.GeoPoint', function() { - before(function() { +describe('firestore.GeoPoint', function () { + before(function () { return wipe(); }); - it('throws if invalid number of arguments', function() { + it('throws if invalid number of arguments', function () { try { new firebase.firestore.GeoPoint(123); return Promise.reject(new Error('Did not throw an Error.')); @@ -30,7 +30,7 @@ describe('firestore.GeoPoint', function() { } }); - it('throws if latitude is not a number', function() { + it('throws if latitude is not a number', function () { try { new firebase.firestore.GeoPoint('123', 0); return Promise.reject(new Error('Did not throw an Error.')); @@ -40,7 +40,7 @@ describe('firestore.GeoPoint', function() { } }); - it('throws if longitude is not a number', function() { + it('throws if longitude is not a number', function () { try { new firebase.firestore.GeoPoint(0, '123'); return Promise.reject(new Error('Did not throw an Error.')); @@ -50,7 +50,7 @@ describe('firestore.GeoPoint', function() { } }); - it('throws if latitude is not valid', function() { + it('throws if latitude is not valid', function () { try { new firebase.firestore.GeoPoint(-100, 0); return Promise.reject(new Error('Did not throw an Error.')); @@ -60,7 +60,7 @@ describe('firestore.GeoPoint', function() { } }); - it('throws if longitude is not valid', function() { + it('throws if longitude is not valid', function () { try { new firebase.firestore.GeoPoint(0, 200); return Promise.reject(new Error('Did not throw an Error.')); @@ -70,18 +70,18 @@ describe('firestore.GeoPoint', function() { } }); - it('gets the latitude value', function() { + it('gets the latitude value', function () { const geo = new firebase.firestore.GeoPoint(20, 0); geo.latitude.should.equal(20); }); - it('gets the longitude value', function() { + it('gets the longitude value', function () { const geo = new firebase.firestore.GeoPoint(20, 15); geo.longitude.should.equal(15); }); - describe('isEqual()', function() { - it('throws if other is a GeoPoint instance', function() { + describe('isEqual()', function () { + it('throws if other is a GeoPoint instance', function () { try { const geo = new firebase.firestore.GeoPoint(0, 0); geo.isEqual(); @@ -92,21 +92,21 @@ describe('firestore.GeoPoint', function() { } }); - it('returns false if not the same', function() { + it('returns false if not the same', function () { const geo1 = new firebase.firestore.GeoPoint(0, 0); const geo2 = new firebase.firestore.GeoPoint(0, 1); const equal = geo1.isEqual(geo2); equal.should.equal(false); }); - it('returns true if the same', function() { + it('returns true if the same', function () { const geo1 = new firebase.firestore.GeoPoint(40, 40); const geo2 = new firebase.firestore.GeoPoint(40, 40); const equal = geo1.isEqual(geo2); equal.should.equal(true); }); }); - it('sets & returns correctly', async function() { + it('sets & returns correctly', async function () { const ref = firebase.firestore().doc(`${COLLECTION}/geopoint`); await ref.set({ geopoint: new firebase.firestore.GeoPoint(20, 30), diff --git a/packages/firestore/e2e/Query/endAt.e2e.js b/packages/firestore/e2e/Query/endAt.e2e.js index 1ae1568972..9b8c909968 100644 --- a/packages/firestore/e2e/Query/endAt.e2e.js +++ b/packages/firestore/e2e/Query/endAt.e2e.js @@ -17,16 +17,13 @@ const { wipe } = require('../helpers'); const COLLECTION = 'firestore'; -describe('firestore().collection().endAt()', function() { - before(function() { +describe('firestore().collection().endAt()', function () { + before(function () { return wipe(); }); - it('throws if no argument provided', function() { + it('throws if no argument provided', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .endAt(); + firebase.firestore().collection(COLLECTION).endAt(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -36,13 +33,9 @@ describe('firestore().collection().endAt()', function() { } }); - it('throws if a inconsistent order number', function() { + it('throws if a inconsistent order number', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .orderBy('foo') - .endAt('bar', 'baz'); + firebase.firestore().collection(COLLECTION).orderBy('foo').endAt('bar', 'baz'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('The number of arguments must be less than or equal'); @@ -50,17 +43,10 @@ describe('firestore().collection().endAt()', function() { } }); - it('throws if providing snapshot and field values', async function() { + it('throws if providing snapshot and field values', async function () { try { - const doc = await firebase - .firestore() - .collection(COLLECTION) - .doc('foo') - .get(); - firebase - .firestore() - .collection(COLLECTION) - .endAt(doc, 'baz'); + const doc = await firebase.firestore().collection(COLLECTION).doc('foo').get(); + firebase.firestore().collection(COLLECTION).endAt(doc, 'baz'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('Expected DocumentSnapshot or list of field values'); @@ -68,16 +54,10 @@ describe('firestore().collection().endAt()', function() { } }); - it('throws if provided snapshot does not exist', async function() { + it('throws if provided snapshot does not exist', async function () { try { - const doc = await firebase - .firestore() - .doc(`${COLLECTION}/idonotexist`) - .get(); - firebase - .firestore() - .collection(COLLECTION) - .endAt(doc); + const doc = await firebase.firestore().doc(`${COLLECTION}/idonotexist`).get(); + firebase.firestore().collection(COLLECTION).endAt(doc); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("Can't use a DocumentSnapshot that doesn't exist"); @@ -85,17 +65,13 @@ describe('firestore().collection().endAt()', function() { } }); - it('throws if order used with snapshot but fields do not exist', async function() { + it('throws if order used with snapshot but fields do not exist', async function () { try { const doc = firebase.firestore().doc(`${COLLECTION}/iexist`); await doc.set({ foo: { bar: 'baz' } }); const snap = await doc.get(); - firebase - .firestore() - .collection(COLLECTION) - .orderBy('foo.baz') - .endAt(snap); + firebase.firestore().collection(COLLECTION).orderBy('foo.baz').endAt(snap); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -105,7 +81,7 @@ describe('firestore().collection().endAt()', function() { } }); - it('ends at field values', async function() { + it('ends at field values', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/endsAt/collection`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); @@ -117,17 +93,14 @@ describe('firestore().collection().endAt()', function() { doc3.set({ foo: 3, bar: { value: 3 } }), ]); - const qs = await colRef - .orderBy('bar.value', 'desc') - .endAt(2) - .get(); + const qs = await colRef.orderBy('bar.value', 'desc').endAt(2).get(); qs.docs.length.should.eql(2); qs.docs[0].id.should.eql('doc3'); qs.docs[1].id.should.eql('doc2'); }); - it('ends at snapshot field values', async function() { + it('ends at snapshot field values', async function () { // await Utils.sleep(3000); const colRef = firebase.firestore().collection(`${COLLECTION}/endsAt/snapshotFields`); const doc1 = colRef.doc('doc1'); @@ -142,17 +115,14 @@ describe('firestore().collection().endAt()', function() { const endAt = await doc2.get(); - const qs = await colRef - .orderBy('bar.value') - .endAt(endAt) - .get(); + const qs = await colRef.orderBy('bar.value').endAt(endAt).get(); qs.docs.length.should.eql(2); qs.docs[0].id.should.eql('doc3'); qs.docs[1].id.should.eql('doc2'); }); - it('ends at snapshot', async function() { + it('ends at snapshot', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/endsAt/snapshot`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); diff --git a/packages/firestore/e2e/Query/endBefore.e2e.js b/packages/firestore/e2e/Query/endBefore.e2e.js index a232d5bf16..5e410bc6b3 100644 --- a/packages/firestore/e2e/Query/endBefore.e2e.js +++ b/packages/firestore/e2e/Query/endBefore.e2e.js @@ -17,17 +17,14 @@ const { wipe } = require('../helpers'); const COLLECTION = 'firestore'; -describe('firestore().collection().endBefore()', function() { - before(function() { +describe('firestore().collection().endBefore()', function () { + before(function () { return wipe(); }); - it('throws if no argument provided', function() { + it('throws if no argument provided', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .endBefore(); + firebase.firestore().collection(COLLECTION).endBefore(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -37,13 +34,9 @@ describe('firestore().collection().endBefore()', function() { } }); - it('throws if a inconsistent order number', function() { + it('throws if a inconsistent order number', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .orderBy('foo') - .endBefore('bar', 'baz'); + firebase.firestore().collection(COLLECTION).orderBy('foo').endBefore('bar', 'baz'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('The number of arguments must be less than or equal'); @@ -51,17 +44,11 @@ describe('firestore().collection().endBefore()', function() { } }); - it('throws if providing snapshot and field values', async function() { + it('throws if providing snapshot and field values', async function () { try { - const doc = await firebase - .firestore() - .doc(`${COLLECTION}/stuff`) - .get(); - - firebase - .firestore() - .collection(COLLECTION) - .endBefore(doc, 'baz'); + const doc = await firebase.firestore().doc(`${COLLECTION}/stuff`).get(); + + firebase.firestore().collection(COLLECTION).endBefore(doc, 'baz'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('Expected DocumentSnapshot or list of field values'); @@ -69,16 +56,10 @@ describe('firestore().collection().endBefore()', function() { } }); - it('throws if provided snapshot does not exist', async function() { + it('throws if provided snapshot does not exist', async function () { try { - const doc = await firebase - .firestore() - .doc(`${COLLECTION}/idonotexist`) - .get(); - firebase - .firestore() - .collection(COLLECTION) - .endBefore(doc); + const doc = await firebase.firestore().doc(`${COLLECTION}/idonotexist`).get(); + firebase.firestore().collection(COLLECTION).endBefore(doc); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("Can't use a DocumentSnapshot that doesn't exist"); @@ -86,17 +67,13 @@ describe('firestore().collection().endBefore()', function() { } }); - it('throws if order used with snapshot but fields do not exist', async function() { + it('throws if order used with snapshot but fields do not exist', async function () { try { const doc = firebase.firestore().doc(`${COLLECTION}/iexist`); await doc.set({ foo: { bar: 'baz' } }); const snap = await doc.get(); - firebase - .firestore() - .collection(COLLECTION) - .orderBy('foo.baz') - .endBefore(snap); + firebase.firestore().collection(COLLECTION).orderBy('foo.baz').endBefore(snap); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -106,7 +83,7 @@ describe('firestore().collection().endBefore()', function() { } }); - it('ends before field values', async function() { + it('ends before field values', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/endBefore/collection`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); @@ -118,16 +95,13 @@ describe('firestore().collection().endBefore()', function() { doc3.set({ foo: 3, bar: { value: 3 } }), ]); - const qs = await colRef - .orderBy('bar.value', 'desc') - .endBefore(2) - .get(); + const qs = await colRef.orderBy('bar.value', 'desc').endBefore(2).get(); qs.docs.length.should.eql(1); qs.docs[0].id.should.eql('doc3'); }); - xit('ends before snapshot field values', async function() { + xit('ends before snapshot field values', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/endBefore/snapshotFields`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); @@ -141,16 +115,13 @@ describe('firestore().collection().endBefore()', function() { const endBefore = await doc2.get(); - const qs = await colRef - .orderBy('bar.value') - .endBefore(endBefore) - .get(); + const qs = await colRef.orderBy('bar.value').endBefore(endBefore).get(); qs.docs.length.should.eql(1); qs.docs[0].id.should.eql('doc3'); }); - it('ends before snapshot', async function() { + it('ends before snapshot', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/endBefore/snapshot`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); diff --git a/packages/firestore/e2e/Query/get.e2e.js b/packages/firestore/e2e/Query/get.e2e.js index 21c28eda0d..037708c50e 100644 --- a/packages/firestore/e2e/Query/get.e2e.js +++ b/packages/firestore/e2e/Query/get.e2e.js @@ -17,16 +17,13 @@ const { wipe } = require('../helpers'); const COLLECTION = 'firestore'; -describe('firestore().collection().get()', function() { - before(function() { +describe('firestore().collection().get()', function () { + before(function () { return wipe(); }); - it('throws if get options is not an object', function() { + it('throws if get options is not an object', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .get(123); + firebase.firestore().collection(COLLECTION).get(123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'options' must be an object is provided"); @@ -34,14 +31,11 @@ describe('firestore().collection().get()', function() { } }); - it('throws if get options.source is not valid', function() { + it('throws if get options.source is not valid', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .get({ - source: 'foo', - }); + firebase.firestore().collection(COLLECTION).get({ + source: 'foo', + }); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -51,22 +45,16 @@ describe('firestore().collection().get()', function() { } }); - it('returns a QuerySnapshot', async function() { - const docRef = firebase - .firestore() - .collection(COLLECTION) - .doc('nestedcollection'); + it('returns a QuerySnapshot', async function () { + const docRef = firebase.firestore().collection(COLLECTION).doc('nestedcollection'); const colRef = docRef.collection('get'); const snapshot = await colRef.get(); snapshot.constructor.name.should.eql('FirestoreQuerySnapshot'); }); - it('returns a correct cache setting (true)', async function() { - const docRef = firebase - .firestore() - .collection(COLLECTION) - .doc('nestedcollection'); + it('returns a correct cache setting (true)', async function () { + const docRef = firebase.firestore().collection(COLLECTION).doc('nestedcollection'); const colRef = docRef.collection('get'); const snapshot = await colRef.get({ source: 'cache', @@ -76,11 +64,8 @@ describe('firestore().collection().get()', function() { snapshot.metadata.fromCache.should.be.True(); }); - it('returns a correct cache setting (false)', async function() { - const docRef = firebase - .firestore() - .collection(COLLECTION) - .doc('nestedcollection'); + it('returns a correct cache setting (false)', async function () { + const docRef = firebase.firestore().collection(COLLECTION).doc('nestedcollection'); const colRef = docRef.collection('get'); await colRef.get(); // Puts it in cache const snapshot = await colRef.get({ diff --git a/packages/firestore/e2e/Query/isEqual.e2e.js b/packages/firestore/e2e/Query/isEqual.e2e.js index fc9bfce5fa..9b69a6ae37 100644 --- a/packages/firestore/e2e/Query/isEqual.e2e.js +++ b/packages/firestore/e2e/Query/isEqual.e2e.js @@ -16,13 +16,10 @@ */ const COLLECTION = 'firestore'; -describe('firestore().collection().isEqual()', function() { - it('throws if other is not a Query', function() { +describe('firestore().collection().isEqual()', function () { + it('throws if other is not a Query', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .isEqual(123); + firebase.firestore().collection(COLLECTION).isEqual(123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'other' expected a Query instance"); @@ -30,32 +27,17 @@ describe('firestore().collection().isEqual()', function() { } }); - it('returns false when not equal (simple checks)', function() { + it('returns false when not equal (simple checks)', function () { const subCol = `${COLLECTION}/isequal/simplechecks`; const query = firebase.firestore().collection(subCol); const q1 = firebase.firestore(firebase.app('secondaryFromNative')).collection(subCol); - const q2 = firebase - .firestore() - .collection(subCol) - .where('foo', '==', 'bar'); - const q3 = firebase - .firestore() - .collection(subCol) - .orderBy('foo'); - const q4 = firebase - .firestore() - .collection(subCol) - .limit(3); + const q2 = firebase.firestore().collection(subCol).where('foo', '==', 'bar'); + const q3 = firebase.firestore().collection(subCol).orderBy('foo'); + const q4 = firebase.firestore().collection(subCol).limit(3); - const ref1 = firebase - .firestore() - .collection(subCol) - .where('bar', '==', true); - const ref2 = firebase - .firestore() - .collection(subCol) - .where('bar', '==', true); + const ref1 = firebase.firestore().collection(subCol).where('bar', '==', true); + const ref2 = firebase.firestore().collection(subCol).where('bar', '==', true); const eql1 = query.isEqual(q1); const eql2 = query.isEqual(q2); @@ -70,7 +52,7 @@ describe('firestore().collection().isEqual()', function() { eql5.should.be.True(); }); - it('returns false when not equal (expensive checks)', function() { + it('returns false when not equal (expensive checks)', function () { const query = firebase .firestore() .collection(COLLECTION) @@ -122,7 +104,7 @@ describe('firestore().collection().isEqual()', function() { eql4.should.be.False(); }); - it('returns true when equal', function() { + it('returns true when equal', function () { const query = firebase .firestore() .collection(COLLECTION) diff --git a/packages/firestore/e2e/Query/limit.e2e.js b/packages/firestore/e2e/Query/limit.e2e.js index bcdf3adca4..da42ff1796 100644 --- a/packages/firestore/e2e/Query/limit.e2e.js +++ b/packages/firestore/e2e/Query/limit.e2e.js @@ -17,16 +17,13 @@ const { wipe } = require('../helpers'); const COLLECTION = 'firestore'; -describe('firestore().collection().limit()', function() { - before(function() { +describe('firestore().collection().limit()', function () { + before(function () { return wipe(); }); - it('throws if limit is invalid', function() { + it('throws if limit is invalid', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .limit(-1); + firebase.firestore().collection(COLLECTION).limit(-1); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'limit' must be a positive integer value"); @@ -34,16 +31,13 @@ describe('firestore().collection().limit()', function() { } }); - it('sets limit on internals', async function() { - const colRef = firebase - .firestore() - .collection(COLLECTION) - .limit(123); + it('sets limit on internals', async function () { + const colRef = firebase.firestore().collection(COLLECTION).limit(123); colRef._modifiers.options.limit.should.eql(123); }); - it('limits the number of documents', async function() { + it('limits the number of documents', async function () { const colRef = firebase.firestore().collection(COLLECTION); // Add 3 diff --git a/packages/firestore/e2e/Query/limitToLast.e2e.js b/packages/firestore/e2e/Query/limitToLast.e2e.js index 30fc16332c..75e7fd26ef 100644 --- a/packages/firestore/e2e/Query/limitToLast.e2e.js +++ b/packages/firestore/e2e/Query/limitToLast.e2e.js @@ -17,16 +17,13 @@ const COLLECTION = 'firestore'; const { wipe } = require('../helpers'); -describe('firestore().collection().limitToLast()', function() { - before(function() { +describe('firestore().collection().limitToLast()', function () { + before(function () { return wipe(); }); - it('throws if limitToLast is invalid', function() { + it('throws if limitToLast is invalid', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .limitToLast(-1); + firebase.firestore().collection(COLLECTION).limitToLast(-1); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'limitToLast' must be a positive integer value"); @@ -34,38 +31,27 @@ describe('firestore().collection().limitToLast()', function() { } }); - it('sets limitToLast on internals', async function() { - const colRef = firebase - .firestore() - .collection(COLLECTION) - .limitToLast(123); + it('sets limitToLast on internals', async function () { + const colRef = firebase.firestore().collection(COLLECTION).limitToLast(123); should(colRef._modifiers.options.limitToLast).equal(123); }); - it('removes limit query if limitToLast is set afterwards', function() { - const colRef = firebase - .firestore() - .collection(COLLECTION) - .limit(2) - .limitToLast(123); + it('removes limit query if limitToLast is set afterwards', function () { + const colRef = firebase.firestore().collection(COLLECTION).limit(2).limitToLast(123); should(colRef._modifiers.options.limit).equal(undefined); }); // FIXME flaky on local tests - xit('removes limitToLast query if limit is set afterwards', function() { - const colRef = firebase - .firestore() - .collection(COLLECTION) - .limitToLast(123) - .limit(2); + xit('removes limitToLast query if limit is set afterwards', function () { + const colRef = firebase.firestore().collection(COLLECTION).limitToLast(123).limit(2); should(colRef._modifiers.options.limitToLast).equal(undefined); }); // FIXME flaky on local tests - xit('limitToLast the number of documents', async function() { + xit('limitToLast the number of documents', async function () { const subCol = `${COLLECTION}/limitToLast/count`; const colRef = firebase.firestore().collection(subCol); @@ -92,13 +78,9 @@ describe('firestore().collection().limitToLast()', function() { should(results[1].count).equal(1); }); - it("throws error if no 'orderBy' is set on the query", function() { + it("throws error if no 'orderBy' is set on the query", function () { try { - firebase - .firestore() - .collection(COLLECTION) - .limitToLast(3) - .get(); + firebase.firestore().collection(COLLECTION).limitToLast(3).get(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( diff --git a/packages/firestore/e2e/Query/onSnapshot.e2e.js b/packages/firestore/e2e/Query/onSnapshot.e2e.js index 9354a6a54c..296ffcc0d5 100644 --- a/packages/firestore/e2e/Query/onSnapshot.e2e.js +++ b/packages/firestore/e2e/Query/onSnapshot.e2e.js @@ -18,16 +18,13 @@ const { wipe } = require('../helpers'); const COLLECTION = 'firestore'; const NO_RULE_COLLECTION = 'no_rules'; -describe('firestore().collection().onSnapshot()', function() { - before(function() { +describe('firestore().collection().onSnapshot()', function () { + before(function () { return wipe(); }); - it('throws if no arguments are provided', function() { + it('throws if no arguments are provided', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .onSnapshot(); + firebase.firestore().collection(COLLECTION).onSnapshot(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('expected at least one argument'); @@ -35,7 +32,7 @@ describe('firestore().collection().onSnapshot()', function() { } }); - it('returns an unsubscribe function', function() { + it('returns an unsubscribe function', function () { const unsub = firebase .firestore() .collection(`${COLLECTION}/foo/bar1`) @@ -45,12 +42,9 @@ describe('firestore().collection().onSnapshot()', function() { unsub(); }); - it('accepts a single callback function with snapshot', async function() { + it('accepts a single callback function with snapshot', async function () { const callback = sinon.spy(); - const unsub = firebase - .firestore() - .collection(`${COLLECTION}/foo/bar2`) - .onSnapshot(callback); + const unsub = firebase.firestore().collection(`${COLLECTION}/foo/bar2`).onSnapshot(callback); await Utils.spyToBeCalledOnceAsync(callback); @@ -60,12 +54,9 @@ describe('firestore().collection().onSnapshot()', function() { unsub(); }); - it('accepts a single callback function with Error', async function() { + it('accepts a single callback function with Error', async function () { const callback = sinon.spy(); - const unsub = firebase - .firestore() - .collection(NO_RULE_COLLECTION) - .onSnapshot(callback); + const unsub = firebase.firestore().collection(NO_RULE_COLLECTION).onSnapshot(callback); await Utils.spyToBeCalledOnceAsync(callback); @@ -75,8 +66,8 @@ describe('firestore().collection().onSnapshot()', function() { unsub(); }); - describe('multiple callbacks', function() { - it('calls onNext when successful', async function() { + describe('multiple callbacks', function () { + it('calls onNext when successful', async function () { const onNext = sinon.spy(); const onError = sinon.spy(); const unsub = firebase @@ -93,13 +84,10 @@ describe('firestore().collection().onSnapshot()', function() { unsub(); }); - it('calls onError with Error', async function() { + it('calls onError with Error', async function () { const onNext = sinon.spy(); const onError = sinon.spy(); - const unsub = firebase - .firestore() - .collection(NO_RULE_COLLECTION) - .onSnapshot(onNext, onError); + const unsub = firebase.firestore().collection(NO_RULE_COLLECTION).onSnapshot(onNext, onError); await Utils.spyToBeCalledOnceAsync(onError); @@ -111,17 +99,14 @@ describe('firestore().collection().onSnapshot()', function() { }); }); - describe('objects of callbacks', function() { - it('calls next when successful', async function() { + describe('objects of callbacks', function () { + it('calls next when successful', async function () { const onNext = sinon.spy(); const onError = sinon.spy(); - const unsub = firebase - .firestore() - .collection(`${COLLECTION}/foo/bar4`) - .onSnapshot({ - next: onNext, - error: onError, - }); + const unsub = firebase.firestore().collection(`${COLLECTION}/foo/bar4`).onSnapshot({ + next: onNext, + error: onError, + }); await Utils.spyToBeCalledOnceAsync(onNext); @@ -132,16 +117,13 @@ describe('firestore().collection().onSnapshot()', function() { unsub(); }); - it('calls error with Error', async function() { + it('calls error with Error', async function () { const onNext = sinon.spy(); const onError = sinon.spy(); - const unsub = firebase - .firestore() - .collection(NO_RULE_COLLECTION) - .onSnapshot({ - next: onNext, - error: onError, - }); + const unsub = firebase.firestore().collection(NO_RULE_COLLECTION).onSnapshot({ + next: onNext, + error: onError, + }); await Utils.spyToBeCalledOnceAsync(onError); @@ -153,18 +135,15 @@ describe('firestore().collection().onSnapshot()', function() { }); }); - describe('SnapshotListenerOptions + callbacks', function() { - it('calls callback with snapshot when successful', async function() { + describe('SnapshotListenerOptions + callbacks', function () { + it('calls callback with snapshot when successful', async function () { const callback = sinon.spy(); - const unsub = firebase - .firestore() - .collection(`${COLLECTION}/foo/bar5`) - .onSnapshot( - { - includeMetadataChanges: false, - }, - callback, - ); + const unsub = firebase.firestore().collection(`${COLLECTION}/foo/bar5`).onSnapshot( + { + includeMetadataChanges: false, + }, + callback, + ); await Utils.spyToBeCalledOnceAsync(callback); @@ -174,17 +153,14 @@ describe('firestore().collection().onSnapshot()', function() { unsub(); }); - it('calls callback with Error', async function() { + it('calls callback with Error', async function () { const callback = sinon.spy(); - const unsub = firebase - .firestore() - .collection(NO_RULE_COLLECTION) - .onSnapshot( - { - includeMetadataChanges: false, - }, - callback, - ); + const unsub = firebase.firestore().collection(NO_RULE_COLLECTION).onSnapshot( + { + includeMetadataChanges: false, + }, + callback, + ); await Utils.spyToBeCalledOnceAsync(callback); @@ -194,19 +170,16 @@ describe('firestore().collection().onSnapshot()', function() { unsub(); }); - it('calls next with snapshot when successful', async function() { + it('calls next with snapshot when successful', async function () { const onNext = sinon.spy(); const onError = sinon.spy(); - const unsub = firebase - .firestore() - .collection(`${COLLECTION}/foo/bar6`) - .onSnapshot( - { - includeMetadataChanges: false, - }, - onNext, - onError, - ); + const unsub = firebase.firestore().collection(`${COLLECTION}/foo/bar6`).onSnapshot( + { + includeMetadataChanges: false, + }, + onNext, + onError, + ); await Utils.spyToBeCalledOnceAsync(onNext); @@ -217,19 +190,16 @@ describe('firestore().collection().onSnapshot()', function() { unsub(); }); - it('calls error with Error', async function() { + it('calls error with Error', async function () { const onNext = sinon.spy(); const onError = sinon.spy(); - const unsub = firebase - .firestore() - .collection(NO_RULE_COLLECTION) - .onSnapshot( - { - includeMetadataChanges: false, - }, - onNext, - onError, - ); + const unsub = firebase.firestore().collection(NO_RULE_COLLECTION).onSnapshot( + { + includeMetadataChanges: false, + }, + onNext, + onError, + ); await Utils.spyToBeCalledOnceAsync(onError); @@ -241,22 +211,19 @@ describe('firestore().collection().onSnapshot()', function() { }); }); - describe('SnapshotListenerOptions + object of callbacks', function() { - it('calls next with snapshot when successful', async function() { + describe('SnapshotListenerOptions + object of callbacks', function () { + it('calls next with snapshot when successful', async function () { const onNext = sinon.spy(); const onError = sinon.spy(); - const unsub = firebase - .firestore() - .collection(`${COLLECTION}/foo/bar7`) - .onSnapshot( - { - includeMetadataChanges: false, - }, - { - next: onNext, - error: onError, - }, - ); + const unsub = firebase.firestore().collection(`${COLLECTION}/foo/bar7`).onSnapshot( + { + includeMetadataChanges: false, + }, + { + next: onNext, + error: onError, + }, + ); await Utils.spyToBeCalledOnceAsync(onNext); @@ -267,21 +234,18 @@ describe('firestore().collection().onSnapshot()', function() { unsub(); }); - it('calls error with Error', async function() { + it('calls error with Error', async function () { const onNext = sinon.spy(); const onError = sinon.spy(); - const unsub = firebase - .firestore() - .collection(NO_RULE_COLLECTION) - .onSnapshot( - { - includeMetadataChanges: false, - }, - { - next: onNext, - error: onError, - }, - ); + const unsub = firebase.firestore().collection(NO_RULE_COLLECTION).onSnapshot( + { + includeMetadataChanges: false, + }, + { + next: onNext, + error: onError, + }, + ); await Utils.spyToBeCalledOnceAsync(onError); @@ -293,14 +257,11 @@ describe('firestore().collection().onSnapshot()', function() { }); }); - it('throws if SnapshotListenerOptions is invalid', function() { + it('throws if SnapshotListenerOptions is invalid', function () { try { - firebase - .firestore() - .collection(NO_RULE_COLLECTION) - .onSnapshot({ - includeMetadataChanges: 123, - }); + firebase.firestore().collection(NO_RULE_COLLECTION).onSnapshot({ + includeMetadataChanges: 123, + }); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -310,14 +271,11 @@ describe('firestore().collection().onSnapshot()', function() { } }); - it('throws if next callback is invalid', function() { + it('throws if next callback is invalid', function () { try { - firebase - .firestore() - .collection(NO_RULE_COLLECTION) - .onSnapshot({ - next: 'foo', - }); + firebase.firestore().collection(NO_RULE_COLLECTION).onSnapshot({ + next: 'foo', + }); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'observer.next' or 'onNext' expected a function"); @@ -325,14 +283,11 @@ describe('firestore().collection().onSnapshot()', function() { } }); - it('throws if error callback is invalid', function() { + it('throws if error callback is invalid', function () { try { - firebase - .firestore() - .collection(NO_RULE_COLLECTION) - .onSnapshot({ - error: 'foo', - }); + firebase.firestore().collection(NO_RULE_COLLECTION).onSnapshot({ + error: 'foo', + }); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'observer.error' or 'onError' expected a function"); @@ -342,7 +297,7 @@ describe('firestore().collection().onSnapshot()', function() { // FIXME test disabled due to flakiness in CI E2E tests. // Registered 4 of 3 expected calls once (!?), 3 of 2 expected calls once. - xit('unsubscribes from further updates', async function() { + xit('unsubscribes from further updates', async function () { const callback = sinon.spy(); const collection = firebase.firestore().collection(`${COLLECTION}/foo/bar7`); diff --git a/packages/firestore/e2e/Query/orderBy.e2e.js b/packages/firestore/e2e/Query/orderBy.e2e.js index a9864918b7..fa2190fc20 100644 --- a/packages/firestore/e2e/Query/orderBy.e2e.js +++ b/packages/firestore/e2e/Query/orderBy.e2e.js @@ -16,16 +16,13 @@ */ const COLLECTION = 'firestore'; const { wipe } = require('../helpers'); -describe('firestore().collection().orderBy()', function() { - before(function() { +describe('firestore().collection().orderBy()', function () { + before(function () { return wipe(); }); - it('throws if fieldPath is not valid', function() { + it('throws if fieldPath is not valid', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .orderBy(123); + firebase.firestore().collection(COLLECTION).orderBy(123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'fieldPath' must be a string or instance of FieldPath"); @@ -33,12 +30,9 @@ describe('firestore().collection().orderBy()', function() { } }); - it('throws if fieldPath string is invalid', function() { + it('throws if fieldPath string is invalid', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .orderBy('.foo.bar'); + firebase.firestore().collection(COLLECTION).orderBy('.foo.bar'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'fieldPath' Invalid field path"); @@ -46,12 +40,9 @@ describe('firestore().collection().orderBy()', function() { } }); - it('throws if direction string is not valid', function() { + it('throws if direction string is not valid', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .orderBy('foo', 'up'); + firebase.firestore().collection(COLLECTION).orderBy('foo', 'up'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'directionStr' must be one of 'asc' or 'desc'"); @@ -59,17 +50,13 @@ describe('firestore().collection().orderBy()', function() { } }); - it('throws if a startAt()/startAfter() has already been set', async function() { + it('throws if a startAt()/startAfter() has already been set', async function () { try { const doc = firebase.firestore().doc(`${COLLECTION}/startATstartAfter`); await doc.set({ foo: 'bar' }); const snapshot = await doc.get(); - firebase - .firestore() - .collection(COLLECTION) - .startAt(snapshot) - .orderBy('foo'); + firebase.firestore().collection(COLLECTION).startAt(snapshot).orderBy('foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('You must not call startAt() or startAfter()'); @@ -77,17 +64,13 @@ describe('firestore().collection().orderBy()', function() { } }); - it('throws if a endAt()/endBefore() has already been set', async function() { + it('throws if a endAt()/endBefore() has already been set', async function () { try { const doc = firebase.firestore().doc(`${COLLECTION}/endAtendBefore`); await doc.set({ foo: 'bar' }); const snapshot = await doc.get(); - firebase - .firestore() - .collection(COLLECTION) - .endAt(snapshot) - .orderBy('foo'); + firebase.firestore().collection(COLLECTION).endAt(snapshot).orderBy('foo'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('You must not call endAt() or endBefore()'); @@ -95,13 +78,9 @@ describe('firestore().collection().orderBy()', function() { } }); - it('throws if duplicating the order field path', function() { + it('throws if duplicating the order field path', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .orderBy('foo.bar') - .orderBy('foo.bar'); + firebase.firestore().collection(COLLECTION).orderBy('foo.bar').orderBy('foo.bar'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('Order by clause cannot contain duplicate fields'); @@ -110,7 +89,7 @@ describe('firestore().collection().orderBy()', function() { }); // FIXME flaky in local tests - xit('orders by a value ASC', async function() { + xit('orders by a value ASC', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/order/asc`); await colRef.add({ value: 1 }); @@ -126,7 +105,7 @@ describe('firestore().collection().orderBy()', function() { }); // FIXME flaky in local tests - xit('orders by a value DESC', async function() { + xit('orders by a value DESC', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/order/desc`); await colRef.add({ value: 1 }); diff --git a/packages/firestore/e2e/Query/query.e2e.js b/packages/firestore/e2e/Query/query.e2e.js index e80f10879f..d8da393392 100644 --- a/packages/firestore/e2e/Query/query.e2e.js +++ b/packages/firestore/e2e/Query/query.e2e.js @@ -15,12 +15,9 @@ */ const COLLECTION = 'firestore'; -describe('FirestoreQuery/FirestoreQueryModifiers', function() { - it('should not mutate previous queries (#2691)', async function() { - const queryBefore = firebase - .firestore() - .collection(COLLECTION) - .where('age', '>', 30); +describe('FirestoreQuery/FirestoreQueryModifiers', function () { + it('should not mutate previous queries (#2691)', async function () { + const queryBefore = firebase.firestore().collection(COLLECTION).where('age', '>', 30); const queryAfter = queryBefore.orderBy('age'); queryBefore._modifiers._orders.length.should.equal(0); queryBefore._modifiers._filters.length.should.equal(1); @@ -29,7 +26,7 @@ describe('FirestoreQuery/FirestoreQueryModifiers', function() { queryAfter._modifiers._filters.length.should.equal(1); }); - it('throws if where equality operator is invoked, and the where fieldPath parameter matches any orderBy parameter', async function() { + it('throws if where equality operator is invoked, and the where fieldPath parameter matches any orderBy parameter', async function () { try { firebase .firestore() @@ -58,7 +55,7 @@ describe('FirestoreQuery/FirestoreQueryModifiers', function() { } }); - it('throws if where inequality operator is invoked, and the where fieldPath does not match initial orderBy parameter', async function() { + it('throws if where inequality operator is invoked, and the where fieldPath does not match initial orderBy parameter', async function () { try { firebase .firestore() diff --git a/packages/firestore/e2e/Query/startAfter.e2e.js b/packages/firestore/e2e/Query/startAfter.e2e.js index 6c38f44503..d4171add0b 100644 --- a/packages/firestore/e2e/Query/startAfter.e2e.js +++ b/packages/firestore/e2e/Query/startAfter.e2e.js @@ -16,16 +16,13 @@ */ const COLLECTION = 'firestore'; const { wipe } = require('../helpers'); -describe('firestore().collection().startAfter()', function() { - before(function() { +describe('firestore().collection().startAfter()', function () { + before(function () { return wipe(); }); - it('throws if no argument provided', function() { + it('throws if no argument provided', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .startAfter(); + firebase.firestore().collection(COLLECTION).startAfter(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -35,13 +32,9 @@ describe('firestore().collection().startAfter()', function() { } }); - it('throws if a inconsistent order number', function() { + it('throws if a inconsistent order number', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .orderBy('foo') - .startAfter('bar', 'baz'); + firebase.firestore().collection(COLLECTION).orderBy('foo').startAfter('bar', 'baz'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('The number of arguments must be less than or equal'); @@ -49,16 +42,10 @@ describe('firestore().collection().startAfter()', function() { } }); - it('throws if providing snapshot and field values', async function() { + it('throws if providing snapshot and field values', async function () { try { - const doc = await firebase - .firestore() - .doc(`${COLLECTION}/foo`) - .get(); - firebase - .firestore() - .collection(COLLECTION) - .startAfter(doc, 'baz'); + const doc = await firebase.firestore().doc(`${COLLECTION}/foo`).get(); + firebase.firestore().collection(COLLECTION).startAfter(doc, 'baz'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('Expected DocumentSnapshot or list of field values'); @@ -66,16 +53,10 @@ describe('firestore().collection().startAfter()', function() { } }); - it('throws if provided snapshot does not exist', async function() { + it('throws if provided snapshot does not exist', async function () { try { - const doc = await firebase - .firestore() - .doc(`${COLLECTION}/idonotexist`) - .get(); - firebase - .firestore() - .collection(COLLECTION) - .startAfter(doc); + const doc = await firebase.firestore().doc(`${COLLECTION}/idonotexist`).get(); + firebase.firestore().collection(COLLECTION).startAfter(doc); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("Can't use a DocumentSnapshot that doesn't exist"); @@ -83,17 +64,13 @@ describe('firestore().collection().startAfter()', function() { } }); - it('throws if order used with snapshot but fields do not exist', async function() { + it('throws if order used with snapshot but fields do not exist', async function () { try { const doc = firebase.firestore().doc(`${COLLECTION}/iexist`); await doc.set({ foo: { bar: 'baz' } }); const snap = await doc.get(); - firebase - .firestore() - .collection(COLLECTION) - .orderBy('foo.baz') - .startAfter(snap); + firebase.firestore().collection(COLLECTION).orderBy('foo.baz').startAfter(snap); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -103,7 +80,7 @@ describe('firestore().collection().startAfter()', function() { } }); - it('starts after field values', async function() { + it('starts after field values', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/startAfter/collection`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); @@ -115,16 +92,13 @@ describe('firestore().collection().startAfter()', function() { doc3.set({ foo: 3, bar: { value: 3 } }), ]); - const qs = await colRef - .orderBy('bar.value', 'desc') - .startAfter(2) - .get(); + const qs = await colRef.orderBy('bar.value', 'desc').startAfter(2).get(); qs.docs.length.should.eql(1); qs.docs[0].id.should.eql('doc1'); }); - it('starts after snapshot field values', async function() { + it('starts after snapshot field values', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/startAfter/snapshotFields`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); @@ -138,16 +112,13 @@ describe('firestore().collection().startAfter()', function() { const startAfter = await doc2.get(); - const qs = await colRef - .orderBy('bar.value') - .startAfter(startAfter) - .get(); + const qs = await colRef.orderBy('bar.value').startAfter(startAfter).get(); qs.docs.length.should.eql(1); qs.docs[0].id.should.eql('doc3'); }); - it('startAfter snapshot', async function() { + it('startAfter snapshot', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/endsAt/snapshot`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); @@ -163,7 +134,7 @@ describe('firestore().collection().startAfter()', function() { qs.docs[0].id.should.eql('doc3'); }); - it('runs startAfter & endBefore in the same query', async function() { + it('runs startAfter & endBefore in the same query', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/startAfter/snapshot`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); @@ -174,11 +145,7 @@ describe('firestore().collection().startAfter()', function() { const first = await doc1.get(); const last = await doc3.get(); - const inBetween = await colRef - .orderBy('age', 'asc') - .startAfter(first) - .endBefore(last) - .get(); + const inBetween = await colRef.orderBy('age', 'asc').startAfter(first).endBefore(last).get(); inBetween.docs.length.should.eql(1); inBetween.docs[0].id.should.eql('doc2'); diff --git a/packages/firestore/e2e/Query/startAt.e2e.js b/packages/firestore/e2e/Query/startAt.e2e.js index 185b122861..1a0a159f87 100644 --- a/packages/firestore/e2e/Query/startAt.e2e.js +++ b/packages/firestore/e2e/Query/startAt.e2e.js @@ -16,16 +16,13 @@ */ const COLLECTION = 'firestore'; const { wipe } = require('../helpers'); -describe('firestore().collection().starAt()', function() { - before(function() { +describe('firestore().collection().starAt()', function () { + before(function () { return wipe(); }); - it('throws if no argument provided', function() { + it('throws if no argument provided', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .startAt(); + firebase.firestore().collection(COLLECTION).startAt(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -35,13 +32,9 @@ describe('firestore().collection().starAt()', function() { } }); - it('throws if a inconsistent order number', function() { + it('throws if a inconsistent order number', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .orderBy('foo') - .startAt('bar', 'baz'); + firebase.firestore().collection(COLLECTION).orderBy('foo').startAt('bar', 'baz'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('The number of arguments must be less than or equal'); @@ -49,16 +42,10 @@ describe('firestore().collection().starAt()', function() { } }); - it('throws if providing snapshot and field values', async function() { + it('throws if providing snapshot and field values', async function () { try { - const doc = await firebase - .firestore() - .doc(`${COLLECTION}/foo`) - .get(); - firebase - .firestore() - .collection(COLLECTION) - .startAt(doc, 'baz'); + const doc = await firebase.firestore().doc(`${COLLECTION}/foo`).get(); + firebase.firestore().collection(COLLECTION).startAt(doc, 'baz'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('Expected DocumentSnapshot or list of field values'); @@ -66,16 +53,10 @@ describe('firestore().collection().starAt()', function() { } }); - it('throws if provided snapshot does not exist', async function() { + it('throws if provided snapshot does not exist', async function () { try { - const doc = await firebase - .firestore() - .doc(`${COLLECTION}/idonotexist`) - .get(); - firebase - .firestore() - .collection(COLLECTION) - .startAt(doc); + const doc = await firebase.firestore().doc(`${COLLECTION}/idonotexist`).get(); + firebase.firestore().collection(COLLECTION).startAt(doc); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("Can't use a DocumentSnapshot that doesn't exist"); @@ -83,18 +64,14 @@ describe('firestore().collection().starAt()', function() { } }); - it('throws if order used with snapshot but fields do not exist', async function() { + it('throws if order used with snapshot but fields do not exist', async function () { try { const doc = firebase.firestore().doc(`${COLLECTION}/iexist`); await doc.set({ foo: { bar: 'baz' } }); const snap = await doc.get(); - firebase - .firestore() - .collection(COLLECTION) - .orderBy('foo.baz') - .startAt(snap); + firebase.firestore().collection(COLLECTION).orderBy('foo.baz').startAt(snap); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -104,7 +81,7 @@ describe('firestore().collection().starAt()', function() { } }); - it('starts at field values', async function() { + it('starts at field values', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/startAt/collection`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); @@ -116,17 +93,14 @@ describe('firestore().collection().starAt()', function() { doc3.set({ foo: 3, bar: { value: 3 } }), ]); - const qs = await colRef - .orderBy('bar.value', 'desc') - .startAt(2) - .get(); + const qs = await colRef.orderBy('bar.value', 'desc').startAt(2).get(); qs.docs.length.should.eql(2); qs.docs[0].id.should.eql('doc2'); qs.docs[1].id.should.eql('doc1'); }); - it('starts at snapshot field values', async function() { + it('starts at snapshot field values', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/startAt/snapshotFields`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); @@ -140,17 +114,14 @@ describe('firestore().collection().starAt()', function() { const startAt = await doc2.get(); - const qs = await colRef - .orderBy('bar.value') - .startAt(startAt) - .get(); + const qs = await colRef.orderBy('bar.value').startAt(startAt).get(); qs.docs.length.should.eql(2); qs.docs[0].id.should.eql('doc2'); qs.docs[1].id.should.eql('doc3'); }); - it('startAt at snapshot', async function() { + it('startAt at snapshot', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/endsAt/snapshot`); const doc1 = colRef.doc('doc1'); const doc2 = colRef.doc('doc2'); diff --git a/packages/firestore/e2e/Query/where.e2e.js b/packages/firestore/e2e/Query/where.e2e.js index 5f43cc4263..4c5c06e29a 100644 --- a/packages/firestore/e2e/Query/where.e2e.js +++ b/packages/firestore/e2e/Query/where.e2e.js @@ -16,16 +16,13 @@ */ const COLLECTION = 'firestore'; const { wipe } = require('../helpers'); -describe('firestore().collection().where()', function() { - beforeEach(async function() { +describe('firestore().collection().where()', function () { + beforeEach(async function () { return await wipe(); }); - it('throws if fieldPath is invalid', function() { + it('throws if fieldPath is invalid', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .where(123); + firebase.firestore().collection(COLLECTION).where(123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'fieldPath' must be a string or instance of FieldPath"); @@ -33,12 +30,9 @@ describe('firestore().collection().where()', function() { } }); - it('throws if fieldPath string is invalid', function() { + it('throws if fieldPath string is invalid', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .where('.foo.bar'); + firebase.firestore().collection(COLLECTION).where('.foo.bar'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'fieldPath' Invalid field path"); @@ -46,12 +40,9 @@ describe('firestore().collection().where()', function() { } }); - it('throws if operator string is invalid', function() { + it('throws if operator string is invalid', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .where('foo.bar', '!'); + firebase.firestore().collection(COLLECTION).where('foo.bar', '!'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'opStr' is invalid"); @@ -59,7 +50,7 @@ describe('firestore().collection().where()', function() { } }); - it('throws if query contains multiple array-contains', function() { + it('throws if query contains multiple array-contains', function () { try { firebase .firestore() @@ -73,12 +64,9 @@ describe('firestore().collection().where()', function() { } }); - it('throws if value is not defined', function() { + it('throws if value is not defined', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .where('foo.bar', 'array-contains'); + firebase.firestore().collection(COLLECTION).where('foo.bar', 'array-contains'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'value' argument expected"); @@ -86,12 +74,9 @@ describe('firestore().collection().where()', function() { } }); - it('throws if null value and no equal operator', function() { + it('throws if null value and no equal operator', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .where('foo.bar', 'array-contains', null); + firebase.firestore().collection(COLLECTION).where('foo.bar', 'array-contains', null); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('You can only perform equals comparisons on null'); @@ -99,20 +84,13 @@ describe('firestore().collection().where()', function() { } }); - it('allows null to be used with equal operator', function() { - firebase - .firestore() - .collection(COLLECTION) - .where('foo.bar', '==', null); + it('allows null to be used with equal operator', function () { + firebase.firestore().collection(COLLECTION).where('foo.bar', '==', null); }); - it('throws if multiple inequalities on different paths is provided', function() { + it('throws if multiple inequalities on different paths is provided', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .where('foo.bar', '>', 123) - .where('bar', '>', 123); + firebase.firestore().collection(COLLECTION).where('foo.bar', '>', 123).where('bar', '>', 123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('All where filters with an inequality'); @@ -120,7 +98,7 @@ describe('firestore().collection().where()', function() { } }); - it('allows inequality on the same path', function() { + it('allows inequality on the same path', function () { firebase .firestore() .collection(COLLECTION) @@ -128,12 +106,9 @@ describe('firestore().collection().where()', function() { .where(new firebase.firestore.FieldPath('foo', 'bar'), '>', 1234); }); - it('throws if in query with no array value', function() { + it('throws if in query with no array value', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .where('foo.bar', 'in', '123'); + firebase.firestore().collection(COLLECTION).where('foo.bar', 'in', '123'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('A non-empty array is required'); @@ -141,12 +116,9 @@ describe('firestore().collection().where()', function() { } }); - it('throws if array-contains-any query with no array value', function() { + it('throws if array-contains-any query with no array value', function () { try { - firebase - .firestore() - .collection(COLLECTION) - .where('foo.bar', 'array-contains-any', '123'); + firebase.firestore().collection(COLLECTION).where('foo.bar', 'array-contains-any', '123'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('A non-empty array is required'); @@ -154,7 +126,7 @@ describe('firestore().collection().where()', function() { } }); - it('throws if in query array length is greater than 10', function() { + it('throws if in query array length is greater than 10', function () { try { firebase .firestore() @@ -167,7 +139,7 @@ describe('firestore().collection().where()', function() { } }); - it('throws if query has multiple array-contains-any filter', function() { + it('throws if query has multiple array-contains-any filter', function () { try { firebase .firestore() @@ -181,7 +153,7 @@ describe('firestore().collection().where()', function() { } }); - it('throws if query has array-contains-any & in filter', function() { + it('throws if query has array-contains-any & in filter', function () { try { firebase .firestore() @@ -197,7 +169,7 @@ describe('firestore().collection().where()', function() { } }); - it('throws if query has multiple in filter', function() { + it('throws if query has multiple in filter', function () { try { firebase .firestore() @@ -211,7 +183,7 @@ describe('firestore().collection().where()', function() { } }); - it('throws if query has in & array-contains-any filter', function() { + it('throws if query has in & array-contains-any filter', function () { try { firebase .firestore() @@ -229,7 +201,7 @@ describe('firestore().collection().where()', function() { /* Queries */ - it('returns with where equal filter', async function() { + it('returns with where equal filter', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/filter/equal`); const search = Date.now(); @@ -247,7 +219,7 @@ describe('firestore().collection().where()', function() { }); }); - it('returns with where greater than filter', async function() { + it('returns with where greater than filter', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/filter/greater`); const search = Date.now(); @@ -266,7 +238,7 @@ describe('firestore().collection().where()', function() { }); }); - it('returns with where greater than or equal filter', async function() { + it('returns with where greater than or equal filter', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/filter/greaterequal`); const search = Date.now(); @@ -285,7 +257,7 @@ describe('firestore().collection().where()', function() { }); }); - it('returns with where less than filter', async function() { + it('returns with where less than filter', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/filter/less`); const search = -Date.now(); @@ -303,7 +275,7 @@ describe('firestore().collection().where()', function() { }); }); - it('returns with where less than or equal filter', async function() { + it('returns with where less than or equal filter', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/filter/lessequal`); const search = -Date.now(); @@ -322,7 +294,7 @@ describe('firestore().collection().where()', function() { }); }); - it('returns with where array-contains filter', async function() { + it('returns with where array-contains filter', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/filter/array-contains`); const match = Date.now(); @@ -341,7 +313,7 @@ describe('firestore().collection().where()', function() { }); }); - it('returns with in filter', async function() { + it('returns with in filter', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/filter/in${Date.now() + ''}`); await Promise.all([ @@ -360,7 +332,7 @@ describe('firestore().collection().where()', function() { }); }); - it('returns with array-contains-any filter', async function() { + it('returns with array-contains-any filter', async function () { const colRef = firebase .firestore() .collection(`${COLLECTION}/filter/array-contains-any${Date.now() + ''}`); @@ -377,7 +349,7 @@ describe('firestore().collection().where()', function() { snapshot.size.should.eql(3); // 2nd record should only be returned once }); - it('returns with a FieldPath', async function() { + it('returns with a FieldPath', async function () { const colRef = firebase .firestore() .collection(`${COLLECTION}/filter/where-fieldpath${Date.now() + ''}`); @@ -400,7 +372,7 @@ describe('firestore().collection().where()', function() { should.equal(data.map['foo.bar@gmail.com'], true); }); - it('should throw an error if you use a FieldPath on a filter in conjunction with an orderBy() parameter that is not FieldPath', async function() { + it('should throw an error if you use a FieldPath on a filter in conjunction with an orderBy() parameter that is not FieldPath', async function () { try { firebase .firestore() @@ -415,7 +387,7 @@ describe('firestore().collection().where()', function() { } }); - it('should correctly query integer values with in operator', async function() { + it('should correctly query integer values with in operator', async function () { const ref = firebase.firestore().collection(`${COLLECTION}/filter/int-in${Date.now() + ''}`); await ref.add({ status: 1 }); @@ -429,7 +401,7 @@ describe('firestore().collection().where()', function() { items.length.should.equal(1); }); - it('should correctly query integer values with array-contains operator', async function() { + it('should correctly query integer values with array-contains operator', async function () { const ref = firebase .firestore() .collection(`${COLLECTION}/filter/int-array-contains${Date.now() + ''}`); @@ -445,7 +417,7 @@ describe('firestore().collection().where()', function() { items.length.should.equal(1); }); - it("should correctly retrieve data when using 'not-in' operator", async function() { + it("should correctly retrieve data when using 'not-in' operator", async function () { const ref = firebase.firestore().collection(`${COLLECTION}/filter/not-in${Date.now() + ''}`); await Promise.all([ref.add({ notIn: 'here' }), ref.add({ notIn: 'now' })]); @@ -455,7 +427,7 @@ describe('firestore().collection().where()', function() { should(result.docs[0].data().notIn).equal('now'); }); - it("should throw error when using 'not-in' operator twice", async function() { + it("should throw error when using 'not-in' operator twice", async function () { const ref = firebase.firestore().collection(COLLECTION); try { @@ -467,7 +439,7 @@ describe('firestore().collection().where()', function() { } }); - it("should throw error when combining 'not-in' operator with '!=' operator", async function() { + it("should throw error when combining 'not-in' operator with '!=' operator", async function () { const ref = firebase.firestore().collection(COLLECTION); try { @@ -481,7 +453,7 @@ describe('firestore().collection().where()', function() { } }); - it("should throw error when combining 'not-in' operator with 'in' operator", async function() { + it("should throw error when combining 'not-in' operator with 'in' operator", async function () { const ref = firebase.firestore().collection(COLLECTION); try { @@ -493,7 +465,7 @@ describe('firestore().collection().where()', function() { } }); - it("should throw error when combining 'not-in' operator with 'array-contains-any' operator", async function() { + it("should throw error when combining 'not-in' operator with 'array-contains-any' operator", async function () { const ref = firebase.firestore().collection(COLLECTION); try { @@ -507,7 +479,7 @@ describe('firestore().collection().where()', function() { } }); - it("should throw error when 'not-in' filter has a list of more than 10 items", async function() { + it("should throw error when 'not-in' filter has a list of more than 10 items", async function () { const ref = firebase.firestore().collection(COLLECTION); try { @@ -521,7 +493,7 @@ describe('firestore().collection().where()', function() { } }); - it("should correctly retrieve data when using '!=' operator", async function() { + it("should correctly retrieve data when using '!=' operator", async function () { const ref = firebase .firestore() .collection(`${COLLECTION}/filter/bang-equals${Date.now() + ''}`); @@ -534,7 +506,7 @@ describe('firestore().collection().where()', function() { should(result.docs[0].data().notEqual).equal('now'); }); - it("should throw error when using '!=' operator twice ", async function() { + it("should throw error when using '!=' operator twice ", async function () { const ref = firebase.firestore().collection(COLLECTION); try { @@ -546,7 +518,7 @@ describe('firestore().collection().where()', function() { } }); - it("should throw error when combining '!=' operator with any other inequality operator on a different field", async function() { + it("should throw error when combining '!=' operator with any other inequality operator on a different field", async function () { const ref = firebase.firestore().collection(COLLECTION); try { @@ -580,7 +552,7 @@ describe('firestore().collection().where()', function() { return Promise.resolve(); }); - it('should handle where clause after sort by', async function() { + it('should handle where clause after sort by', async function () { const ref = firebase .firestore() .collection(`${COLLECTION}/filter/sort-by-where${Date.now() + ''}`); diff --git a/packages/firestore/e2e/QuerySnapshot.e2e.js b/packages/firestore/e2e/QuerySnapshot.e2e.js index 895edde0ee..9aa4d68d7e 100644 --- a/packages/firestore/e2e/QuerySnapshot.e2e.js +++ b/packages/firestore/e2e/QuerySnapshot.e2e.js @@ -17,30 +17,24 @@ const { wipe } = require('./helpers'); const COLLECTION = 'firestore'; -describe('firestore.QuerySnapshot', function() { - before(function() { +describe('firestore.QuerySnapshot', function () { + before(function () { return wipe(); }); - it('is returned from a collection get()', async function() { - const snapshot = await firebase - .firestore() - .collection(COLLECTION) - .get(); + it('is returned from a collection get()', async function () { + const snapshot = await firebase.firestore().collection(COLLECTION).get(); snapshot.constructor.name.should.eql('FirestoreQuerySnapshot'); }); - it('is returned from a collection onSnapshot()', async function() { + it('is returned from a collection onSnapshot()', async function () { const callback = sinon.spy(); - firebase - .firestore() - .collection(COLLECTION) - .onSnapshot(callback); + firebase.firestore().collection(COLLECTION).onSnapshot(callback); await Utils.spyToBeCalledOnceAsync(callback); callback.args[0][0].constructor.name.should.eql('FirestoreQuerySnapshot'); }); - it('returns an array of DocumentSnapshots', async function() { + it('returns an array of DocumentSnapshots', async function () { const colRef = firebase.firestore().collection(COLLECTION); await colRef.add({}); const snapshot = await colRef.get(); @@ -49,7 +43,7 @@ describe('firestore.QuerySnapshot', function() { snapshot.docs[0].constructor.name.should.eql('FirestoreDocumentSnapshot'); }); - it('returns false if not empty', async function() { + it('returns false if not empty', async function () { const colRef = firebase.firestore().collection(COLLECTION); await colRef.add({}); const snapshot = await colRef.get(); @@ -57,33 +51,33 @@ describe('firestore.QuerySnapshot', function() { snapshot.empty.should.be.False(); }); - it('returns true if empty', async function() { + it('returns true if empty', async function () { const colRef = firebase.firestore().collection(`${COLLECTION}/foo/emptycollection`); const snapshot = await colRef.get(); snapshot.empty.should.be.Boolean(); snapshot.empty.should.be.True(); }); - it('returns a SnapshotMetadata instance', async function() { + it('returns a SnapshotMetadata instance', async function () { const colRef = firebase.firestore().collection(COLLECTION); const snapshot = await colRef.get(); snapshot.metadata.constructor.name.should.eql('FirestoreSnapshotMetadata'); }); - it('returns a Query instance', async function() { + it('returns a Query instance', async function () { const colRef = firebase.firestore().collection(COLLECTION); const snapshot = await colRef.get(); snapshot.query.constructor.name.should.eql('FirestoreCollectionReference'); }); - it('returns size as a number', async function() { + it('returns size as a number', async function () { const colRef = firebase.firestore().collection(COLLECTION); const snapshot = await colRef.get(); snapshot.size.should.be.Number(); }); - describe('docChanges()', function() { - it('throws if options is not an object', async function() { + describe('docChanges()', function () { + it('throws if options is not an object', async function () { try { const colRef = firebase.firestore().collection(COLLECTION); const snapshot = await colRef.limit(1).get(); @@ -95,7 +89,7 @@ describe('firestore.QuerySnapshot', function() { } }); - it('throws if options.includeMetadataChanges is not a boolean', async function() { + it('throws if options.includeMetadataChanges is not a boolean', async function () { try { const colRef = firebase.firestore().collection(COLLECTION); const snapshot = await colRef.limit(1).get(); @@ -107,7 +101,7 @@ describe('firestore.QuerySnapshot', function() { } }); - it('throws if options.includeMetadataChanges is true, but snapshot does not include those changes', async function() { + it('throws if options.includeMetadataChanges is true, but snapshot does not include those changes', async function () { const callback = sinon.spy(); const colRef = firebase.firestore().collection(COLLECTION); const unsub = colRef.onSnapshot( @@ -129,7 +123,7 @@ describe('firestore.QuerySnapshot', function() { } }); - it('returns an array of DocumentChange instances', async function() { + it('returns an array of DocumentChange instances', async function () { const colRef = firebase.firestore().collection(COLLECTION); colRef.add({}); const snapshot = await colRef.limit(1).get(); @@ -140,7 +134,7 @@ describe('firestore.QuerySnapshot', function() { }); // TODO: fixme @ehesp - flaky test: `AssertionError: expected 3 to equal 1` on line 155 - xit('returns the correct number of document changes if listening to metadata changes', async function() { + xit('returns the correct number of document changes if listening to metadata changes', async function () { const callback = sinon.spy(); const colRef = firebase.firestore().collection('v6/metadatachanges/true-true'); const unsub = colRef.onSnapshot({ includeMetadataChanges: true }, callback); @@ -158,7 +152,7 @@ describe('firestore.QuerySnapshot', function() { }); // TODO: fixme @ehesp - flaky test: `AssertionError: expected 5 to equal 1` - xit('returns the correct number of document changes if listening to metadata changes, but not including them in docChanges', async function() { + xit('returns the correct number of document changes if listening to metadata changes, but not including them in docChanges', async function () { const callback = sinon.spy(); const colRef = firebase.firestore().collection('v6/metadatachanges/true-false'); const unsub = colRef.onSnapshot({ includeMetadataChanges: true }, callback); @@ -176,8 +170,8 @@ describe('firestore.QuerySnapshot', function() { }); }); - describe('forEach()', function() { - it('throws if callback is not a function', async function() { + describe('forEach()', function () { + it('throws if callback is not a function', async function () { try { const colRef = firebase.firestore().collection(COLLECTION); const snapshot = await colRef.limit(1).get(); @@ -189,7 +183,7 @@ describe('firestore.QuerySnapshot', function() { } }); - it('calls back a function', async function() { + it('calls back a function', async function () { const colRef = firebase.firestore().collection(COLLECTION); colRef.add({}); colRef.add({}); @@ -204,7 +198,7 @@ describe('firestore.QuerySnapshot', function() { callback.args[1][1].should.be.Number(); }); - it('provides context to the callback', async function() { + it('provides context to the callback', async function () { const colRef = firebase.firestore().collection(COLLECTION); colRef.add({}); const snapshot = await colRef.limit(1).get(); @@ -218,13 +212,10 @@ describe('firestore.QuerySnapshot', function() { }); }); - describe('isEqual()', function() { - it('throws if other is not a QuerySnapshot', async function() { + describe('isEqual()', function () { + it('throws if other is not a QuerySnapshot', async function () { try { - const qs = await firebase - .firestore() - .collection(COLLECTION) - .get(); + const qs = await firebase.firestore().collection(COLLECTION).get(); qs.isEqual(123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -233,7 +224,7 @@ describe('firestore.QuerySnapshot', function() { } }); - it('returns false if not equal (simple checks)', async function() { + it('returns false if not equal (simple checks)', async function () { const colRef = firebase.firestore().collection(COLLECTION); // Ensure a doc exists await colRef.add({}); @@ -250,7 +241,7 @@ describe('firestore.QuerySnapshot', function() { eq1.should.be.False(); }); - it('returns false if not equal (expensive checks)', async function() { + it('returns false if not equal (expensive checks)', async function () { const colRef = firebase .firestore() .collection(`${COLLECTION}/querysnapshot/querySnapshotIsEqual-False`); @@ -280,7 +271,7 @@ describe('firestore.QuerySnapshot', function() { eq1.should.be.False(); }); - it('returns true when equal', async function() { + it('returns true when equal', async function () { const colRef = firebase .firestore() .collection(`${COLLECTION}/querysnapshot/querySnapshotIsEqual-True`); diff --git a/packages/firestore/e2e/SnapshotMetadata.e2e.js b/packages/firestore/e2e/SnapshotMetadata.e2e.js index 59dd85d138..a4276618c7 100644 --- a/packages/firestore/e2e/SnapshotMetadata.e2e.js +++ b/packages/firestore/e2e/SnapshotMetadata.e2e.js @@ -17,11 +17,11 @@ const { wipe } = require('./helpers'); const COLLECTION = 'firestore'; -describe('firestore.SnapshotMetadata', function() { - before(function() { +describe('firestore.SnapshotMetadata', function () { + before(function () { return wipe(); }); - it('.fromCache -> returns a boolean', async function() { + it('.fromCache -> returns a boolean', async function () { const ref1 = firebase.firestore().collection(COLLECTION); const ref2 = firebase.firestore().doc(`${COLLECTION}/idonotexist`); const colRef = await ref1.get(); @@ -30,7 +30,7 @@ describe('firestore.SnapshotMetadata', function() { docRef.metadata.fromCache.should.be.Boolean(); }); - it('.hasPendingWrites -> returns a boolean', async function() { + it('.hasPendingWrites -> returns a boolean', async function () { const ref1 = firebase.firestore().collection(COLLECTION); const ref2 = firebase.firestore().doc(`${COLLECTION}/idonotexist`); const colRef = await ref1.get(); @@ -39,13 +39,10 @@ describe('firestore.SnapshotMetadata', function() { docRef.metadata.hasPendingWrites.should.be.Boolean(); }); - describe('isEqual()', function() { - it('throws if other is not a valid type', async function() { + describe('isEqual()', function () { + it('throws if other is not a valid type', async function () { try { - const snapshot = await firebase - .firestore() - .collection(COLLECTION) - .get(); + const snapshot = await firebase.firestore().collection(COLLECTION).get(); snapshot.metadata.isEqual(); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { @@ -54,27 +51,15 @@ describe('firestore.SnapshotMetadata', function() { } }); - it('returns true if is equal', async function() { - const snapshot1 = await firebase - .firestore() - .collection(COLLECTION) - .get({ source: 'cache' }); - const snapshot2 = await firebase - .firestore() - .collection(COLLECTION) - .get({ source: 'cache' }); + it('returns true if is equal', async function () { + const snapshot1 = await firebase.firestore().collection(COLLECTION).get({ source: 'cache' }); + const snapshot2 = await firebase.firestore().collection(COLLECTION).get({ source: 'cache' }); snapshot1.metadata.isEqual(snapshot2.metadata).should.eql(true); }); - it('returns false if not equal', async function() { - const snapshot1 = await firebase - .firestore() - .collection(COLLECTION) - .get({ source: 'cache' }); - const snapshot2 = await firebase - .firestore() - .collection(COLLECTION) - .get({ source: 'server' }); + it('returns false if not equal', async function () { + const snapshot1 = await firebase.firestore().collection(COLLECTION).get({ source: 'cache' }); + const snapshot2 = await firebase.firestore().collection(COLLECTION).get({ source: 'server' }); snapshot1.metadata.isEqual(snapshot2.metadata).should.eql(false); }); }); diff --git a/packages/firestore/e2e/Timestamp.e2e.js b/packages/firestore/e2e/Timestamp.e2e.js index b0f42349ce..25353cc1fa 100644 --- a/packages/firestore/e2e/Timestamp.e2e.js +++ b/packages/firestore/e2e/Timestamp.e2e.js @@ -15,8 +15,8 @@ * */ -describe('firestore.Timestamp', function() { - it('throws if seconds is not a number', function() { +describe('firestore.Timestamp', function () { + it('throws if seconds is not a number', function () { try { new firebase.firestore.Timestamp('1234'); return Promise.reject(new Error('Did not throw an Error.')); @@ -26,7 +26,7 @@ describe('firestore.Timestamp', function() { } }); - it('throws if nanoseconds is not a number', function() { + it('throws if nanoseconds is not a number', function () { try { new firebase.firestore.Timestamp(123, '456'); return Promise.reject(new Error('Did not throw an Error.')); @@ -36,7 +36,7 @@ describe('firestore.Timestamp', function() { } }); - it('throws if nanoseconds less than 0', function() { + it('throws if nanoseconds less than 0', function () { try { new firebase.firestore.Timestamp(123, -1); return Promise.reject(new Error('Did not throw an Error.')); @@ -46,7 +46,7 @@ describe('firestore.Timestamp', function() { } }); - it('throws if nanoseconds greater than 1e9', function() { + it('throws if nanoseconds greater than 1e9', function () { try { new firebase.firestore.Timestamp(123, 10000000000); return Promise.reject(new Error('Did not throw an Error.')); @@ -56,7 +56,7 @@ describe('firestore.Timestamp', function() { } }); - it('throws if seconds less than -62135596800', function() { + it('throws if seconds less than -62135596800', function () { try { new firebase.firestore.Timestamp(-63135596800, 123); return Promise.reject(new Error('Did not throw an Error.')); @@ -66,7 +66,7 @@ describe('firestore.Timestamp', function() { } }); - it('throws if seconds greater-equal than 253402300800', function() { + it('throws if seconds greater-equal than 253402300800', function () { try { new firebase.firestore.Timestamp(253402300800, 123); return Promise.reject(new Error('Did not throw an Error.')); @@ -76,18 +76,18 @@ describe('firestore.Timestamp', function() { } }); - it('returns number of seconds', function() { + it('returns number of seconds', function () { const ts = new firebase.firestore.Timestamp(123, 123); ts.seconds.should.equal(123); }); - it('returns number of nanoseconds', function() { + it('returns number of nanoseconds', function () { const ts = new firebase.firestore.Timestamp(123, 123456); ts.nanoseconds.should.equal(123456); }); - describe('isEqual()', function() { - it('throws if invalid other is procided', function() { + describe('isEqual()', function () { + it('throws if invalid other is procided', function () { try { const ts = new firebase.firestore.Timestamp(123, 1234); ts.isEqual(123); @@ -98,52 +98,52 @@ describe('firestore.Timestamp', function() { } }); - it('returns false if not equal', function() { + it('returns false if not equal', function () { const ts1 = new firebase.firestore.Timestamp(123, 123456); const ts2 = new firebase.firestore.Timestamp(1234, 123456); ts1.isEqual(ts2).should.equal(false); }); - it('returns true if equal', function() { + it('returns true if equal', function () { const ts1 = new firebase.firestore.Timestamp(123, 123456); const ts2 = new firebase.firestore.Timestamp(123, 123456); ts1.isEqual(ts2).should.equal(true); }); }); - describe('toDate()', function() { - it('returns a valid Date object', function() { + describe('toDate()', function () { + it('returns a valid Date object', function () { const ts = new firebase.firestore.Timestamp(123, 123456); const date = ts.toDate(); should.equal(date.constructor.name, 'Date'); }); }); - describe('toMillis()', function() { - it('returns the number of milliseconds', function() { + describe('toMillis()', function () { + it('returns the number of milliseconds', function () { const ts = new firebase.firestore.Timestamp(123, 123456); const ms = ts.toMillis(); should.equal(typeof ms, 'number'); }); }); - describe('toString()', function() { - it('returns a string representation of the class', function() { + describe('toString()', function () { + it('returns a string representation of the class', function () { const ts = new firebase.firestore.Timestamp(123, 123456); const str = ts.toString(); str.should.equal(`FirestoreTimestamp(seconds=${123}, nanoseconds=${123456})`); }); }); - describe('Timestamp.now()', function() { - it('returns a new instance', function() { + describe('Timestamp.now()', function () { + it('returns a new instance', function () { const ts = firebase.firestore.Timestamp.now(); should.equal(ts.constructor.name, 'FirestoreTimestamp'); }); }); - describe('Timestamp.fromDate()', function() { - it('throws if date is not a valid Date', function() { + describe('Timestamp.fromDate()', function () { + it('throws if date is not a valid Date', function () { try { firebase.firestore.Timestamp.fromDate(123); return Promise.reject(new Error('Did not throw an Error.')); @@ -153,14 +153,14 @@ describe('firestore.Timestamp', function() { } }); - it('returns a new instance', function() { + it('returns a new instance', function () { const ts = firebase.firestore.Timestamp.fromDate(new Date()); should.equal(ts.constructor.name, 'FirestoreTimestamp'); }); }); - describe('Timestamp.fromMillis()', function() { - it('returns a new instance', function() { + describe('Timestamp.fromMillis()', function () { + it('returns a new instance', function () { const ts = firebase.firestore.Timestamp.fromMillis(123); should.equal(ts.constructor.name, 'FirestoreTimestamp'); }); diff --git a/packages/firestore/e2e/Transaction.e2e.js b/packages/firestore/e2e/Transaction.e2e.js index f50ed1d307..3f54ae26e9 100644 --- a/packages/firestore/e2e/Transaction.e2e.js +++ b/packages/firestore/e2e/Transaction.e2e.js @@ -17,8 +17,8 @@ const COLLECTION = 'firestore'; const NO_RULE_COLLECTION = 'no_rules'; -describe('firestore.Transaction', function() { - it('should throw if updateFunction is not a Promise', async function() { +describe('firestore.Transaction', function () { + it('should throw if updateFunction is not a Promise', async function () { try { await firebase.firestore().runTransaction(() => 123); return Promise.reject(new Error('Did not throw an Error.')); @@ -28,14 +28,14 @@ describe('firestore.Transaction', function() { } }); - it('should return an instance of FirestoreTransaction', async function() { + it('should return an instance of FirestoreTransaction', async function () { await firebase.firestore().runTransaction(async transaction => { transaction.constructor.name.should.eql('FirestoreTransaction'); return null; }); }); - it('should resolve with user value', async function() { + it('should resolve with user value', async function () { const expected = Date.now(); const value = await firebase.firestore().runTransaction(async () => { @@ -45,7 +45,7 @@ describe('firestore.Transaction', function() { value.should.eql(expected); }); - it('should reject with user Error', async function() { + it('should reject with user Error', async function () { const message = `Error: ${Date.now()}`; try { @@ -59,7 +59,7 @@ describe('firestore.Transaction', function() { } }); - it('should reject a native error', async function() { + it('should reject a native error', async function () { const docRef = firebase.firestore().doc(`${NO_RULE_COLLECTION}/foo`); try { @@ -75,8 +75,8 @@ describe('firestore.Transaction', function() { } }); - describe('transaction.get()', function() { - it('should throw if not providing a document reference', async function() { + describe('transaction.get()', function () { + it('should throw if not providing a document reference', async function () { try { await firebase.firestore().runTransaction(t => { return t.get(123); @@ -88,7 +88,7 @@ describe('firestore.Transaction', function() { } }); - it('should get a document and return a DocumentSnapshot', async function() { + it('should get a document and return a DocumentSnapshot', async function () { const docRef = firebase.firestore().doc(`${COLLECTION}/transactions/transaction/get-delete`); await docRef.set({}); @@ -103,8 +103,8 @@ describe('firestore.Transaction', function() { }); }); - describe('transaction.delete()', function() { - it('should throw if not providing a document reference', async function() { + describe('transaction.delete()', function () { + it('should throw if not providing a document reference', async function () { try { await firebase.firestore().runTransaction(async t => { t.delete(123); @@ -116,7 +116,7 @@ describe('firestore.Transaction', function() { } }); - it('should delete documents', async function() { + it('should delete documents', async function () { const docRef1 = firebase .firestore() .doc(`${COLLECTION}/transactions/transaction/delete-delete1`); @@ -140,8 +140,8 @@ describe('firestore.Transaction', function() { }); }); - describe('transaction.update()', function() { - it('should throw if not providing a document reference', async function() { + describe('transaction.update()', function () { + it('should throw if not providing a document reference', async function () { try { await firebase.firestore().runTransaction(async t => { t.update(123); @@ -153,7 +153,7 @@ describe('firestore.Transaction', function() { } }); - it('should throw if update args are invalid', async function() { + it('should throw if update args are invalid', async function () { const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); try { @@ -167,7 +167,7 @@ describe('firestore.Transaction', function() { } }); - it('should update documents', async function() { + it('should update documents', async function () { const value = Date.now(); const docRef1 = firebase @@ -208,8 +208,8 @@ describe('firestore.Transaction', function() { }); }); - describe('transaction.set()', function() { - it('should throw if not providing a document reference', async function() { + describe('transaction.set()', function () { + it('should throw if not providing a document reference', async function () { try { await firebase.firestore().runTransaction(async t => { t.set(123); @@ -221,7 +221,7 @@ describe('firestore.Transaction', function() { } }); - it('should throw if set data is invalid', async function() { + it('should throw if set data is invalid', async function () { const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); try { @@ -235,7 +235,7 @@ describe('firestore.Transaction', function() { } }); - it('should throw if set options are invalid', async function() { + it('should throw if set options are invalid', async function () { const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); try { @@ -256,7 +256,7 @@ describe('firestore.Transaction', function() { } }); - it('should set data', async function() { + it('should set data', async function () { const docRef = firebase.firestore().doc(`${COLLECTION}/transactions/transaction/set`); await docRef.set({ foo: 'bar', @@ -273,7 +273,7 @@ describe('firestore.Transaction', function() { snapshot.data().should.eql(jet.contextify(expected)); }); - it('should set data with merge', async function() { + it('should set data with merge', async function () { const docRef = firebase.firestore().doc(`${COLLECTION}/transactions/transaction/set-merge`); await docRef.set({ foo: 'bar', @@ -300,7 +300,7 @@ describe('firestore.Transaction', function() { snapshot.data().should.eql(jet.contextify(expected)); }); - it('should set data with merge fields', async function() { + it('should set data with merge fields', async function () { const docRef = firebase .firestore() .doc(`${COLLECTION}/transactions/transaction/set-mergefields`); @@ -332,7 +332,7 @@ describe('firestore.Transaction', function() { snapshot.data().should.eql(jet.contextify(expected)); }); - it('should roll back any updates that failed', async function() { + it('should roll back any updates that failed', async function () { const docRef = firebase.firestore().doc(`${COLLECTION}/transactions/transaction/rollback`); await docRef.set({ diff --git a/packages/firestore/e2e/WriteBatch/commit.e2e.js b/packages/firestore/e2e/WriteBatch/commit.e2e.js index 75b9507113..d15522b878 100644 --- a/packages/firestore/e2e/WriteBatch/commit.e2e.js +++ b/packages/firestore/e2e/WriteBatch/commit.e2e.js @@ -17,27 +17,21 @@ const COLLECTION = 'firestore'; const { wipe } = require('../helpers'); -describe('firestore.WriteBatch.commit()', function() { - before(function() { +describe('firestore.WriteBatch.commit()', function () { + before(function () { return wipe(); }); - it('returns a Promise', function() { - const commit = firebase - .firestore() - .batch() - .commit(); + it('returns a Promise', function () { + const commit = firebase.firestore().batch().commit(); commit.should.be.a.Promise(); }); - it('throws if committing more than 500 writes', async function() { + it('throws if committing more than 500 writes', async function () { const filledArray = new Array(501).fill({ foo: 'bar' }); const batch = firebase.firestore().batch(); for (let i = 0; i < filledArray.length; i++) { - const doc = firebase - .firestore() - .collection(COLLECTION) - .doc(i.toString()); + const doc = firebase.firestore().collection(COLLECTION).doc(i.toString()); const filledArrayElement = filledArray[i]; batch.set(doc, filledArrayElement); } @@ -51,7 +45,7 @@ describe('firestore.WriteBatch.commit()', function() { } }); - it('throws if already committed', async function() { + it('throws if already committed', async function () { try { const batch = firebase.firestore().batch(); await batch.commit(); @@ -63,7 +57,7 @@ describe('firestore.WriteBatch.commit()', function() { } }); - it('should set & commit', async function() { + it('should set & commit', async function () { const lRef = firebase.firestore().doc(`${COLLECTION}/LON`); const nycRef = firebase.firestore().doc(`${COLLECTION}/NYC`); const sfRef = firebase.firestore().doc(`${COLLECTION}/SF`); @@ -84,7 +78,7 @@ describe('firestore.WriteBatch.commit()', function() { await Promise.all([lRef.delete(), nycRef.delete(), sfRef.delete()]); }); - it('should set/merge & commit', async function() { + it('should set/merge & commit', async function () { const lRef = firebase.firestore().doc(`${COLLECTION}/LON`); const nycRef = firebase.firestore().doc(`${COLLECTION}/NYC`); const sfRef = firebase.firestore().doc(`${COLLECTION}/SF`); @@ -115,7 +109,7 @@ describe('firestore.WriteBatch.commit()', function() { await Promise.all([lRef.delete(), nycRef.delete(), sfRef.delete()]); }); - it('should set/mergeFields & commit', async function() { + it('should set/mergeFields & commit', async function () { const lRef = firebase.firestore().doc(`${COLLECTION}/LON`); const nycRef = firebase.firestore().doc(`${COLLECTION}/NYC`); const sfRef = firebase.firestore().doc(`${COLLECTION}/SF`); @@ -150,7 +144,7 @@ describe('firestore.WriteBatch.commit()', function() { await Promise.all([lRef.delete(), nycRef.delete(), sfRef.delete()]); }); - it('should delete & commit', async function() { + it('should delete & commit', async function () { const lRef = firebase.firestore().doc(`${COLLECTION}/LON`); const nycRef = firebase.firestore().doc(`${COLLECTION}/NYC`); const sfRef = firebase.firestore().doc(`${COLLECTION}/SF`); @@ -176,7 +170,7 @@ describe('firestore.WriteBatch.commit()', function() { sDoc.exists.should.be.False(); }); - it('should update & commit', async function() { + it('should update & commit', async function () { const lRef = firebase.firestore().doc(`${COLLECTION}/LON`); const nycRef = firebase.firestore().doc(`${COLLECTION}/NYC`); const sfRef = firebase.firestore().doc(`${COLLECTION}/SF`); diff --git a/packages/firestore/e2e/WriteBatch/delete.e2e.js b/packages/firestore/e2e/WriteBatch/delete.e2e.js index 97c2698db2..5de04c83cd 100644 --- a/packages/firestore/e2e/WriteBatch/delete.e2e.js +++ b/packages/firestore/e2e/WriteBatch/delete.e2e.js @@ -16,13 +16,10 @@ */ const COLLECTION = 'firestore'; -describe('firestore.WriteBatch.delete()', function() { - it('throws if a DocumentReference instance is not provided', function() { +describe('firestore.WriteBatch.delete()', function () { + it('throws if a DocumentReference instance is not provided', function () { try { - firebase - .firestore() - .batch() - .delete(123); + firebase.firestore().batch().delete(123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'documentRef' expected instance of a DocumentReference"); @@ -30,15 +27,12 @@ describe('firestore.WriteBatch.delete()', function() { } }); - it('throws if a DocumentReference firestore instance is different', function() { + it('throws if a DocumentReference firestore instance is different', function () { try { const app2 = firebase.app('secondaryFromNative'); const docRef = firebase.firestore(app2).doc(`${COLLECTION}/foo`); - firebase - .firestore() - .batch() - .delete(docRef); + firebase.firestore().batch().delete(docRef); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -48,12 +42,9 @@ describe('firestore.WriteBatch.delete()', function() { } }); - it('adds the DocumentReference to the internal writes', function() { + it('adds the DocumentReference to the internal writes', function () { const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); - const wb = firebase - .firestore() - .batch() - .delete(docRef); + const wb = firebase.firestore().batch().delete(docRef); wb._writes.length.should.eql(1); const expected = { path: `${COLLECTION}/foo`, diff --git a/packages/firestore/e2e/WriteBatch/set.e2e.js b/packages/firestore/e2e/WriteBatch/set.e2e.js index d7ce3d26b7..1acd12f5b6 100644 --- a/packages/firestore/e2e/WriteBatch/set.e2e.js +++ b/packages/firestore/e2e/WriteBatch/set.e2e.js @@ -16,13 +16,10 @@ */ const COLLECTION = 'firestore'; -describe('firestore.WriteBatch.set()', function() { - it('throws if a DocumentReference instance is not provided', function() { +describe('firestore.WriteBatch.set()', function () { + it('throws if a DocumentReference instance is not provided', function () { try { - firebase - .firestore() - .batch() - .set(123); + firebase.firestore().batch().set(123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'documentRef' expected instance of a DocumentReference"); @@ -30,15 +27,12 @@ describe('firestore.WriteBatch.set()', function() { } }); - it('throws if a DocumentReference firestore instance is different', function() { + it('throws if a DocumentReference firestore instance is different', function () { try { const app2 = firebase.app('secondaryFromNative'); const docRef = firebase.firestore(app2).doc(`${COLLECTION}/foo`); - firebase - .firestore() - .batch() - .set(docRef); + firebase.firestore().batch().set(docRef); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -48,14 +42,11 @@ describe('firestore.WriteBatch.set()', function() { } }); - it('throws if a data is not an object', function() { + it('throws if a data is not an object', function () { try { const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); - firebase - .firestore() - .batch() - .set(docRef, 123); + firebase.firestore().batch().set(docRef, 123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'data' must be an object"); @@ -63,14 +54,11 @@ describe('firestore.WriteBatch.set()', function() { } }); - it('throws if a options is not an object', function() { + it('throws if a options is not an object', function () { try { const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); - firebase - .firestore() - .batch() - .set(docRef, {}, 123); + firebase.firestore().batch().set(docRef, {}, 123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'options' must be an object"); @@ -78,7 +66,7 @@ describe('firestore.WriteBatch.set()', function() { } }); - it('throws if merge and mergeFields is provided', function() { + it('throws if merge and mergeFields is provided', function () { try { const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); firebase @@ -99,19 +87,16 @@ describe('firestore.WriteBatch.set()', function() { } }); - it('throws if merge is not a boolean', function() { + it('throws if merge is not a boolean', function () { try { const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); - firebase - .firestore() - .batch() - .set( - docRef, - {}, - { - merge: 'true', - }, - ); + firebase.firestore().batch().set( + docRef, + {}, + { + merge: 'true', + }, + ); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'options.merge' must be a boolean value"); @@ -119,19 +104,16 @@ describe('firestore.WriteBatch.set()', function() { } }); - it('throws if mergeFields is not an array', function() { + it('throws if mergeFields is not an array', function () { try { const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); - firebase - .firestore() - .batch() - .set( - docRef, - {}, - { - mergeFields: '[]', - }, - ); + firebase.firestore().batch().set( + docRef, + {}, + { + mergeFields: '[]', + }, + ); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'options.mergeFields' must be an array"); @@ -139,7 +121,7 @@ describe('firestore.WriteBatch.set()', function() { } }); - it('throws if mergeFields item is not valid', function() { + it('throws if mergeFields item is not valid', function () { try { const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); @@ -162,7 +144,7 @@ describe('firestore.WriteBatch.set()', function() { } }); - it('throws if string fieldpath is invalid', function() { + it('throws if string fieldpath is invalid', function () { try { const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); @@ -183,7 +165,7 @@ describe('firestore.WriteBatch.set()', function() { } }); - it('accepts string fieldpath & FieldPath', function() { + it('accepts string fieldpath & FieldPath', function () { const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); firebase @@ -198,7 +180,7 @@ describe('firestore.WriteBatch.set()', function() { ); }); - it('adds the DocumentReference to the internal writes', function() { + it('adds the DocumentReference to the internal writes', function () { const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); const wb = firebase diff --git a/packages/firestore/e2e/WriteBatch/update.e2e.js b/packages/firestore/e2e/WriteBatch/update.e2e.js index de13a04b29..46957d066c 100644 --- a/packages/firestore/e2e/WriteBatch/update.e2e.js +++ b/packages/firestore/e2e/WriteBatch/update.e2e.js @@ -17,13 +17,10 @@ const COLLECTION = 'firestore'; -describe('firestore.WriteBatch.update()', function() { - it('throws if a DocumentReference instance is not provided', function() { +describe('firestore.WriteBatch.update()', function () { + it('throws if a DocumentReference instance is not provided', function () { try { - firebase - .firestore() - .batch() - .update(123); + firebase.firestore().batch().update(123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql("'documentRef' expected instance of a DocumentReference"); @@ -31,15 +28,12 @@ describe('firestore.WriteBatch.update()', function() { } }); - it('throws if a DocumentReference firestore instance is different', function() { + it('throws if a DocumentReference firestore instance is different', function () { try { const app2 = firebase.app('secondaryFromNative'); const docRef = firebase.firestore(app2).doc(`${COLLECTION}/foo`); - firebase - .firestore() - .batch() - .update(docRef); + firebase.firestore().batch().update(docRef); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql( @@ -49,13 +43,10 @@ describe('firestore.WriteBatch.update()', function() { } }); - it('throws if update args are not provided', function() { + it('throws if update args are not provided', function () { try { const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); - firebase - .firestore() - .batch() - .update(docRef); + firebase.firestore().batch().update(docRef); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('Expected update object or list of key/value pairs'); @@ -63,13 +54,10 @@ describe('firestore.WriteBatch.update()', function() { } }); - it('throws if update arg is not an object', function() { + it('throws if update arg is not an object', function () { try { const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); - firebase - .firestore() - .batch() - .update(docRef, 123); + firebase.firestore().batch().update(docRef, 123); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('if using a single update argument, it must be an object'); @@ -77,13 +65,10 @@ describe('firestore.WriteBatch.update()', function() { } }); - it('throws if update key/values are invalid', function() { + it('throws if update key/values are invalid', function () { try { const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); - firebase - .firestore() - .batch() - .update(docRef, 'foo', 'bar', 'baz'); + firebase.firestore().batch().update(docRef, 'foo', 'bar', 'baz'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('equal numbers of key/value pairs'); @@ -91,13 +76,10 @@ describe('firestore.WriteBatch.update()', function() { } }); - it('throws if update keys are invalid', function() { + it('throws if update keys are invalid', function () { try { const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); - firebase - .firestore() - .batch() - .update(docRef, 'foo', 'bar', 123, 'ben'); + firebase.firestore().batch().update(docRef, 'foo', 'bar', 123, 'ben'); return Promise.reject(new Error('Did not throw an Error.')); } catch (error) { error.message.should.containEql('argument at index 2 must be a string or FieldPath'); @@ -105,12 +87,9 @@ describe('firestore.WriteBatch.update()', function() { } }); - it('adds the DocumentReference to the internal writes', function() { + it('adds the DocumentReference to the internal writes', function () { const docRef = firebase.firestore().doc(`${COLLECTION}/foo`); - const wb = firebase - .firestore() - .batch() - .update(docRef, { foo: 'bar' }); + const wb = firebase.firestore().batch().update(docRef, { foo: 'bar' }); wb._writes.length.should.eql(1); const expected = { path: `${COLLECTION}/foo`, diff --git a/packages/firestore/e2e/firestore.e2e.js b/packages/firestore/e2e/firestore.e2e.js index 7bc15aab00..4c210c138f 100644 --- a/packages/firestore/e2e/firestore.e2e.js +++ b/packages/firestore/e2e/firestore.e2e.js @@ -17,40 +17,37 @@ const COLLECTION = 'firestore'; const COLLECTION_GROUP = 'collectionGroup'; -describe('firestore()', function() { - describe('namespace', function() { - it('accessible from firebase.app()', function() { +describe('firestore()', function () { + describe('namespace', function () { + it('accessible from firebase.app()', function () { const app = firebase.app(); should.exist(app.firestore); app.firestore().app.should.equal(app); }); // removing as pending if module.options.hasMultiAppSupport = true - it('supports multiple apps', async function() { + it('supports multiple apps', async function () { firebase.firestore().app.name.should.equal('[DEFAULT]'); firebase .firestore(firebase.app('secondaryFromNative')) .app.name.should.equal('secondaryFromNative'); - firebase - .app('secondaryFromNative') - .firestore() - .app.name.should.equal('secondaryFromNative'); + firebase.app('secondaryFromNative').firestore().app.name.should.equal('secondaryFromNative'); }); }); - describe('batch()', function() { - it('returns a new WriteBatch instance', function() { + describe('batch()', function () { + it('returns a new WriteBatch instance', function () { const instance = firebase.firestore().batch(); instance.constructor.name.should.eql('FirestoreWriteBatch'); }); }); - describe('clearPersistence()', function() {}); + describe('clearPersistence()', function () {}); - describe('collection()', function() { - it('throws if path is not a string', function() { + describe('collection()', function () { + it('throws if path is not a string', function () { try { firebase.firestore().collection(123); return Promise.reject(new Error('Did not throw an Error.')); @@ -60,7 +57,7 @@ describe('firestore()', function() { } }); - it('throws if path is empty string', function() { + it('throws if path is empty string', function () { try { firebase.firestore().collection(''); return Promise.reject(new Error('Did not throw an Error.')); @@ -70,7 +67,7 @@ describe('firestore()', function() { } }); - it('throws if path does not point to a collection', function() { + it('throws if path does not point to a collection', function () { try { firebase.firestore().collection(`${COLLECTION}/bar`); return Promise.reject(new Error('Did not throw an Error.')); @@ -80,15 +77,15 @@ describe('firestore()', function() { } }); - it('returns a new CollectionReference', function() { + it('returns a new CollectionReference', function () { const collectionReference = firebase.firestore().collection(COLLECTION); should.equal(collectionReference.constructor.name, 'FirestoreCollectionReference'); collectionReference.path.should.eql(COLLECTION); }); }); - describe('doc()', function() { - it('throws if path is not a string', function() { + describe('doc()', function () { + it('throws if path is not a string', function () { try { firebase.firestore().doc(123); return Promise.reject(new Error('Did not throw an Error.')); @@ -98,7 +95,7 @@ describe('firestore()', function() { } }); - it('throws if path is empty string', function() { + it('throws if path is empty string', function () { try { firebase.firestore().doc(''); return Promise.reject(new Error('Did not throw an Error.')); @@ -108,7 +105,7 @@ describe('firestore()', function() { } }); - it('throws if path does not point to a document', function() { + it('throws if path does not point to a document', function () { try { firebase.firestore().doc(`${COLLECTION}/bar/baz`); return Promise.reject(new Error('Did not throw an Error.')); @@ -118,15 +115,15 @@ describe('firestore()', function() { } }); - it('returns a new DocumentReference', function() { + it('returns a new DocumentReference', function () { const docRef = firebase.firestore().doc(`${COLLECTION}/bar`); should.equal(docRef.constructor.name, 'FirestoreDocumentReference'); docRef.path.should.eql(`${COLLECTION}/bar`); }); }); - describe('collectionGroup()', function() { - it('throws if id is not a string', function() { + describe('collectionGroup()', function () { + it('throws if id is not a string', function () { try { firebase.firestore().collectionGroup(123); return Promise.reject(new Error('Did not throw an Error.')); @@ -136,7 +133,7 @@ describe('firestore()', function() { } }); - it('throws if id is empty', function() { + it('throws if id is empty', function () { try { firebase.firestore().collectionGroup(''); return Promise.reject(new Error('Did not throw an Error.')); @@ -146,7 +143,7 @@ describe('firestore()', function() { } }); - it('throws if id contains forward-slash', function() { + it('throws if id contains forward-slash', function () { try { firebase.firestore().collectionGroup(`${COLLECTION}/bar`); return Promise.reject(new Error('Did not throw an Error.')); @@ -156,12 +153,12 @@ describe('firestore()', function() { } }); - it('returns a new query instance', function() { + it('returns a new query instance', function () { const query = firebase.firestore().collectionGroup(COLLECTION); should.equal(query.constructor.name, 'FirestoreQuery'); }); - it('performs a collection group query', async function() { + it('performs a collection group query', async function () { const docRef1 = firebase.firestore().doc(`${COLLECTION}/collectionGroup1`); const docRef2 = firebase.firestore().doc(`${COLLECTION}/collectionGroup2`); const docRef3 = firebase.firestore().doc(`${COLLECTION}/collectionGroup3`); @@ -207,7 +204,7 @@ describe('firestore()', function() { ]); }); - it('performs a collection group query with cursor queries', async function() { + it('performs a collection group query with cursor queries', async function () { const docRef = firebase.firestore().doc(`${COLLECTION}/collectionGroupCursor`); const ref1 = await docRef.collection(COLLECTION_GROUP).add({ number: 1 }); @@ -231,15 +228,15 @@ describe('firestore()', function() { }); }); - describe('disableNetwork() & enableNetwork()', function() { - it('disables and enables with no errors', async function() { + describe('disableNetwork() & enableNetwork()', function () { + it('disables and enables with no errors', async function () { await firebase.firestore().disableNetwork(); await firebase.firestore().enableNetwork(); }); }); - describe('runTransaction()', function() { - it('throws if updateFunction is not a function', function() { + describe('runTransaction()', function () { + it('throws if updateFunction is not a function', function () { try { firebase.firestore().runTransaction('foo'); return Promise.reject(new Error('Did not throw an Error.')); @@ -250,8 +247,8 @@ describe('firestore()', function() { }); }); - describe('settings()', function() { - it('throws if settings is not an object', function() { + describe('settings()', function () { + it('throws if settings is not an object', function () { try { firebase.firestore().settings('foo'); return Promise.reject(new Error('Did not throw an Error.')); @@ -261,7 +258,7 @@ describe('firestore()', function() { } }); - it('throws if passing an incorrect setting key', function() { + it('throws if passing an incorrect setting key', function () { try { firebase.firestore().settings({ foo: 'bar' }); return Promise.reject(new Error('Did not throw an Error.')); @@ -271,7 +268,7 @@ describe('firestore()', function() { } }); - it('throws if cacheSizeBytes is not a number', function() { + it('throws if cacheSizeBytes is not a number', function () { try { firebase.firestore().settings({ cacheSizeBytes: 'foo' }); return Promise.reject(new Error('Did not throw an Error.')); @@ -281,7 +278,7 @@ describe('firestore()', function() { } }); - it('throws if cacheSizeBytes is less than 1MB', function() { + it('throws if cacheSizeBytes is less than 1MB', function () { try { firebase.firestore().settings({ cacheSizeBytes: 123 }); return Promise.reject(new Error('Did not throw an Error.')); @@ -291,11 +288,11 @@ describe('firestore()', function() { } }); // NOTE: removed as it breaks emulator tests along with 'should clear any cached data' test below - xit('accepts an unlimited cache size', function() { + xit('accepts an unlimited cache size', function () { firebase.firestore().settings({ cacheSizeBytes: firebase.firestore.CACHE_SIZE_UNLIMITED }); }); - it('throws if host is not a string', function() { + it('throws if host is not a string', function () { try { firebase.firestore().settings({ host: 123 }); return Promise.reject(new Error('Did not throw an Error.')); @@ -305,7 +302,7 @@ describe('firestore()', function() { } }); - it('throws if host is an empty string', function() { + it('throws if host is an empty string', function () { try { firebase.firestore().settings({ host: '' }); return Promise.reject(new Error('Did not throw an Error.')); @@ -315,7 +312,7 @@ describe('firestore()', function() { } }); - it('throws if persistence is not a boolean', function() { + it('throws if persistence is not a boolean', function () { try { firebase.firestore().settings({ persistence: 'true' }); return Promise.reject(new Error('Did not throw an Error.')); @@ -325,7 +322,7 @@ describe('firestore()', function() { } }); - it('throws if ssl is not a boolean', function() { + it('throws if ssl is not a boolean', function () { try { firebase.firestore().settings({ ssl: 'true' }); return Promise.reject(new Error('Did not throw an Error.')); @@ -336,9 +333,9 @@ describe('firestore()', function() { }); }); - describe('Clear cached data persistence', function() { + describe('Clear cached data persistence', function () { // NOTE: removed as it breaks emulator tests along with 'accepts an unlimited cache size' test above - xit('should clear any cached data', async function() { + xit('should clear any cached data', async function () { const db = firebase.firestore(); const id = 'foobar'; const ref = db.doc(`${COLLECTION}/${id}`); @@ -363,8 +360,8 @@ describe('firestore()', function() { }); }); - describe('wait for pending writes', function() { - xit('waits for pending writes', async function() { + describe('wait for pending writes', function () { + xit('waits for pending writes', async function () { const waitForPromiseMs = 500; const testTimeoutMs = 10000; diff --git a/packages/firestore/e2e/issues.e2e.js b/packages/firestore/e2e/issues.e2e.js index 26fe7c9bd9..7f6dac3dc5 100644 --- a/packages/firestore/e2e/issues.e2e.js +++ b/packages/firestore/e2e/issues.e2e.js @@ -17,38 +17,20 @@ const COLLECTION = 'firestore'; -describe('firestore()', function() { - describe(COLLECTION, function() { - before(async function() { +describe('firestore()', function () { + describe(COLLECTION, function () { + before(async function () { await Promise.all([ - firebase - .firestore() - .doc(`${COLLECTION}/wbXwyLJheRfYXXWlY46j`) - .set({ index: 2, number: 2 }), - firebase - .firestore() - .doc(`${COLLECTION}/kGC5cYPN1nKnZCcAb9oQ`) - .set({ index: 6, number: 2 }), - firebase - .firestore() - .doc(`${COLLECTION}/8Ek8iWCDQPPJ5s2n8PiQ`) - .set({ index: 4, number: 2 }), - firebase - .firestore() - .doc(`${COLLECTION}/mr7MdAygvuheF6AUtWma`) - .set({ index: 1, number: 1 }), - firebase - .firestore() - .doc(`${COLLECTION}/RCO5SvNn4fdoE49OKrIV`) - .set({ index: 3, number: 1 }), - firebase - .firestore() - .doc(`${COLLECTION}/CvVG7VP1hXTtcfdUaeNl`) - .set({ index: 5, number: 1 }), + firebase.firestore().doc(`${COLLECTION}/wbXwyLJheRfYXXWlY46j`).set({ index: 2, number: 2 }), + firebase.firestore().doc(`${COLLECTION}/kGC5cYPN1nKnZCcAb9oQ`).set({ index: 6, number: 2 }), + firebase.firestore().doc(`${COLLECTION}/8Ek8iWCDQPPJ5s2n8PiQ`).set({ index: 4, number: 2 }), + firebase.firestore().doc(`${COLLECTION}/mr7MdAygvuheF6AUtWma`).set({ index: 1, number: 1 }), + firebase.firestore().doc(`${COLLECTION}/RCO5SvNn4fdoE49OKrIV`).set({ index: 3, number: 1 }), + firebase.firestore().doc(`${COLLECTION}/CvVG7VP1hXTtcfdUaeNl`).set({ index: 5, number: 1 }), ]); }); - it('returns all results', async function() { + it('returns all results', async function () { const db = firebase.firestore(); const ref = db.collection(COLLECTION).orderBy('number', 'desc'); const allResultsSnapshot = await ref.get(); @@ -74,7 +56,7 @@ describe('firestore()', function() { }); }); - it('returns first page', async function() { + it('returns first page', async function () { const db = firebase.firestore(); const ref = db.collection(COLLECTION).orderBy('number', 'desc'); const firstPageSnapshot = await ref.limit(2).get(); @@ -89,7 +71,7 @@ describe('firestore()', function() { }); }); - it('returns second page', async function() { + it('returns second page', async function () { const db = firebase.firestore(); const ref = db.collection(COLLECTION).orderBy('number', 'desc'); const firstPageSnapshot = await ref.limit(2).get(); @@ -98,10 +80,7 @@ describe('firestore()', function() { lastDocument = doc; }); - const secondPageSnapshot = await ref - .startAfter(lastDocument) - .limit(2) - .get(); + const secondPageSnapshot = await ref.startAfter(lastDocument).limit(2).get(); should.equal(secondPageSnapshot.docs.length, 2); secondPageSnapshot.forEach((doc, i) => { if (i === 0) { diff --git a/packages/firestore/lib/FirestoreTransactionHandler.js b/packages/firestore/lib/FirestoreTransactionHandler.js index 82bead232c..4b3dc9debf 100644 --- a/packages/firestore/lib/FirestoreTransactionHandler.js +++ b/packages/firestore/lib/FirestoreTransactionHandler.js @@ -158,10 +158,7 @@ export default class FirestoreTransactionHandler { const meta = { id, updateFunction, - stack: new Error().stack - .split('\n') - .slice(2) - .join('\n'), + stack: new Error().stack.split('\n').slice(2).join('\n'), }; this._pending[id] = { diff --git a/packages/firestore/lib/index.d.ts b/packages/firestore/lib/index.d.ts index 1b9fdb9152..c8e81c31df 100644 --- a/packages/firestore/lib/index.d.ts +++ b/packages/firestore/lib/index.d.ts @@ -2060,6 +2060,7 @@ export default defaultExport; * Attach namespace to `firebase.` and `FirebaseApp.`. */ declare module '@react-native-firebase/app' { + // eslint-disable-next-line @typescript-eslint/no-unused-vars namespace ReactNativeFirebase { import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp; interface Module { diff --git a/packages/functions/__tests__/functions.test.ts b/packages/functions/__tests__/functions.test.ts index 008f1bbe8e..8bdce7a13d 100644 --- a/packages/functions/__tests__/functions.test.ts +++ b/packages/functions/__tests__/functions.test.ts @@ -1,16 +1,16 @@ import functions, { firebase } from '../lib'; -describe('Cloud Functions', function() { - describe('namespace', function() { - it('accessible from firebase.app()', function() { +describe('Cloud Functions', function () { + describe('namespace', function () { + it('accessible from firebase.app()', function () { const app = firebase.app(); expect(app.functions).toBeDefined(); expect(app.functions().httpsCallable).toBeDefined(); }); }); - describe('useFunctionsEmulator()', function() { - it('useFunctionsEmulator -> uses 10.0.2.2', function() { + describe('useFunctionsEmulator()', function () { + it('useFunctionsEmulator -> uses 10.0.2.2', function () { functions().useFunctionsEmulator('http://localhost'); // @ts-ignore @@ -23,8 +23,8 @@ describe('Cloud Functions', function() { }); }); - describe('httpcallable()', function() { - it('throws an error with an incorrect timeout', function() { + describe('httpcallable()', function () { + it('throws an error with an incorrect timeout', function () { const app = firebase.app(); // @ts-ignore diff --git a/packages/functions/e2e/functions.e2e.js b/packages/functions/e2e/functions.e2e.js index fd512e5538..6aae62c902 100644 --- a/packages/functions/e2e/functions.e2e.js +++ b/packages/functions/e2e/functions.e2e.js @@ -17,9 +17,9 @@ const { SAMPLE_DATA } = require('@react-native-firebase/private-tests-firebase-functions'); -describe('functions()', function() { - describe('namespace', function() { - it('accepts passing in an FirebaseApp instance as first arg', async function() { +describe('functions()', function () { + describe('namespace', function () { + it('accepts passing in an FirebaseApp instance as first arg', async function () { const appName = `functionsApp${FirebaseHelpers.id}1`; const platformAppConfig = FirebaseHelpers.app.config(); const app = await firebase.initializeApp(platformAppConfig, appName); @@ -34,7 +34,7 @@ describe('functions()', function() { app.functions().app.name.should.equal(app.name); }); - it('accepts passing in a region string as first arg to an app', async function() { + it('accepts passing in a region string as first arg to an app', async function () { const region = 'europe-west1'; const functionsForRegion = firebase.app().functions(region); @@ -42,15 +42,9 @@ describe('functions()', function() { functionsForRegion.app.should.equal(firebase.app()); functionsForRegion.app.name.should.equal(firebase.app().name); - firebase - .app() - .functions(region) - .app.should.equal(firebase.app()); + firebase.app().functions(region).app.should.equal(firebase.app()); - firebase - .app() - .functions(region) - ._customUrlOrRegion.should.equal(region); + firebase.app().functions(region)._customUrlOrRegion.should.equal(region); const functionRunner = functionsForRegion.httpsCallable('testFunctionCustomRegion'); @@ -59,7 +53,7 @@ describe('functions()', function() { }); }); - it('useFunctionsEmulator', async function() { + it('useFunctionsEmulator', async function () { const region = 'europe-west2'; const fnName = 'invertaseReactNativeFirebaseFunctionsEmulator'; const functions = firebase.app().functions(region); @@ -72,44 +66,44 @@ describe('functions()', function() { response.data.fnName.should.equal(fnName); }); - describe('httpsCallable(fnName)(args)', function() { - it('accepts primitive args: undefined', async function() { + describe('httpsCallable(fnName)(args)', function () { + it('accepts primitive args: undefined', async function () { const functionRunner = firebase.functions().httpsCallable('testFunctionDefaultRegion'); const response = await functionRunner(); response.data.should.equal('null'); }); - it('accepts primitive args: string', async function() { + it('accepts primitive args: string', async function () { const functionRunner = firebase.functions().httpsCallable('testFunctionDefaultRegion'); const response = await functionRunner('hello'); response.data.should.equal('string'); }); - it('accepts primitive args: number', async function() { + it('accepts primitive args: number', async function () { const functionRunner = firebase.functions().httpsCallable('testFunctionDefaultRegion'); const response = await functionRunner(123); response.data.should.equal('number'); }); - it('accepts primitive args: boolean', async function() { + it('accepts primitive args: boolean', async function () { const functionRunner = firebase.functions().httpsCallable('testFunctionDefaultRegion'); const response = await functionRunner(true); response.data.should.equal('boolean'); }); - it('accepts primitive args: null', async function() { + it('accepts primitive args: null', async function () { const functionRunner = firebase.functions().httpsCallable('testFunctionDefaultRegion'); const response = await functionRunner(null); response.data.should.equal('null'); }); - it('accepts array args', async function() { + it('accepts array args', async function () { const functionRunner = firebase.functions().httpsCallable('testFunctionDefaultRegion'); const response = await functionRunner([1, 2, 3, 4]); response.data.should.equal('array'); }); - it('accepts object args', async function() { + it('accepts object args', async function () { const type = 'object'; const inputData = SAMPLE_DATA[type]; const functionRunner = firebase.functions().httpsCallable('testFunctionDefaultRegion'); @@ -120,7 +114,7 @@ describe('functions()', function() { should.deepEqual(outputData, inputData); }); - it('accepts complex nested objects', async function() { + it('accepts complex nested objects', async function () { const type = 'deepObject'; const inputData = SAMPLE_DATA[type]; const functionRunner = firebase.functions().httpsCallable('testFunctionDefaultRegion'); @@ -131,7 +125,7 @@ describe('functions()', function() { should.deepEqual(outputData, inputData); }); - it('accepts complex nested arrays', async function() { + it('accepts complex nested arrays', async function () { const type = 'deepArray'; const inputData = SAMPLE_DATA[type]; const functionRunner = firebase.functions().httpsCallable('testFunctionDefaultRegion'); @@ -143,8 +137,8 @@ describe('functions()', function() { }); }); - describe('HttpsError', function() { - it('errors return instance of HttpsError', async function() { + describe('HttpsError', function () { + it('errors return instance of HttpsError', async function () { const functionRunner = firebase.functions().httpsCallable('testFunctionDefaultRegion'); try { @@ -159,7 +153,7 @@ describe('functions()', function() { return Promise.resolve(); }); - it('HttpsError.details -> allows returning complex data', async function() { + it('HttpsError.details -> allows returning complex data', async function () { let type = 'deepObject'; let inputData = SAMPLE_DATA[type]; const functionRunner = firebase.functions().httpsCallable('testFunctionDefaultRegion'); @@ -198,7 +192,7 @@ describe('functions()', function() { return Promise.resolve(); }); - it('HttpsError.details -> allows returning primitives', async function() { + it('HttpsError.details -> allows returning primitives', async function () { let type = 'number'; let inputData = SAMPLE_DATA[type]; const functionRunner = firebase.functions().httpsCallable('testFunctionDefaultRegion'); @@ -271,7 +265,7 @@ describe('functions()', function() { return Promise.resolve(); }); - it('HttpsCallableOptions.timeout will error when timeout is exceeded', async function() { + it('HttpsCallableOptions.timeout will error when timeout is exceeded', async function () { const fnName = 'invertaseReactNativeFirebaseFunctionsEmulator'; const region = 'europe-west2'; diff --git a/packages/functions/lib/index.d.ts b/packages/functions/lib/index.d.ts index d1c7ecb539..7b733e1d9f 100644 --- a/packages/functions/lib/index.d.ts +++ b/packages/functions/lib/index.d.ts @@ -377,6 +377,7 @@ export default defaultExport; * Attach namespace to `firebase.` and `FirebaseApp.`. */ declare module '@react-native-firebase/app' { + // eslint-disable-next-line @typescript-eslint/no-unused-vars namespace ReactNativeFirebase { import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp; interface Module { diff --git a/packages/iid/e2e/iid.e2e.js b/packages/iid/e2e/iid.e2e.js index 188627c8e9..0a61b1ddab 100644 --- a/packages/iid/e2e/iid.e2e.js +++ b/packages/iid/e2e/iid.e2e.js @@ -15,37 +15,31 @@ * */ -describe('iid()', function() { - afterEach(async function() { +describe('iid()', function () { + afterEach(async function () { await Utils.sleep(150); }); - describe('namespace', function() { - it('accessible from firebase.app()', function() { + describe('namespace', function () { + it('accessible from firebase.app()', function () { const app = firebase.app(); should.exist(app.iid); app.iid().app.should.equal(app); }); - it('supports multiple apps', async function() { + it('supports multiple apps', async function () { firebase.iid().app.name.should.equal('[DEFAULT]'); firebase .iid(firebase.app('secondaryFromNative')) .app.name.should.equal('secondaryFromNative'); - firebase - .app('secondaryFromNative') - .iid() - .app.name.should.equal('secondaryFromNative'); + firebase.app('secondaryFromNative').iid().app.name.should.equal('secondaryFromNative'); await Utils.sleep(1000); const defaultToken = await firebase.iid().getToken(); await Utils.sleep(1000); - const secondaryToken = await firebase - .app('secondaryFromNative') - .iid() - .getToken(); + const secondaryToken = await firebase.app('secondaryFromNative').iid().getToken(); defaultToken.should.be.a.String(); secondaryToken.should.be.a.String(); @@ -58,14 +52,14 @@ describe('iid()', function() { }); }); - describe('get()', function() { - it('returns instance id string', async function() { + describe('get()', function () { + it('returns instance id string', async function () { const iid = await firebase.iid().get(); iid.should.be.a.String(); }); }); - describe('delete()', function() { + describe('delete()', function () { android.it('deletes the current instance id', async () => { const iidBefore = await firebase.iid().get(); await Utils.sleep(1000); @@ -80,19 +74,19 @@ describe('iid()', function() { }); }); - describe('getToken()', function() { - it('should return an FCM token from getToken with arguments', async function() { + describe('getToken()', function () { + it('should return an FCM token from getToken with arguments', async function () { const authorizedEntity = firebase.iid().app.options.messagingSenderId; const token = await firebase.iid().getToken(authorizedEntity, '*'); token.should.be.a.String(); }); - it('should return an FCM token from getToken without arguments', async function() { + it('should return an FCM token from getToken without arguments', async function () { const token = await firebase.iid().getToken(); token.should.be.a.String(); }); - it('should return an FCM token from getToken with 1 argument', async function() { + it('should return an FCM token from getToken with 1 argument', async function () { const authorizedEntity = firebase.iid().app.options.messagingSenderId; const token = await firebase.iid().getToken(authorizedEntity); @@ -100,7 +94,7 @@ describe('iid()', function() { }); }); - describe('deleteToken()', function() { + describe('deleteToken()', function () { android.it('should return nil from deleteToken with arguments', async () => { const authorizedEntity = firebase.iid().app.options.messagingSenderId; const token = await firebase.iid().deleteToken(authorizedEntity, '*'); diff --git a/packages/iid/lib/index.d.ts b/packages/iid/lib/index.d.ts index fab2763402..29d7dec012 100644 --- a/packages/iid/lib/index.d.ts +++ b/packages/iid/lib/index.d.ts @@ -147,6 +147,7 @@ export default defaultExport; * Attach namespace to `firebase.` and `FirebaseApp.`. */ declare module '@react-native-firebase/app' { + // eslint-disable-next-line @typescript-eslint/no-unused-vars namespace ReactNativeFirebase { import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp; interface Module { diff --git a/packages/in-app-messaging/e2e/fiam.e2e.js b/packages/in-app-messaging/e2e/fiam.e2e.js index 4f6b0b2e0b..72d48dd115 100644 --- a/packages/in-app-messaging/e2e/fiam.e2e.js +++ b/packages/in-app-messaging/e2e/fiam.e2e.js @@ -15,17 +15,17 @@ * */ -describe('inAppMessaging()', function() { - describe('namespace', function() { - it('accessible from firebase.app()', function() { +describe('inAppMessaging()', function () { + describe('namespace', function () { + it('accessible from firebase.app()', function () { const app = firebase.app(); should.exist(app.inAppMessaging); app.inAppMessaging().app.should.equal(app); }); }); - describe('setAutomaticDataCollectionEnabled()', function() { - it('true', async function() { + describe('setAutomaticDataCollectionEnabled()', function () { + it('true', async function () { if (Platform.ios) { // android has this as false when Perf tests run prior - internally all share the same flag on the native SDK should.equal(firebase.inAppMessaging().isAutomaticDataCollectionEnabled, true); @@ -35,7 +35,7 @@ describe('inAppMessaging()', function() { await Utils.sleep(2000); }); // TODO flakey on CI - xit('false', async function() { + xit('false', async function () { await device.launchApp(); await firebase.inAppMessaging().setAutomaticDataCollectionEnabled(false); should.equal(firebase.inAppMessaging().isAutomaticDataCollectionEnabled, false); @@ -45,7 +45,7 @@ describe('inAppMessaging()', function() { await Utils.sleep(1500); }); - it('errors if not boolean', async function() { + it('errors if not boolean', async function () { try { firebase.inAppMessaging().setAutomaticDataCollectionEnabled(); return Promise.reject(new Error('Did not throw')); @@ -56,15 +56,15 @@ describe('inAppMessaging()', function() { }); }); - xdescribe('setMessagesDisplaySuppressed()', function() { - it('false', async function() { + xdescribe('setMessagesDisplaySuppressed()', function () { + it('false', async function () { should.equal(firebase.inAppMessaging().isMessagesDisplaySuppressed, false); await firebase.inAppMessaging().setMessagesDisplaySuppressed(false); should.equal(firebase.inAppMessaging().isMessagesDisplaySuppressed, false); await Utils.sleep(2000); }); - it('true', async function() { + it('true', async function () { await device.launchApp(); await firebase.inAppMessaging().setMessagesDisplaySuppressed(true); should.equal(firebase.inAppMessaging().isMessagesDisplaySuppressed, true); @@ -74,7 +74,7 @@ describe('inAppMessaging()', function() { await Utils.sleep(1500); }); - it('errors if not boolean', async function() { + it('errors if not boolean', async function () { try { firebase.inAppMessaging().setMessagesDisplaySuppressed(); return Promise.reject(new Error('Did not throw')); @@ -85,8 +85,8 @@ describe('inAppMessaging()', function() { }); }); - xdescribe('triggerEvent()', function() { - it('no exceptions thrown', async function() { + xdescribe('triggerEvent()', function () { + it('no exceptions thrown', async function () { await device.launchApp(); await firebase.inAppMessaging().triggerEvent('eventName'); }); diff --git a/packages/in-app-messaging/lib/index.d.ts b/packages/in-app-messaging/lib/index.d.ts index 81b662d34a..cc3c46fbb0 100644 --- a/packages/in-app-messaging/lib/index.d.ts +++ b/packages/in-app-messaging/lib/index.d.ts @@ -165,6 +165,7 @@ export default defaultExport; * Attach namespace to `firebase.` and `FirebaseApp.`. */ declare module '@react-native-firebase/app' { + // eslint-disable-next-line @typescript-eslint/no-unused-vars namespace ReactNativeFirebase { import FirebaseModuleWithStatics = ReactNativeFirebase.FirebaseModuleWithStatics; interface Module { diff --git a/packages/messaging/e2e/messaging.e2e.js b/packages/messaging/e2e/messaging.e2e.js index 3bc16e825f..07ad6160e1 100644 --- a/packages/messaging/e2e/messaging.e2e.js +++ b/packages/messaging/e2e/messaging.e2e.js @@ -15,17 +15,17 @@ * */ -describe('messaging()', function() { - describe('namespace', function() { - it('accessible from firebase.app()', function() { +describe('messaging()', function () { + describe('namespace', function () { + it('accessible from firebase.app()', function () { const app = firebase.app(); should.exist(app.messaging); app.messaging().app.should.equal(app); }); }); - describe('setAutoInitEnabled()', function() { - it('throws if enabled is not a boolean', function() { + describe('setAutoInitEnabled()', function () { + it('throws if enabled is not a boolean', function () { try { firebase.messaging().setAutoInitEnabled(123); return Promise.reject(new Error('Did not throw Error.')); @@ -35,7 +35,7 @@ describe('messaging()', function() { } }); - it('sets the value', async function() { + it('sets the value', async function () { should.equal(firebase.messaging().isAutoInitEnabled, true); await firebase.messaging().setAutoInitEnabled(false); should.equal(firebase.messaging().isAutoInitEnabled, false); @@ -46,68 +46,68 @@ describe('messaging()', function() { }); }); - describe('isDeviceRegisteredForRemoteMessages', function() { + describe('isDeviceRegisteredForRemoteMessages', function () { android.it('returns true on android', () => { should.equal(firebase.messaging().isDeviceRegisteredForRemoteMessages, true); }); - it('defaults to false on ios before registering', function() { + it('defaults to false on ios before registering', function () { if (device.getPlatform() === 'ios') { should.equal(firebase.messaging().isDeviceRegisteredForRemoteMessages, false); } }); }); - describe('unregisterDeviceForRemoteMessages', function() { + describe('unregisterDeviceForRemoteMessages', function () { android.it('resolves on android', async () => { await firebase.messaging().unregisterDeviceForRemoteMessages(); }); }); - describe('hasPermission', function() { + describe('hasPermission', function () { android.it('returns true android (default)', async () => { should.equal(await firebase.messaging().hasPermission(), true); }); - it('returns -1 on ios (default)', async function() { + it('returns -1 on ios (default)', async function () { if (device.getPlatform() === 'ios') { should.equal(await firebase.messaging().hasPermission(), -1); } }); }); - describe('requestPermission', function() { + describe('requestPermission', function () { android.it('resolves 1 on android', async () => { should.equal(await firebase.messaging().requestPermission(), 1); }); }); - describe('getAPNSToken', function() { + describe('getAPNSToken', function () { android.it('resolves null on android', async () => { should.equal(await firebase.messaging().getAPNSToken(), null); }); - it('resolves null on ios if using simulator', async function() { + it('resolves null on ios if using simulator', async function () { if (device.getPlatform() === 'ios') { should.equal(await firebase.messaging().getAPNSToken(), null); } }); }); - describe('unsupported web sdk methods', function() { - it('useServiceWorker should not error when called', function() { + describe('unsupported web sdk methods', function () { + it('useServiceWorker should not error when called', function () { firebase.messaging().useServiceWorker(); }); - it('usePublicVapidKey should not error when called', function() { + it('usePublicVapidKey should not error when called', function () { firebase.messaging().usePublicVapidKey(); }); }); - describe('getInitialNotification', function() { - it('returns null when no initial notification', async function() { + describe('getInitialNotification', function () { + it('returns null when no initial notification', async function () { should.equal(await firebase.messaging().getInitialNotification(), null); }); }); - describe('getToken()', function() { - it('throws if authorizedEntity is not a string', function() { + describe('getToken()', function () { + it('throws if authorizedEntity is not a string', function () { try { firebase.messaging().getToken(123); return Promise.reject(new Error('Did not throw Error.')); @@ -117,7 +117,7 @@ describe('messaging()', function() { } }); - it('throws if scope is not a string', function() { + it('throws if scope is not a string', function () { try { firebase.messaging().getToken('123', 123); return Promise.reject(new Error('Did not throw Error.')); @@ -128,8 +128,8 @@ describe('messaging()', function() { }); }); - describe('deleteToken()', function() { - it('throws if authorizedEntity is not a string', function() { + describe('deleteToken()', function () { + it('throws if authorizedEntity is not a string', function () { try { firebase.messaging().deleteToken(123); return Promise.reject(new Error('Did not throw Error.')); @@ -139,7 +139,7 @@ describe('messaging()', function() { } }); - it('throws if scope is not a string', function() { + it('throws if scope is not a string', function () { try { firebase.messaging().deleteToken('123', 123); return Promise.reject(new Error('Did not throw Error.')); @@ -149,7 +149,7 @@ describe('messaging()', function() { } }); - xit('generate a new token after deleting', async function() { + xit('generate a new token after deleting', async function () { // const token1 = await firebase.messaging().getToken(); await firebase.messaging().deleteToken(); @@ -158,8 +158,8 @@ describe('messaging()', function() { }); }); - describe('onMessage()', function() { - it('throws if listener is not a function', function() { + describe('onMessage()', function () { + it('throws if listener is not a function', function () { try { firebase.messaging().onMessage({}); return Promise.reject(new Error('Did not throw Error.')); @@ -169,7 +169,7 @@ describe('messaging()', function() { } }); - xit('receives messages when the app is in the foreground', async function() { + xit('receives messages when the app is in the foreground', async function () { const spy = sinon.spy(); const unsubscribe = firebase.messaging().onMessage(spy); if (device.getPlatform() === 'ios') { @@ -190,8 +190,8 @@ describe('messaging()', function() { }); }); - describe('onTokenRefresh()', function() { - it('throws if listener is not a function', function() { + describe('onTokenRefresh()', function () { + it('throws if listener is not a function', function () { try { firebase.messaging().onTokenRefresh({}); return Promise.reject(new Error('Did not throw Error.')); @@ -202,8 +202,8 @@ describe('messaging()', function() { }); }); - describe('onDeletedMessages()', function() { - it('throws if listener is not a function', function() { + describe('onDeletedMessages()', function () { + it('throws if listener is not a function', function () { try { firebase.messaging().onDeletedMessages(123); return Promise.reject(new Error('Did not throw Error.')); @@ -214,8 +214,8 @@ describe('messaging()', function() { }); }); - describe('onMessageSent()', function() { - it('throws if listener is not a function', function() { + describe('onMessageSent()', function () { + it('throws if listener is not a function', function () { try { firebase.messaging().onMessageSent(123); return Promise.reject(new Error('Did not throw Error.')); @@ -226,8 +226,8 @@ describe('messaging()', function() { }); }); - describe('onSendError()', function() { - it('throws if listener is not a function', function() { + describe('onSendError()', function () { + it('throws if listener is not a function', function () { try { firebase.messaging().onSendError('123'); return Promise.reject(new Error('Did not throw Error.')); @@ -238,8 +238,8 @@ describe('messaging()', function() { }); }); - describe('setBackgroundMessageHandler()', function() { - it('throws if handler is not a function', function() { + describe('setBackgroundMessageHandler()', function () { + it('throws if handler is not a function', function () { try { firebase.messaging().setBackgroundMessageHandler('123'); return Promise.reject(new Error('Did not throw Error.')); @@ -276,8 +276,8 @@ describe('messaging()', function() { }); }); - describe('subscribeToTopic()', function() { - it('throws if topic is not a string', function() { + describe('subscribeToTopic()', function () { + it('throws if topic is not a string', function () { try { firebase.messaging().subscribeToTopic(123); return Promise.reject(new Error('Did not throw Error.')); @@ -287,7 +287,7 @@ describe('messaging()', function() { } }); - it('throws if topic contains a /', function() { + it('throws if topic contains a /', function () { try { firebase.messaging().subscribeToTopic('foo/bar'); return Promise.reject(new Error('Did not throw Error.')); @@ -298,8 +298,8 @@ describe('messaging()', function() { }); }); - describe('unsubscribeFromTopic()', function() { - it('throws if topic is not a string', function() { + describe('unsubscribeFromTopic()', function () { + it('throws if topic is not a string', function () { try { firebase.messaging().unsubscribeFromTopic(123); return Promise.reject(new Error('Did not throw Error.')); @@ -309,7 +309,7 @@ describe('messaging()', function() { } }); - it('throws if topic contains a /', function() { + it('throws if topic contains a /', function () { try { firebase.messaging().unsubscribeFromTopic('foo/bar'); return Promise.reject(new Error('Did not throw Error.')); diff --git a/packages/messaging/e2e/remoteMessage.e2e.js b/packages/messaging/e2e/remoteMessage.e2e.js index 4f8e4233bc..0d38f92406 100644 --- a/packages/messaging/e2e/remoteMessage.e2e.js +++ b/packages/messaging/e2e/remoteMessage.e2e.js @@ -15,8 +15,8 @@ * */ -describe('messaging().sendMessage(*)', function() { - it('throws if used on ios', function() { +describe('messaging().sendMessage(*)', function () { + it('throws if used on ios', function () { if (device.getPlatform() === 'ios') { try { firebase.messaging().sendMessage(123); @@ -47,7 +47,7 @@ describe('messaging().sendMessage(*)', function() { }); android.describe('to', () => { - it('throws if to is not a string', function() { + it('throws if to is not a string', function () { try { firebase.messaging().sendMessage({ to: 123, @@ -59,7 +59,7 @@ describe('messaging().sendMessage(*)', function() { } }); - it('accepts custom to value', async function() { + it('accepts custom to value', async function () { await firebase.messaging().sendMessage({ to: 'foobar', }); @@ -67,7 +67,7 @@ describe('messaging().sendMessage(*)', function() { }); android.describe('messageId', () => { - it('throws if messageId is not a string', function() { + it('throws if messageId is not a string', function () { try { firebase.messaging().sendMessage({ messageId: 123, @@ -79,7 +79,7 @@ describe('messaging().sendMessage(*)', function() { } }); - it('accepts custom messageId value', async function() { + it('accepts custom messageId value', async function () { await firebase.messaging().sendMessage({ messageId: 'foobar', }); @@ -87,7 +87,7 @@ describe('messaging().sendMessage(*)', function() { }); android.describe('ttl', () => { - it('throws if not a number', function() { + it('throws if not a number', function () { try { firebase.messaging().sendMessage({ ttl: '123', @@ -99,7 +99,7 @@ describe('messaging().sendMessage(*)', function() { } }); - it('throws if negative number', function() { + it('throws if negative number', function () { try { firebase.messaging().sendMessage({ ttl: -2, @@ -111,7 +111,7 @@ describe('messaging().sendMessage(*)', function() { } }); - it('throws if float number', function() { + it('throws if float number', function () { try { firebase.messaging().sendMessage({ ttl: 123.4, @@ -123,7 +123,7 @@ describe('messaging().sendMessage(*)', function() { } }); - it('accepts custom ttl value', async function() { + it('accepts custom ttl value', async function () { await firebase.messaging().sendMessage({ ttl: 123, }); @@ -131,7 +131,7 @@ describe('messaging().sendMessage(*)', function() { }); android.describe('data', () => { - it('throws if data not an object', function() { + it('throws if data not an object', function () { try { firebase.messaging().sendMessage({ data: 123, @@ -143,7 +143,7 @@ describe('messaging().sendMessage(*)', function() { } }); - it('accepts custom data value', async function() { + it('accepts custom data value', async function () { await firebase.messaging().sendMessage({ data: { foo: 'bar', @@ -153,7 +153,7 @@ describe('messaging().sendMessage(*)', function() { }); android.describe('collapseKey', () => { - it('throws if collapseKey is not a string', function() { + it('throws if collapseKey is not a string', function () { try { firebase.messaging().sendMessage({ collapseKey: 123, @@ -165,7 +165,7 @@ describe('messaging().sendMessage(*)', function() { } }); - it('accepts custom collapseKey value', async function() { + it('accepts custom collapseKey value', async function () { await firebase.messaging().sendMessage({ collapseKey: 'foobar', }); @@ -173,7 +173,7 @@ describe('messaging().sendMessage(*)', function() { }); android.describe('messageType', () => { - it('throws if messageType is not a string', function() { + it('throws if messageType is not a string', function () { try { firebase.messaging().sendMessage({ messageType: 123, @@ -185,7 +185,7 @@ describe('messaging().sendMessage(*)', function() { } }); - it('accepts custom messageType value', async function() { + it('accepts custom messageType value', async function () { await firebase.messaging().sendMessage({ messageType: 'foobar', }); diff --git a/packages/messaging/lib/index.d.ts b/packages/messaging/lib/index.d.ts index 136322c558..c10fea7f51 100644 --- a/packages/messaging/lib/index.d.ts +++ b/packages/messaging/lib/index.d.ts @@ -382,7 +382,6 @@ export namespace FirebaseMessagingTypes { * An interface representing all the available permissions that can be requested by your app via * the `requestPermission` API. */ - // eslint-disable-next-line @typescript-eslint/interface-name-prefix export interface IOSPermissions { /** * Request permission to display alerts. @@ -984,6 +983,7 @@ export default defaultExport; * Attach namespace to `firebase.` and `FirebaseApp.`. */ declare module '@react-native-firebase/app' { + // eslint-disable-next-line @typescript-eslint/no-unused-vars namespace ReactNativeFirebase { import FirebaseModuleWithStatics = ReactNativeFirebase.FirebaseModuleWithStatics; interface Module { diff --git a/packages/ml/e2e/documentText.e2e.js b/packages/ml/e2e/documentText.e2e.js index b1b413bc81..3ae1247af5 100644 --- a/packages/ml/e2e/documentText.e2e.js +++ b/packages/ml/e2e/documentText.e2e.js @@ -42,17 +42,14 @@ function documentTextBaseElementValidate(documentTextBase) { let testImageFile; -describe('ml.document.text', function() { - before(async function() { +describe('ml.document.text', function () { + before(async function () { testImageFile = `${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/text.png`; - await firebase - .storage() - .ref('vision/text.png') - .writeToFile(testImageFile); + await firebase.storage().ref('vision/text.png').writeToFile(testImageFile); }); - describe('MLCloudDocumentTextRecognizerOptions', function() { - it('throws if not an object', async function() { + describe('MLCloudDocumentTextRecognizerOptions', function () { + it('throws if not an object', async function () { try { await firebase.ml().cloudDocumentTextRecognizerProcessImage(testImageFile, 'foo'); return Promise.reject(new Error('Did not throw Error.')); @@ -64,7 +61,7 @@ describe('ml.document.text', function() { } }); - it('throws if enforceCertFingerprintMatch is not a boolean', async function() { + it('throws if enforceCertFingerprintMatch is not a boolean', async function () { try { await firebase.ml().cloudDocumentTextRecognizerProcessImage(testImageFile, { enforceCertFingerprintMatch: 'true', @@ -78,13 +75,13 @@ describe('ml.document.text', function() { } }); - it('sets enforceCertFingerprintMatch', async function() { + it('sets enforceCertFingerprintMatch', async function () { await firebase.ml().cloudDocumentTextRecognizerProcessImage(testImageFile, { enforceCertFingerprintMatch: false, }); }); - it('throws if apiKeyOverride is not a string', async function() { + it('throws if apiKeyOverride is not a string', async function () { try { await firebase.ml().cloudDocumentTextRecognizerProcessImage(testImageFile, { apiKeyOverride: true, @@ -98,7 +95,7 @@ describe('ml.document.text', function() { } }); - it('throws if languageHints is not an array', async function() { + it('throws if languageHints is not an array', async function () { try { await firebase.ml().cloudDocumentTextRecognizerProcessImage(testImageFile, { languageHints: 'en', @@ -112,7 +109,7 @@ describe('ml.document.text', function() { } }); - it('throws if languageHints is empty array', async function() { + it('throws if languageHints is empty array', async function () { try { await firebase.ml().cloudDocumentTextRecognizerProcessImage(testImageFile, { languageHints: [], @@ -126,7 +123,7 @@ describe('ml.document.text', function() { } }); - it('throws if languageHints contains non-string', async function() { + it('throws if languageHints contains non-string', async function () { try { await firebase.ml().cloudDocumentTextRecognizerProcessImage(testImageFile, { languageHints: [123], @@ -140,15 +137,15 @@ describe('ml.document.text', function() { } }); - it('sets hinted languages', async function() { + it('sets hinted languages', async function () { await firebase.ml().cloudDocumentTextRecognizerProcessImage(testImageFile, { languageHints: ['fr'], }); }); }); - describe('cloudDocumentTextRecognizerProcessImage()', function() { - it('should throw if image path is not a string', function() { + describe('cloudDocumentTextRecognizerProcessImage()', function () { + it('should throw if image path is not a string', function () { try { firebase.ml().cloudDocumentTextRecognizerProcessImage(123); return Promise.reject(new Error('Did not throw an Error.')); @@ -158,7 +155,7 @@ describe('ml.document.text', function() { } }); - it('should return a MLDocumentText representation for an image', async function() { + it('should return a MLDocumentText representation for an image', async function () { const res = await firebase.ml().cloudDocumentTextRecognizerProcessImage(testImageFile); res.text.should.be.a.String(); diff --git a/packages/ml/e2e/label.e2e.js b/packages/ml/e2e/label.e2e.js index 5c1afa5c8d..50ecdf43f5 100644 --- a/packages/ml/e2e/label.e2e.js +++ b/packages/ml/e2e/label.e2e.js @@ -17,17 +17,14 @@ let testImageFile; -describe('ml.label', function() { - before(async function() { +describe('ml.label', function () { + before(async function () { testImageFile = `${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/crab.jpg`; - await firebase - .storage() - .ref('vision/crab.jpg') - .writeToFile(testImageFile); + await firebase.storage().ref('vision/crab.jpg').writeToFile(testImageFile); }); - describe('cloudImageLabelerProcessImage()', function() { - it('should throw if image path is not a string', function() { + describe('cloudImageLabelerProcessImage()', function () { + it('should throw if image path is not a string', function () { try { firebase.ml().cloudImageLabelerProcessImage(123); return Promise.reject(new Error('Did not throw an Error.')); @@ -37,7 +34,7 @@ describe('ml.label', function() { } }); - xit('should return a cloud label array', async function() { + xit('should return a cloud label array', async function () { const res = await firebase.ml().cloudImageLabelerProcessImage(testImageFile); res.should.be.Array(); @@ -51,8 +48,8 @@ describe('ml.label', function() { }); }); - describe('MLCloudImageLabelerOptions', function() { - it('throws if not an object', async function() { + describe('MLCloudImageLabelerOptions', function () { + it('throws if not an object', async function () { try { await firebase.ml().cloudImageLabelerProcessImage(testImageFile, '123'); return Promise.reject(new Error('Did not throw an Error.')); @@ -62,8 +59,8 @@ describe('ml.label', function() { } }); - describe('confidenceThreshold', function() { - it('should throw if confidence threshold is not a number', async function() { + describe('confidenceThreshold', function () { + it('should throw if confidence threshold is not a number', async function () { try { await firebase.ml().cloudImageLabelerProcessImage(testImageFile, { confidenceThreshold: '0.2', @@ -77,7 +74,7 @@ describe('ml.label', function() { } }); - it('should throw if confidence threshold is not between 0 & 1', async function() { + it('should throw if confidence threshold is not between 0 & 1', async function () { try { await firebase.ml().cloudImageLabelerProcessImage(testImageFile, { confidenceThreshold: 1.1, @@ -91,7 +88,7 @@ describe('ml.label', function() { } }); - xit('should accept options and return cloud labels', async function() { + xit('should accept options and return cloud labels', async function () { const res = await firebase.ml().cloudImageLabelerProcessImage(testImageFile, { confidenceThreshold: 0.8, }); @@ -107,8 +104,8 @@ describe('ml.label', function() { }); }); - describe('enforceCertFingerprintMatch', function() { - it('throws if not a boolean', async function() { + describe('enforceCertFingerprintMatch', function () { + it('throws if not a boolean', async function () { try { await firebase.ml().cloudImageLabelerProcessImage(testImageFile, { enforceCertFingerprintMatch: 'true', @@ -122,15 +119,15 @@ describe('ml.label', function() { } }); - xit('sets enforceCertFingerprintMatch', async function() { + xit('sets enforceCertFingerprintMatch', async function () { await firebase.ml().cloudImageLabelerProcessImage(testImageFile, { enforceCertFingerprintMatch: false, }); }); }); - xdescribe('apiKeyOverride', function() { - it('throws if apiKeyOverride is not a string', async function() { + xdescribe('apiKeyOverride', function () { + it('throws if apiKeyOverride is not a string', async function () { try { await firebase.ml().cloudImageLabelerProcessImage(testImageFile, { apiKeyOverride: true, diff --git a/packages/ml/e2e/landmark.e2e.js b/packages/ml/e2e/landmark.e2e.js index 96ad490d73..f9cbb9253f 100644 --- a/packages/ml/e2e/landmark.e2e.js +++ b/packages/ml/e2e/landmark.e2e.js @@ -16,17 +16,14 @@ */ let testImageFile; -describe('ml.landmark', function() { - before(async function() { +describe('ml.landmark', function () { + before(async function () { testImageFile = `${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/landmark.jpg`; - await firebase - .storage() - .ref('vision/landmark.jpg') - .writeToFile(testImageFile); + await firebase.storage().ref('vision/landmark.jpg').writeToFile(testImageFile); }); - describe('cloudLandmarkRecognizerProcessImage()', function() { - it('should throw if image path is not a string', function() { + describe('cloudLandmarkRecognizerProcessImage()', function () { + it('should throw if image path is not a string', function () { try { firebase.ml().cloudLandmarkRecognizerProcessImage(123); return Promise.reject(new Error('Did not throw an Error.')); @@ -36,7 +33,7 @@ describe('ml.landmark', function() { } }); - xit('should return an array of landmark information', async function() { + xit('should return an array of landmark information', async function () { const res = await firebase.ml().cloudLandmarkRecognizerProcessImage(testImageFile); res.should.be.Array(); @@ -59,8 +56,8 @@ describe('ml.landmark', function() { }); }); - describe('MLCloudLandmarkRecognizerOptions', function() { - it('throws if not an object', async function() { + describe('MLCloudLandmarkRecognizerOptions', function () { + it('throws if not an object', async function () { try { await firebase.ml().cloudLandmarkRecognizerProcessImage(testImageFile, '123'); return Promise.reject(new Error('Did not throw an Error.')); @@ -72,8 +69,8 @@ describe('ml.landmark', function() { } }); - describe('cloudLandmarkRecognizerOptions', function() { - it('throws if not a boolean', async function() { + describe('cloudLandmarkRecognizerOptions', function () { + it('throws if not a boolean', async function () { try { await firebase.ml().cloudLandmarkRecognizerProcessImage(testImageFile, { enforceCertFingerprintMatch: 'false', @@ -87,13 +84,13 @@ describe('ml.landmark', function() { } }); - xit('sets cloudLandmarkRecognizerOptions', async function() { + xit('sets cloudLandmarkRecognizerOptions', async function () { await firebase.ml().cloudLandmarkRecognizerProcessImage(testImageFile, { enforceCertFingerprintMatch: false, }); }); - it('throws if apiKeyOverride is not a string', async function() { + it('throws if apiKeyOverride is not a string', async function () { try { await firebase.ml().cloudLandmarkRecognizerProcessImage(testImageFile, { apiKeyOverride: true, @@ -108,8 +105,8 @@ describe('ml.landmark', function() { }); }); // TODO temporarily disable test suite - is flakey on CI - needs investigating - describe('maxResults', function() { - it('throws if maxResults is not a number', async function() { + describe('maxResults', function () { + it('throws if maxResults is not a number', async function () { try { await firebase.ml().cloudLandmarkRecognizerProcessImage(testImageFile, { maxResults: '2', @@ -123,7 +120,7 @@ describe('ml.landmark', function() { } }); - xit('limits the maximum results', async function() { + xit('limits the maximum results', async function () { const res = await firebase.ml().cloudLandmarkRecognizerProcessImage(testImageFile, { maxResults: 3, }); @@ -135,8 +132,8 @@ describe('ml.landmark', function() { }); }); - describe('modelType', function() { - it('throws if model is invalid', async function() { + describe('modelType', function () { + it('throws if model is invalid', async function () { try { await firebase.ml().cloudLandmarkRecognizerProcessImage(testImageFile, { modelType: 3, @@ -150,7 +147,7 @@ describe('ml.landmark', function() { } }); - xit('sets modelType', async function() { + xit('sets modelType', async function () { await firebase.ml().cloudLandmarkRecognizerProcessImage(testImageFile, { modelType: firebase.ml.MLCloudLandmarkRecognizerModelType.STABLE_MODEL, }); @@ -160,7 +157,7 @@ describe('ml.landmark', function() { }); }); - xit('uses a latest model', async function() { + xit('uses a latest model', async function () { const res = await firebase.ml().cloudLandmarkRecognizerProcessImage(testImageFile, { modelType: firebase.ml.MLCloudLandmarkRecognizerModelType.LATEST_MODEL, }); diff --git a/packages/ml/e2e/ml.e2e.js b/packages/ml/e2e/ml.e2e.js index 22a49cc889..6937ea9d5b 100644 --- a/packages/ml/e2e/ml.e2e.js +++ b/packages/ml/e2e/ml.e2e.js @@ -15,23 +15,20 @@ * */ -describe('ml()', function() { - describe('namespace', function() { - it('accessible from firebase.app()', function() { +describe('ml()', function () { + describe('namespace', function () { + it('accessible from firebase.app()', function () { const app = firebase.app(); should.exist(app.ml); app.ml().app.should.equal(app); }); - it('supports multiple apps', async function() { + it('supports multiple apps', async function () { firebase.ml().app.name.should.equal('[DEFAULT]'); firebase.ml(firebase.app('secondaryFromNative')).app.name.should.equal('secondaryFromNative'); - firebase - .app('secondaryFromNative') - .ml() - .app.name.should.equal('secondaryFromNative'); + firebase.app('secondaryFromNative').ml().app.name.should.equal('secondaryFromNative'); }); }); }); diff --git a/packages/ml/e2e/text.e2e.js b/packages/ml/e2e/text.e2e.js index 30c12dd1b7..04adccfa12 100644 --- a/packages/ml/e2e/text.e2e.js +++ b/packages/ml/e2e/text.e2e.js @@ -69,17 +69,14 @@ function textBaseElementValidate(textBase, cloud = false) { let testImageFile; -describe('ml.text', function() { - before(async function() { +describe('ml.text', function () { + before(async function () { testImageFile = `${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/text.png`; - await firebase - .storage() - .ref('vision/text.png') - .writeToFile(testImageFile); + await firebase.storage().ref('vision/text.png').writeToFile(testImageFile); }); - describe('MLCloudTextRecognizerOptions', function() { - it('throws if not an object', async function() { + describe('MLCloudTextRecognizerOptions', function () { + it('throws if not an object', async function () { try { await firebase.ml().cloudTextRecognizerProcessImage(testImageFile, '123'); return Promise.reject(new Error('Did not throw an Error.')); @@ -89,8 +86,8 @@ describe('ml.text', function() { } }); - describe('enforceCertFingerprintMatch', function() { - it('throws if not a boolean', async function() { + describe('enforceCertFingerprintMatch', function () { + it('throws if not a boolean', async function () { try { await firebase.ml().cloudTextRecognizerProcessImage(testImageFile, { enforceCertFingerprintMatch: 'false', @@ -104,15 +101,15 @@ describe('ml.text', function() { } }); - it('sets a value', async function() { + it('sets a value', async function () { await firebase.ml().cloudTextRecognizerProcessImage(testImageFile, { enforceCertFingerprintMatch: false, }); }); }); - describe('apiKeyOverride', function() { - it('throws if apiKeyOverride is not a string', async function() { + describe('apiKeyOverride', function () { + it('throws if apiKeyOverride is not a string', async function () { try { await firebase.ml().cloudTextRecognizerProcessImage(testImageFile, { apiKeyOverride: true, @@ -127,8 +124,8 @@ describe('ml.text', function() { }); }); - describe('languageHints', function() { - it('throws if not array', async function() { + describe('languageHints', function () { + it('throws if not array', async function () { try { await firebase.ml().cloudTextRecognizerProcessImage(testImageFile, { languageHints: 'en', @@ -142,7 +139,7 @@ describe('ml.text', function() { } }); - it('throws if empty array', async function() { + it('throws if empty array', async function () { try { await firebase.ml().cloudTextRecognizerProcessImage(testImageFile, { languageHints: [], @@ -156,7 +153,7 @@ describe('ml.text', function() { } }); - it('throws if array contains non-string values', async function() { + it('throws if array contains non-string values', async function () { try { await firebase.ml().cloudTextRecognizerProcessImage(testImageFile, { languageHints: [123], @@ -170,15 +167,15 @@ describe('ml.text', function() { } }); - it('sets hintedLanguages', async function() { + it('sets hintedLanguages', async function () { await firebase.ml().cloudTextRecognizerProcessImage(testImageFile, { languageHints: ['fr'], }); }); }); - describe('modelType', function() { - it('throws if invalid type', async function() { + describe('modelType', function () { + it('throws if invalid type', async function () { try { await firebase.ml().cloudTextRecognizerProcessImage(testImageFile, { modelType: 7, @@ -190,7 +187,7 @@ describe('ml.text', function() { } }); - it('sets modelType', async function() { + it('sets modelType', async function () { await firebase.ml().cloudTextRecognizerProcessImage(testImageFile, { modelType: firebase.ml.MLCloudTextRecognizerModelType.SPARSE_MODEL, }); @@ -198,8 +195,8 @@ describe('ml.text', function() { }); }); - describe('cloudTextRecognizerProcessImage()', function() { - it('should throw if image path is not a string', function() { + describe('cloudTextRecognizerProcessImage()', function () { + it('should throw if image path is not a string', function () { try { firebase.ml().cloudTextRecognizerProcessImage(123); return Promise.reject(new Error('Did not throw an Error.')); @@ -209,7 +206,7 @@ describe('ml.text', function() { } }); - it('should return a VisionText representation for an image', async function() { + it('should return a VisionText representation for an image', async function () { const res = await firebase.ml().cloudTextRecognizerProcessImage(testImageFile); res.text.should.be.a.String(); res.blocks.should.be.an.Array(); diff --git a/packages/ml/lib/index.d.ts b/packages/ml/lib/index.d.ts index 9012b33ca6..f6546f353a 100644 --- a/packages/ml/lib/index.d.ts +++ b/packages/ml/lib/index.d.ts @@ -688,6 +688,7 @@ export default defaultExport; * Attach namespace to `firebase.` and `FirebaseApp.`. */ declare module '@react-native-firebase/app' { + // eslint-disable-next-line @typescript-eslint/no-unused-vars namespace ReactNativeFirebase { import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp; interface Module { diff --git a/packages/perf/__tests__/perf.test.ts b/packages/perf/__tests__/perf.test.ts index 93fc8ac62e..330c39efd8 100644 --- a/packages/perf/__tests__/perf.test.ts +++ b/packages/perf/__tests__/perf.test.ts @@ -1,16 +1,16 @@ import perf, { firebase } from '../lib'; -describe('Performance Monitoring', function() { - describe('namespace', function() { - it('accessible from firebase.app()', function() { +describe('Performance Monitoring', function () { + describe('namespace', function () { + it('accessible from firebase.app()', function () { const app = firebase.app(); expect(app.perf).toBeDefined(); expect(app.perf().app).toEqual(app); }); }); - describe('setPerformanceCollectionEnabled', function() { - it('errors if not boolean', function() { + describe('setPerformanceCollectionEnabled', function () { + it('errors if not boolean', function () { expect(() => { // @ts-ignore perf().setPerformanceCollectionEnabled(); @@ -18,8 +18,8 @@ describe('Performance Monitoring', function() { }); }); - describe('newTrace()', function() { - it('returns an instance of Trace', function() { + describe('newTrace()', function () { + it('returns an instance of Trace', function () { const trace = perf().newTrace('invertase'); expect(trace.constructor.name).toEqual('Trace'); @@ -27,7 +27,7 @@ describe('Performance Monitoring', function() { expect(trace._identifier).toEqual('invertase'); }); - it('errors if identifier not a string', function() { + it('errors if identifier not a string', function () { try { // @ts-ignore perf().newTrace(1337); @@ -40,7 +40,7 @@ describe('Performance Monitoring', function() { } }); - it('errors if identifier length > 100', function() { + it('errors if identifier length > 100', function () { try { perf().newTrace(new Array(101).fill('i').join('')); return Promise.reject(new Error('Did not throw')); @@ -53,8 +53,8 @@ describe('Performance Monitoring', function() { }); }); - describe('newHttpMetric()', function() { - it('returns an instance of HttpMetric', async function() { + describe('newHttpMetric()', function () { + it('returns an instance of HttpMetric', async function () { const metric = perf().newHttpMetric('https://invertase.io', 'GET'); expect(metric.constructor.name).toEqual('HttpMetric'); @@ -65,7 +65,7 @@ describe('Performance Monitoring', function() { expect(metric._httpMethod).toEqual('GET'); }); - it('errors if url not a string', async function() { + it('errors if url not a string', async function () { try { // @ts-ignore perf().newHttpMetric(1337, 7331); @@ -76,7 +76,7 @@ describe('Performance Monitoring', function() { } }); - it('errors if httpMethod not a string', async function() { + it('errors if httpMethod not a string', async function () { try { // @ts-ignore perf().newHttpMetric('https://invertase.io', 1337); @@ -89,7 +89,7 @@ describe('Performance Monitoring', function() { } }); - it('errors if httpMethod not a valid type', async function() { + it('errors if httpMethod not a valid type', async function () { try { // @ts-ignore perf().newHttpMetric('https://invertase.io', 'FIRE'); @@ -103,8 +103,8 @@ describe('Performance Monitoring', function() { }); }); - describe('setPerformanceCollectionEnabled()', function() { - it('errors if not boolean', async function() { + describe('setPerformanceCollectionEnabled()', function () { + it('errors if not boolean', async function () { try { // @ts-ignore firebase.perf().setPerformanceCollectionEnabled(); diff --git a/packages/perf/e2e/HttpMetric.e2e.js b/packages/perf/e2e/HttpMetric.e2e.js index c65ade3cf2..1de64e9e06 100644 --- a/packages/perf/e2e/HttpMetric.e2e.js +++ b/packages/perf/e2e/HttpMetric.e2e.js @@ -18,9 +18,9 @@ const aCoolUrl = 'https://invertase.io'; android.describe('perf()', () => { - describe('HttpMetric', function() { - describe('start()', function() { - it('correctly starts with internal flag ', async function() { + describe('HttpMetric', function () { + describe('start()', function () { + it('correctly starts with internal flag ', async function () { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); await httpMetric.start(); httpMetric.setHttpResponseCode(200); @@ -29,7 +29,7 @@ android.describe('perf()', () => { await httpMetric.stop(); }); - it('resolves null if already started', async function() { + it('resolves null if already started', async function () { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'POST'); await httpMetric.start(); should.equal(httpMetric._started, true); @@ -40,8 +40,8 @@ android.describe('perf()', () => { }); }); - describe('stop()', function() { - it('correctly stops with internal flag ', async function() { + describe('stop()', function () { + it('correctly stops with internal flag ', async function () { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); await httpMetric.start(); httpMetric.setHttpResponseCode(500); @@ -55,7 +55,7 @@ android.describe('perf()', () => { should.equal(httpMetric._stopped, true); }); - it('resolves null if already stopped', async function() { + it('resolves null if already stopped', async function () { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'POST'); await httpMetric.start(); await Utils.sleep(100); @@ -63,7 +63,7 @@ android.describe('perf()', () => { should.equal(await httpMetric.stop(), null); }); - it('handles floating point numbers', async function() { + it('handles floating point numbers', async function () { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'POST'); await httpMetric.start(); const floatingPoint = 500.447553; @@ -101,21 +101,21 @@ android.describe('perf()', () => { // }); // }); - describe('getAttribute()', function() { - it('should return null if attribute does not exist', async function() { + describe('getAttribute()', function () { + it('should return null if attribute does not exist', async function () { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); const value = httpMetric.getAttribute('inver'); should.equal(value, null); }); - it('should return an attribute string value', async function() { + it('should return an attribute string value', async function () { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); httpMetric.putAttribute('inver', 'tase'); const value = httpMetric.getAttribute('inver'); should.equal(value, 'tase'); }); - it('errors if attribute name is not a string', async function() { + it('errors if attribute name is not a string', async function () { try { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); httpMetric.getAttribute(1337); @@ -127,15 +127,15 @@ android.describe('perf()', () => { }); }); - describe('putAttribute()', function() { - it('sets an attribute string value', async function() { + describe('putAttribute()', function () { + it('sets an attribute string value', async function () { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); httpMetric.putAttribute('inver', 'tase'); const value = httpMetric.getAttribute('inver'); value.should.equal('tase'); }); - it('errors if attribute name is not a string', async function() { + it('errors if attribute name is not a string', async function () { try { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); httpMetric.putAttribute(1337, 'invertase'); @@ -146,7 +146,7 @@ android.describe('perf()', () => { } }); - it('errors if attribute value is not a string', async function() { + it('errors if attribute value is not a string', async function () { try { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); httpMetric.putAttribute('invertase', 1337); @@ -157,7 +157,7 @@ android.describe('perf()', () => { } }); - it('errors if attribute name is greater than 40 characters', async function() { + it('errors if attribute name is greater than 40 characters', async function () { try { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); httpMetric.putAttribute(new Array(41).fill('1').join(''), 1337); @@ -168,7 +168,7 @@ android.describe('perf()', () => { } }); - it('errors if attribute value is greater than 100 characters', async function() { + it('errors if attribute value is greater than 100 characters', async function () { try { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); httpMetric.putAttribute('invertase', new Array(101).fill('1').join('')); @@ -179,7 +179,7 @@ android.describe('perf()', () => { } }); - it('errors if more than 5 attributes are put', async function() { + it('errors if more than 5 attributes are put', async function () { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); httpMetric.putAttribute('invertase1', '1337'); @@ -209,20 +209,20 @@ android.describe('perf()', () => { // }); // }); - describe('setHttpResponseCode()', function() { - it('sets number value', async function() { + describe('setHttpResponseCode()', function () { + it('sets number value', async function () { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); httpMetric.setHttpResponseCode(500); should.equal(httpMetric._httpResponseCode, 500); }); - it('sets a null value to clear value', async function() { + it('sets a null value to clear value', async function () { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); httpMetric.setHttpResponseCode(null); should.equal(httpMetric._httpResponseCode, null); }); - it('errors if not a number or null value', async function() { + it('errors if not a number or null value', async function () { try { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); httpMetric.setHttpResponseCode('500'); @@ -234,20 +234,20 @@ android.describe('perf()', () => { }); }); - describe('setRequestPayloadSize()', function() { - it('sets number value', async function() { + describe('setRequestPayloadSize()', function () { + it('sets number value', async function () { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); httpMetric.setRequestPayloadSize(13377331); should.equal(httpMetric._requestPayloadSize, 13377331); }); - it('sets a null value to clear value', async function() { + it('sets a null value to clear value', async function () { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); httpMetric.setRequestPayloadSize(null); should.equal(httpMetric._requestPayloadSize, null); }); - it('errors if not a number or null value', async function() { + it('errors if not a number or null value', async function () { try { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); httpMetric.setRequestPayloadSize('1337'); @@ -259,20 +259,20 @@ android.describe('perf()', () => { }); }); - describe('setResponsePayloadSize()', function() { - it('sets number value', async function() { + describe('setResponsePayloadSize()', function () { + it('sets number value', async function () { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); httpMetric.setResponsePayloadSize(13377331); should.equal(httpMetric._responsePayloadSize, 13377331); }); - it('sets a null value to clear value', async function() { + it('sets a null value to clear value', async function () { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); httpMetric.setResponsePayloadSize(null); should.equal(httpMetric._responsePayloadSize, null); }); - it('errors if not a number or null value', async function() { + it('errors if not a number or null value', async function () { try { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); httpMetric.setResponsePayloadSize('1337'); @@ -284,20 +284,20 @@ android.describe('perf()', () => { }); }); - describe('setResponseContentType()', function() { - it('sets string value', async function() { + describe('setResponseContentType()', function () { + it('sets string value', async function () { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); httpMetric.setResponseContentType('application/invertase'); should.equal(httpMetric._responseContentType, 'application/invertase'); }); - it('sets a null value to clear value', async function() { + it('sets a null value to clear value', async function () { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); httpMetric.setResponseContentType(null); should.equal(httpMetric._responseContentType, null); }); - it('errors if not a string or null value', async function() { + it('errors if not a string or null value', async function () { try { const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); httpMetric.setResponseContentType(1337); diff --git a/packages/perf/e2e/Trace.e2e.js b/packages/perf/e2e/Trace.e2e.js index b114f57cc0..d11508eb72 100644 --- a/packages/perf/e2e/Trace.e2e.js +++ b/packages/perf/e2e/Trace.e2e.js @@ -16,9 +16,9 @@ */ android.describe('perf()', () => { - describe('Trace', function() { - describe('start()', function() { - it('correctly starts with internal flag ', async function() { + describe('Trace', function () { + describe('start()', function () { + it('correctly starts with internal flag ', async function () { const trace = firebase.perf().newTrace('invertase'); await trace.start(); should.equal(trace._started, true); @@ -28,7 +28,7 @@ android.describe('perf()', () => { await trace.stop(); }); - it('resolves null if already started', async function() { + it('resolves null if already started', async function () { const trace = firebase.perf().newTrace('invertase'); await trace.start(); should.equal(trace._started, true); @@ -38,8 +38,8 @@ android.describe('perf()', () => { }); }); - describe('stop()', function() { - it('correctly stops with internal flag ', async function() { + describe('stop()', function () { + it('correctly stops with internal flag ', async function () { const trace = firebase.perf().newTrace('invertase'); await trace.start(); trace.putAttribute('foo', 'bar'); @@ -51,7 +51,7 @@ android.describe('perf()', () => { should.equal(trace._stopped, true); }); - it('resolves null if already stopped', async function() { + it('resolves null if already stopped', async function () { const trace = firebase.perf().newTrace('invertase'); await trace.start(); await Utils.sleep(100); @@ -84,21 +84,21 @@ android.describe('perf()', () => { // }); // }); - describe('getAttribute()', function() { - it('should return null if attribute does not exist', async function() { + describe('getAttribute()', function () { + it('should return null if attribute does not exist', async function () { const trace = firebase.perf().newTrace('invertase'); const value = trace.getAttribute('inver'); should.equal(value, null); }); - it('should return an attribute string value', async function() { + it('should return an attribute string value', async function () { const trace = firebase.perf().newTrace('invertase'); trace.putAttribute('inver', 'tase'); const value = trace.getAttribute('inver'); should.equal(value, 'tase'); }); - it('errors if attribute name is not a string', async function() { + it('errors if attribute name is not a string', async function () { try { const trace = firebase.perf().newTrace('invertase'); trace.getAttribute(1337); @@ -110,15 +110,15 @@ android.describe('perf()', () => { }); }); - describe('putAttribute()', function() { - it('sets an attribute string value', async function() { + describe('putAttribute()', function () { + it('sets an attribute string value', async function () { const trace = firebase.perf().newTrace('invertase'); trace.putAttribute('inver', 'tase'); const value = trace.getAttribute('inver'); value.should.equal('tase'); }); - it('errors if attribute name is not a string', async function() { + it('errors if attribute name is not a string', async function () { try { const trace = firebase.perf().newTrace('invertase'); trace.putAttribute(1337, 'invertase'); @@ -129,7 +129,7 @@ android.describe('perf()', () => { } }); - it('errors if attribute value is not a string', async function() { + it('errors if attribute value is not a string', async function () { try { const trace = firebase.perf().newTrace('invertase'); trace.putAttribute('invertase', 1337); @@ -140,7 +140,7 @@ android.describe('perf()', () => { } }); - it('errors if attribute name is greater than 40 characters', async function() { + it('errors if attribute name is greater than 40 characters', async function () { try { const trace = firebase.perf().newTrace('invertase'); trace.putAttribute(new Array(41).fill('1').join(''), 1337); @@ -151,7 +151,7 @@ android.describe('perf()', () => { } }); - it('errors if attribute value is greater than 100 characters', async function() { + it('errors if attribute value is greater than 100 characters', async function () { try { const trace = firebase.perf().newTrace('invertase'); trace.putAttribute('invertase', new Array(101).fill('1').join('')); @@ -162,7 +162,7 @@ android.describe('perf()', () => { } }); - it('errors if more than 5 attributes are put', async function() { + it('errors if more than 5 attributes are put', async function () { const trace = firebase.perf().newTrace('invertase'); trace.putAttribute('invertase1', '1337'); @@ -197,8 +197,8 @@ android.describe('perf()', () => { // Metrics // ----------- - describe('removeMetric()', function() { - it('errors if name not a string', async function() { + describe('removeMetric()', function () { + it('errors if name not a string', async function () { const trace = firebase.perf().newTrace('invertase'); try { trace.putMetric('likes', 1337); @@ -210,7 +210,7 @@ android.describe('perf()', () => { } }); - it('removes a metric', async function() { + it('removes a metric', async function () { const trace = firebase.perf().newTrace('invertase'); trace.putMetric('likes', 1337); const value = trace.getMetric('likes'); @@ -221,21 +221,21 @@ android.describe('perf()', () => { }); }); - describe('getMetric()', function() { - it('should return 0 if metric does not exist', async function() { + describe('getMetric()', function () { + it('should return 0 if metric does not exist', async function () { const trace = firebase.perf().newTrace('invertase'); const value = trace.getMetric('likes'); should.equal(value, 0); }); - it('should return an metric number value', async function() { + it('should return an metric number value', async function () { const trace = firebase.perf().newTrace('invertase'); trace.putMetric('likes', 7331); const value = trace.getMetric('likes'); should.equal(value, 7331); }); - it('errors if metric name is not a string', async function() { + it('errors if metric name is not a string', async function () { try { const trace = firebase.perf().newTrace('invertase'); trace.getMetric(1337); @@ -247,15 +247,15 @@ android.describe('perf()', () => { }); }); - describe('putMetric()', function() { - it('sets a metric number value', async function() { + describe('putMetric()', function () { + it('sets a metric number value', async function () { const trace = firebase.perf().newTrace('invertase'); trace.putMetric('likes', 9001); const value = trace.getMetric('likes'); value.should.equal(9001); }); - it('overwrites existing metric if it exists', async function() { + it('overwrites existing metric if it exists', async function () { const trace = firebase.perf().newTrace('invertase'); trace.putMetric('likes', 1); trace.incrementMetric('likes', 9000); @@ -266,7 +266,7 @@ android.describe('perf()', () => { value2.should.equal(1); }); - it('errors if metric name is not a string', async function() { + it('errors if metric name is not a string', async function () { try { const trace = firebase.perf().newTrace('invertase'); trace.putMetric(1337, 7331); @@ -277,7 +277,7 @@ android.describe('perf()', () => { } }); - it('errors if metric value is not a number', async function() { + it('errors if metric value is not a number', async function () { try { const trace = firebase.perf().newTrace('invertase'); trace.putMetric('likes', '1337'); @@ -289,8 +289,8 @@ android.describe('perf()', () => { }); }); - describe('incrementMetric()', function() { - it('increments a metric number value', async function() { + describe('incrementMetric()', function () { + it('increments a metric number value', async function () { const trace = firebase.perf().newTrace('invertase'); trace.putMetric('likes', 9000); trace.incrementMetric('likes', 1); @@ -298,14 +298,14 @@ android.describe('perf()', () => { value.should.equal(9001); }); - it('increments a metric even if it does not already exist', async function() { + it('increments a metric even if it does not already exist', async function () { const trace = firebase.perf().newTrace('invertase'); trace.incrementMetric('likes', 9001); const value = trace.getMetric('likes'); value.should.equal(9001); }); - it('errors if metric name is not a string', async function() { + it('errors if metric name is not a string', async function () { try { const trace = firebase.perf().newTrace('invertase'); trace.incrementMetric(1337, 1); @@ -316,7 +316,7 @@ android.describe('perf()', () => { } }); - it('errors if incrementBy value is not a number', async function() { + it('errors if incrementBy value is not a number', async function () { try { const trace = firebase.perf().newTrace('invertase'); trace.incrementMetric('likes', '1'); @@ -328,7 +328,7 @@ android.describe('perf()', () => { }); }); - it('getMetrics()', async function() { + it('getMetrics()', async function () { const trace = firebase.perf().newTrace('invertase'); trace.putMetric('likes', 1337); trace.putMetric('stars', 6832); diff --git a/packages/perf/e2e/perf.e2e.js b/packages/perf/e2e/perf.e2e.js index 016bf88b06..d4c70b8855 100644 --- a/packages/perf/e2e/perf.e2e.js +++ b/packages/perf/e2e/perf.e2e.js @@ -16,16 +16,16 @@ */ android.describe('perf()', () => { - describe('setPerformanceCollectionEnabled()', function() { + describe('setPerformanceCollectionEnabled()', function () { // TODO sometimes android launches with isPerformanceCollectionEnabled = false - xit('true', async function() { + xit('true', async function () { should.equal(firebase.perf().isPerformanceCollectionEnabled, true); await firebase.perf().setPerformanceCollectionEnabled(true); should.equal(firebase.perf().isPerformanceCollectionEnabled, true); await Utils.sleep(2000); }); - it('false', async function() { + it('false', async function () { await device.launchApp(); await firebase.perf().setPerformanceCollectionEnabled(false); should.equal(firebase.perf().isPerformanceCollectionEnabled, false); @@ -36,8 +36,8 @@ android.describe('perf()', () => { }); }); - describe('startTrace()', function() { - it('resolves a started instance of Trace', async function() { + describe('startTrace()', function () { + it('resolves a started instance of Trace', async function () { const trace = await firebase.perf().startTrace('invertase'); trace.constructor.name.should.be.equal('Trace'); trace._identifier.should.equal('invertase'); diff --git a/packages/perf/lib/index.d.ts b/packages/perf/lib/index.d.ts index f3bb6027dd..c9d26e8869 100644 --- a/packages/perf/lib/index.d.ts +++ b/packages/perf/lib/index.d.ts @@ -459,6 +459,7 @@ export default defaultExport; * Attach namespace to `firebase.` and `FirebaseApp.`. */ declare module '@react-native-firebase/app' { + // eslint-disable-next-line @typescript-eslint/no-unused-vars namespace ReactNativeFirebase { import FirebaseModuleWithStatics = ReactNativeFirebase.FirebaseModuleWithStatics; interface Module { diff --git a/packages/remote-config/e2e/config.e2e.js b/packages/remote-config/e2e/config.e2e.js index e934c8a84d..730ce2fb18 100644 --- a/packages/remote-config/e2e/config.e2e.js +++ b/packages/remote-config/e2e/config.e2e.js @@ -15,15 +15,15 @@ * */ -describe('remoteConfig()', function() { - describe('namespace', function() { - it('accessible from firebase.app()', function() { +describe('remoteConfig()', function () { + describe('namespace', function () { + it('accessible from firebase.app()', function () { const app = firebase.app(); should.exist(app.remoteConfig); app.remoteConfig().app.should.equal(app); }); - it('supports multiple apps', async function() { + it('supports multiple apps', async function () { firebase.firestore().app.name.should.equal('[DEFAULT]'); firebase @@ -37,8 +37,8 @@ describe('remoteConfig()', function() { }); }); - describe('statics', function() { - it('LastFetchStatus', function() { + describe('statics', function () { + it('LastFetchStatus', function () { firebase.remoteConfig.LastFetchStatus.should.be.an.Object(); firebase.remoteConfig.LastFetchStatus.FAILURE.should.equal('failure'); firebase.remoteConfig.LastFetchStatus.SUCCESS.should.equal('success'); @@ -46,7 +46,7 @@ describe('remoteConfig()', function() { firebase.remoteConfig.LastFetchStatus.THROTTLED.should.equal('throttled'); }); - it('ValueSource', function() { + it('ValueSource', function () { firebase.remoteConfig.ValueSource.should.be.an.Object(); firebase.remoteConfig.ValueSource.REMOTE.should.equal('remote'); firebase.remoteConfig.ValueSource.STATIC.should.equal('static'); @@ -54,8 +54,8 @@ describe('remoteConfig()', function() { }); }); - describe('fetch()', function() { - it('with expiration provided', async function() { + describe('fetch()', function () { + it('with expiration provided', async function () { const date = Date.now() - 30000; await firebase.remoteConfig().ensureInitialized(); @@ -73,10 +73,10 @@ describe('remoteConfig()', function() { console.log(firebase.remoteConfig().fetchTimeMillis, date); should.equal(firebase.remoteConfig().fetchTimeMillis >= date, true); }); - it('without expiration provided', function() { + it('without expiration provided', function () { return firebase.remoteConfig().fetch(); }); - it('it throws if expiration is not a number', function() { + it('it throws if expiration is not a number', function () { try { firebase.remoteConfig().fetch('foo'); return Promise.reject(new Error('Did not throw')); @@ -87,37 +87,37 @@ describe('remoteConfig()', function() { }); }); - describe('fetchAndActivate()', function() { - it('returns true/false if activated', async function() { + describe('fetchAndActivate()', function () { + it('returns true/false if activated', async function () { const activated = await firebase.remoteConfig().fetchAndActivate(); activated.should.be.a.Boolean(); }); }); - describe('activate()', function() { - it('with expiration provided', async function() { + describe('activate()', function () { + it('with expiration provided', async function () { await firebase.remoteConfig().fetch(0); const activated = await firebase.remoteConfig().activate(); activated.should.be.a.Boolean(); }); - it('without expiration provided', async function() { + it('without expiration provided', async function () { await firebase.remoteConfig().fetch(); const activated = await firebase.remoteConfig().activate(); activated.should.be.a.Boolean(); }); }); - describe('config settings', function() { - it('should be immediately available', async function() { + describe('config settings', function () { + it('should be immediately available', async function () { firebase.remoteConfig().lastFetchStatus.should.be.a.String(); firebase.remoteConfig().lastFetchStatus.should.equal('success'); firebase.remoteConfig().fetchTimeMillis.should.be.a.Number(); }); }); - describe('setConfigSettings()', function() { - it('it throws if arg is not an object', async function() { + describe('setConfigSettings()', function () { + it('it throws if arg is not an object', async function () { try { firebase.remoteConfig().setConfigSettings('not an object'); @@ -128,13 +128,13 @@ describe('remoteConfig()', function() { } }); - it('minimumFetchIntervalMillis sets correctly', async function() { + it('minimumFetchIntervalMillis sets correctly', async function () { await firebase.remoteConfig().setConfigSettings({ minimumFetchIntervalMillis: 3000 }); firebase.remoteConfig().settings.minimumFetchIntervalMillis.should.be.equal(3000); }); - it('throws if minimumFetchIntervalMillis is not a number', async function() { + it('throws if minimumFetchIntervalMillis is not a number', async function () { try { firebase.remoteConfig().setConfigSettings({ minimumFetchIntervalMillis: 'potato' }); @@ -145,13 +145,13 @@ describe('remoteConfig()', function() { } }); - it('fetchTimeMillis sets correctly', async function() { + it('fetchTimeMillis sets correctly', async function () { await firebase.remoteConfig().setConfigSettings({ fetchTimeMillis: 3000 }); firebase.remoteConfig().settings.fetchTimeMillis.should.be.equal(3000); }); - it('throws if fetchTimeMillis is not a number', function() { + it('throws if fetchTimeMillis is not a number', function () { try { firebase.remoteConfig().setConfigSettings({ fetchTimeMillis: 'potato' }); @@ -163,8 +163,8 @@ describe('remoteConfig()', function() { }); }); - describe('ensureInitialized()', function() { - it('should ensure remote config has been initialized and values are accessible', async function() { + describe('ensureInitialized()', function () { + it('should ensure remote config has been initialized and values are accessible', async function () { const ensure = await firebase.remoteConfig().ensureInitialized(); const number = firebase.remoteConfig().getValue('number'); @@ -174,8 +174,8 @@ describe('remoteConfig()', function() { }); }); - describe('getAll() with remote', function() { - it('should return an object of all available values', function() { + describe('getAll() with remote', function () { + it('should return an object of all available values', function () { const config = firebase.remoteConfig().getAll(); config.number.asNumber().should.equal(1337); config.number.getSource().should.equal('remote'); @@ -187,8 +187,8 @@ describe('remoteConfig()', function() { }); }); - describe('setDefaults()', function() { - it('sets default values from key values object', async function() { + describe('setDefaults()', function () { + it('sets default values from key values object', async function () { await firebase.remoteConfig().setDefaults({ some_key: 'I do not exist', some_key_1: 1337, @@ -205,7 +205,7 @@ describe('remoteConfig()', function() { values.some_key_2.getSource().should.equal('default'); }); - it('it throws if defaults object not provided', function() { + it('it throws if defaults object not provided', function () { try { firebase.remoteConfig().setDefaults('not an object'); return Promise.reject(new Error('Did not throw')); @@ -216,9 +216,9 @@ describe('remoteConfig()', function() { }); }); - describe('getValue()', function() { - describe('getValue().asBoolean()', function() { - it("returns 'true' for the specified keys: '1', 'true', 't', 'yes', 'y', 'on'", async function() { + describe('getValue()', function () { + describe('getValue().asBoolean()', function () { + it("returns 'true' for the specified keys: '1', 'true', 't', 'yes', 'y', 'on'", async function () { //Boolean truthy values as defined by web sdk await firebase.remoteConfig().setDefaults({ test1: '1', @@ -229,31 +229,13 @@ describe('remoteConfig()', function() { test6: 'on', }); - const test1 = firebase - .remoteConfig() - .getValue('test1') - .asBoolean(); - - const test2 = firebase - .remoteConfig() - .getValue('test2') - .asBoolean(); - const test3 = firebase - .remoteConfig() - .getValue('test3') - .asBoolean(); - const test4 = firebase - .remoteConfig() - .getValue('test4') - .asBoolean(); - const test5 = firebase - .remoteConfig() - .getValue('test5') - .asBoolean(); - const test6 = firebase - .remoteConfig() - .getValue('test6') - .asBoolean(); + const test1 = firebase.remoteConfig().getValue('test1').asBoolean(); + + const test2 = firebase.remoteConfig().getValue('test2').asBoolean(); + const test3 = firebase.remoteConfig().getValue('test3').asBoolean(); + const test4 = firebase.remoteConfig().getValue('test4').asBoolean(); + const test5 = firebase.remoteConfig().getValue('test5').asBoolean(); + const test6 = firebase.remoteConfig().getValue('test6').asBoolean(); test1.should.equal(true); test2.should.equal(true); @@ -263,38 +245,29 @@ describe('remoteConfig()', function() { test6.should.equal(true); }); - it("returns 'false' for values that resolve to a falsy", async function() { + it("returns 'false' for values that resolve to a falsy", async function () { await firebase.remoteConfig().setDefaults({ test1: '2', test2: 'foo', }); - const test1 = firebase - .remoteConfig() - .getValue('test1') - .asBoolean(); + const test1 = firebase.remoteConfig().getValue('test1').asBoolean(); - const test2 = firebase - .remoteConfig() - .getValue('test2') - .asBoolean(); + const test2 = firebase.remoteConfig().getValue('test2').asBoolean(); test1.should.equal(false); test2.should.equal(false); }); - it("returns 'false' if the source is static", function() { - const unknownKey = firebase - .remoteConfig() - .getValue('unknownKey') - .asBoolean(); + it("returns 'false' if the source is static", function () { + const unknownKey = firebase.remoteConfig().getValue('unknownKey').asBoolean(); unknownKey.should.equal(false); }); }); - describe('getValue().asString()', function() { - it('returns the value as a string', function() { + describe('getValue().asString()', function () { + it('returns the value as a string', function () { const config = firebase.remoteConfig().getAll(); config.number.asString().should.equal('1337'); @@ -304,8 +277,8 @@ describe('remoteConfig()', function() { }); }); - describe('getValue().asNumber()', function() { - it('returns the value as a number if it can be evaluated as a number', function() { + describe('getValue().asNumber()', function () { + it('returns the value as a number if it can be evaluated as a number', function () { const config = firebase.remoteConfig().getAll(); config.number.asNumber().should.equal(1337); @@ -313,25 +286,22 @@ describe('remoteConfig()', function() { config.prefix_1.asNumber().should.equal(1); }); - it('returns the value "0" if it cannot be evaluated as a number', function() { + it('returns the value "0" if it cannot be evaluated as a number', function () { const config = firebase.remoteConfig().getAll(); config.bool.asNumber().should.equal(0); config.string.asNumber().should.equal(0); }); - it("returns '0' if the source is static", function() { - const unknownKey = firebase - .remoteConfig() - .getValue('unknownKey') - .asNumber(); + it("returns '0' if the source is static", function () { + const unknownKey = firebase.remoteConfig().getValue('unknownKey').asNumber(); unknownKey.should.equal(0); }); }); - describe('getValue().getSource()', function() { - it('returns the correct source as default or remote', async function() { + describe('getValue().getSource()', function () { + it('returns the correct source as default or remote', async function () { await firebase.remoteConfig().setDefaults({ test1: '2', test2: 'foo', @@ -348,13 +318,13 @@ describe('remoteConfig()', function() { }); }); - it("returns an empty string for a static value for keys that doesn't exist", function() { + it("returns an empty string for a static value for keys that doesn't exist", function () { const configValue = firebase.remoteConfig().getValue('fourOhFour'); configValue.getSource().should.equal('static'); should.equal(configValue.asString(), ''); }); - it('errors if no key provided', async function() { + it('errors if no key provided', async function () { try { firebase.remoteConfig().getValue(); return Promise.reject(new Error('Did not throw')); @@ -364,7 +334,7 @@ describe('remoteConfig()', function() { } }); - it('errors if key not a string', async function() { + it('errors if key not a string', async function () { try { firebase.remoteConfig().getValue(1234); return Promise.reject(new Error('Did not throw')); @@ -375,8 +345,8 @@ describe('remoteConfig()', function() { }); }); - describe('getAll()', function() { - it('gets all values', async function() { + describe('getAll()', function () { + it('gets all values', async function () { const config = firebase.remoteConfig().getAll(); config.should.be.a.Object(); @@ -392,15 +362,15 @@ describe('remoteConfig()', function() { }); }); - describe('setDefaultsFromResource()', function() { - it('sets defaults from remote_config_resource_test file', async function() { + describe('setDefaultsFromResource()', function () { + it('sets defaults from remote_config_resource_test file', async function () { await firebase.remoteConfig().setDefaultsFromResource('remote_config_resource_test'); const config = firebase.remoteConfig().getAll(); config.company.getSource().should.equal('default'); config.company.asString().should.equal('invertase'); }); - it('rejects if resource not found', async function() { + it('rejects if resource not found', async function () { const [error] = await A2A(firebase.remoteConfig().setDefaultsFromResource('i_do_not_exist')); if (!error) { throw new Error('Did not reject'); @@ -410,7 +380,7 @@ describe('remoteConfig()', function() { error.message.should.containEql('was not found'); }); - it('throws if resourceName is not a string', function() { + it('throws if resourceName is not a string', function () { try { firebase.remoteConfig().setDefaultsFromResource(1337); return Promise.reject(new Error('Did not throw')); @@ -421,7 +391,7 @@ describe('remoteConfig()', function() { }); }); - describe('reset()', function() { + describe('reset()', function () { android.it('resets all activated, fetched and default config', async () => { await firebase.remoteConfig().setDefaults({ some_key: 'I do not exist', @@ -440,7 +410,7 @@ describe('remoteConfig()', function() { should(configRetrieveAgain).not.have.properties(remoteProps); }); - it('returns a "null" value as reset() API is not supported on iOS', async function() { + it('returns a "null" value as reset() API is not supported on iOS', async function () { if (device.getPlatform() === 'ios') { const reset = await firebase.remoteConfig().reset(); diff --git a/packages/remote-config/lib/index.d.ts b/packages/remote-config/lib/index.d.ts index 9d48256a4e..697ca45fa8 100644 --- a/packages/remote-config/lib/index.d.ts +++ b/packages/remote-config/lib/index.d.ts @@ -535,6 +535,7 @@ export default defaultExport; * Attach namespace to `firebase.` and `FirebaseApp.`. */ declare module '@react-native-firebase/app' { + // eslint-disable-next-line @typescript-eslint/no-unused-vars namespace ReactNativeFirebase { import FirebaseModuleWithStatics = ReactNativeFirebase.FirebaseModuleWithStatics; interface Module { diff --git a/packages/storage/e2e/StorageReference.e2e.js b/packages/storage/e2e/StorageReference.e2e.js index 2d356ff79d..a409f2bde8 100644 --- a/packages/storage/e2e/StorageReference.e2e.js +++ b/packages/storage/e2e/StorageReference.e2e.js @@ -15,9 +15,9 @@ * */ -describe('storage() -> StorageReference', function() { - describe('toString()', function() { - it('returns the correct bucket path to the file', function() { +describe('storage() -> StorageReference', function () { + describe('toString()', function () { + it('returns the correct bucket path to the file', function () { const app = firebase.app(); firebase .storage() @@ -27,31 +27,22 @@ describe('storage() -> StorageReference', function() { }); }); - describe('properties', function() { - describe('fullPath', function() { - it('returns the full path as a string', function() { - firebase - .storage() - .ref('/foo/uploadNope.jpeg') - .fullPath.should.equal('foo/uploadNope.jpeg'); - firebase - .storage() - .ref('foo/uploadNope.jpeg') - .fullPath.should.equal('foo/uploadNope.jpeg'); + describe('properties', function () { + describe('fullPath', function () { + it('returns the full path as a string', function () { + firebase.storage().ref('/foo/uploadNope.jpeg').fullPath.should.equal('foo/uploadNope.jpeg'); + firebase.storage().ref('foo/uploadNope.jpeg').fullPath.should.equal('foo/uploadNope.jpeg'); }); }); - describe('storage', function() { - it('returns the instance of storage', function() { - firebase - .storage() - .ref('/foo/uploadNope.jpeg') - .storage.ref.should.be.a.Function(); + describe('storage', function () { + it('returns the instance of storage', function () { + firebase.storage().ref('/foo/uploadNope.jpeg').storage.ref.should.be.a.Function(); }); }); - describe('bucket', function() { - it('returns the storage bucket as a string', function() { + describe('bucket', function () { + it('returns the storage bucket as a string', function () { const app = firebase.app(); firebase .storage() @@ -60,47 +51,41 @@ describe('storage() -> StorageReference', function() { }); }); - describe('name', function() { - it('returns the file name as a string', function() { + describe('name', function () { + it('returns the file name as a string', function () { const ref = firebase.storage().ref('/foo/uploadNope.jpeg'); ref.name.should.equal('uploadNope.jpeg'); }); }); - describe('parent', function() { - it('returns the parent directory as a reference', function() { - firebase - .storage() - .ref('/foo/uploadNope.jpeg') - .parent.fullPath.should.equal('foo'); + describe('parent', function () { + it('returns the parent directory as a reference', function () { + firebase.storage().ref('/foo/uploadNope.jpeg').parent.fullPath.should.equal('foo'); }); - it('returns null if already at root', function() { + it('returns null if already at root', function () { const ref = firebase.storage().ref('/'); should.equal(ref.parent, null); }); }); - describe('root', function() { - it('returns a reference to the root of the bucket', function() { - firebase - .storage() - .ref('/foo/uploadNope.jpeg') - .root.fullPath.should.equal('/'); + describe('root', function () { + it('returns a reference to the root of the bucket', function () { + firebase.storage().ref('/foo/uploadNope.jpeg').root.fullPath.should.equal('/'); }); }); }); - describe('child()', function() { - it('returns a reference to a child path', function() { + describe('child()', function () { + it('returns a reference to a child path', function () { const parentRef = firebase.storage().ref('/foo'); const childRef = parentRef.child('someFile.json'); childRef.fullPath.should.equal('foo/someFile.json'); }); }); - describe('delete()', function() { - before(async function() { + describe('delete()', function () { + before(async function () { await firebase .storage() .ref('/ok.jpeg') @@ -111,7 +96,7 @@ describe('storage() -> StorageReference', function() { .putFile(`${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/deleteMe.jpeg`); }); - it('should delete a file', async function() { + it('should delete a file', async function () { const storageReference = firebase.storage().ref('/deleteMe.jpeg'); await storageReference.delete(); @@ -127,7 +112,7 @@ describe('storage() -> StorageReference', function() { } }); - it('throws error if file does not exist', async function() { + it('throws error if file does not exist', async function () { const storageReference = firebase.storage().ref('/iDoNotExist.jpeg'); try { @@ -142,7 +127,7 @@ describe('storage() -> StorageReference', function() { } }); - it('throws error if no write permission', async function() { + it('throws error if no write permission', async function () { const storageReference = firebase.storage().ref('/uploadNope.jpeg'); try { @@ -158,8 +143,8 @@ describe('storage() -> StorageReference', function() { }); }); - describe('getDownloadURL', function() { - it('should return a download url for a file', async function() { + describe('getDownloadURL', function () { + it('should return a download url for a file', async function () { const storageReference = firebase.storage().ref('/ok.jpeg'); const downloadUrl = await storageReference.getDownloadURL(); downloadUrl.should.be.a.String(); @@ -167,7 +152,7 @@ describe('storage() -> StorageReference', function() { downloadUrl.should.containEql(firebase.app().options.projectId); }); - it('throws error if file does not exist', async function() { + it('throws error if file does not exist', async function () { const storageReference = firebase.storage().ref('/iDoNotExist.jpeg'); try { @@ -182,7 +167,7 @@ describe('storage() -> StorageReference', function() { } }); - it('throws error if no write permission', async function() { + it('throws error if no write permission', async function () { const storageReference = firebase.storage().ref('/writeOnly.jpeg'); try { @@ -198,8 +183,8 @@ describe('storage() -> StorageReference', function() { }); }); - describe('getMetadata', function() { - it('should return a metadata for a file', async function() { + describe('getMetadata', function () { + it('should return a metadata for a file', async function () { const storageReference = firebase.storage().ref('/ok.jpeg'); const metadata = await storageReference.getMetadata(); metadata.generation.should.be.a.String(); @@ -221,8 +206,8 @@ describe('storage() -> StorageReference', function() { }); }); - describe('list', function() { - it('should return list results', async function() { + describe('list', function () { + it('should return list results', async function () { const storageReference = firebase.storage().ref('/list'); const result = await storageReference.list(); @@ -238,7 +223,7 @@ describe('storage() -> StorageReference', function() { result.prefixes[0].constructor.name.should.eql('StorageReference'); }); - it('throws if options is not an object', function() { + it('throws if options is not an object', function () { try { const storageReference = firebase.storage().ref('/'); storageReference.list(123); @@ -249,8 +234,8 @@ describe('storage() -> StorageReference', function() { } }); - describe('maxResults', function() { - it('should limit with maxResults are passed', async function() { + describe('maxResults', function () { + it('should limit with maxResults are passed', async function () { const storageReference = firebase.storage().ref('/list'); const result = await storageReference.list({ maxResults: 1, @@ -266,7 +251,7 @@ describe('storage() -> StorageReference', function() { // todo length? }); - it('throws if maxResults is not a number', function() { + it('throws if maxResults is not a number', function () { try { const storageReference = firebase.storage().ref('/list'); storageReference.list({ @@ -279,7 +264,7 @@ describe('storage() -> StorageReference', function() { } }); - it('throws if maxResults is not a valid number', function() { + it('throws if maxResults is not a valid number', function () { try { const storageReference = firebase.storage().ref('/list'); storageReference.list({ @@ -295,8 +280,8 @@ describe('storage() -> StorageReference', function() { }); }); - describe('pageToken', function() { - it('throws if pageToken is not a string', function() { + describe('pageToken', function () { + it('throws if pageToken is not a string', function () { try { const storageReference = firebase.storage().ref('/list'); storageReference.list({ @@ -309,7 +294,7 @@ describe('storage() -> StorageReference', function() { } }); - it('should return and use a page token', async function() { + it('should return and use a page token', async function () { const storageReference = firebase.storage().ref('/list'); const result1 = await storageReference.list({ maxResults: 1, @@ -331,8 +316,8 @@ describe('storage() -> StorageReference', function() { }); }); - describe('listAll', function() { - it('should return all results', async function() { + describe('listAll', function () { + it('should return all results', async function () { const storageReference = firebase.storage().ref('/list'); const result = await storageReference.listAll(); @@ -347,7 +332,7 @@ describe('storage() -> StorageReference', function() { result.prefixes[0].constructor.name.should.eql('StorageReference'); }); - it('should not crash if the user is not allowed to list the directory', async function() { + it('should not crash if the user is not allowed to list the directory', async function () { const storageReference = firebase.storage().ref('/forbidden'); try { await storageReference.listAll(); @@ -362,8 +347,8 @@ describe('storage() -> StorageReference', function() { }); }); - describe('updateMetadata', function() { - it('should return the updated metadata for a file', async function() { + describe('updateMetadata', function () { + it('should return the updated metadata for a file', async function () { const storageReference = firebase.storage().ref('/writeOnly.jpeg'); const metadata = await storageReference.updateMetadata({ contentType: 'image/jpeg', @@ -391,7 +376,7 @@ describe('storage() -> StorageReference', function() { metadata.customMetadata.should.be.an.Object(); }); - it('should remove customMetadata properties by setting the value to null', async function() { + it('should remove customMetadata properties by setting the value to null', async function () { const storageReference = firebase.storage().ref('/writeOnly.jpeg'); const metadata = await storageReference.updateMetadata({ contentType: 'image/jpeg', @@ -413,8 +398,8 @@ describe('storage() -> StorageReference', function() { }); }); - describe('putFile', function() { - it('errors if file path is not a string', async function() { + describe('putFile', function () { + it('errors if file path is not a string', async function () { const storageReference = firebase.storage().ref('/ok.jpeg'); try { storageReference.putFile(1337); @@ -425,7 +410,7 @@ describe('storage() -> StorageReference', function() { } }); - it('errors if metadata is not an object', async function() { + it('errors if metadata is not an object', async function () { const storageReference = firebase.storage().ref('/ok.jpeg'); try { storageReference.putFile('foo', 123); @@ -436,7 +421,7 @@ describe('storage() -> StorageReference', function() { } }); - it('errors if metadata contains an unsupported property', async function() { + it('errors if metadata contains an unsupported property', async function () { const storageReference = firebase.storage().ref('/ok.jpeg'); try { storageReference.putFile('foo', { foo: true }); @@ -447,7 +432,7 @@ describe('storage() -> StorageReference', function() { } }); - it('errors if metadata property value is not a string or null value', async function() { + it('errors if metadata property value is not a string or null value', async function () { const storageReference = firebase.storage().ref('/ok.jpeg'); try { storageReference.putFile('foo', { contentType: true }); @@ -458,7 +443,7 @@ describe('storage() -> StorageReference', function() { } }); - it('errors if metadata.customMetadata is not an object', async function() { + it('errors if metadata.customMetadata is not an object', async function () { const storageReference = firebase.storage().ref('/ok.jpeg'); try { storageReference.putFile('foo', { customMetadata: true }); @@ -472,8 +457,8 @@ describe('storage() -> StorageReference', function() { }); }); - describe('putString', function() { - it('errors if metadata is not an object', async function() { + describe('putString', function () { + it('errors if metadata is not an object', async function () { const storageReference = firebase.storage().ref('/ok.jpeg'); try { storageReference.putString('foo', 'raw', 123); @@ -484,7 +469,7 @@ describe('storage() -> StorageReference', function() { } }); - it('errors if metadata contains an unsupported property', async function() { + it('errors if metadata contains an unsupported property', async function () { const storageReference = firebase.storage().ref('/ok.jpeg'); try { storageReference.putString('foo', 'raw', { foo: true }); @@ -495,7 +480,7 @@ describe('storage() -> StorageReference', function() { } }); - it('errors if metadata property value is not a string or null value', async function() { + it('errors if metadata property value is not a string or null value', async function () { const storageReference = firebase.storage().ref('/ok.jpeg'); try { storageReference.putString('foo', 'raw', { contentType: true }); @@ -506,7 +491,7 @@ describe('storage() -> StorageReference', function() { } }); - it('errors if metadata.customMetadata is not an object', async function() { + it('errors if metadata.customMetadata is not an object', async function () { const storageReference = firebase.storage().ref('/ok.jpeg'); try { storageReference.putString('foo', 'raw', { customMetadata: true }); @@ -520,8 +505,8 @@ describe('storage() -> StorageReference', function() { }); }); - describe('put', function() { - it('errors if metadata is not an object', async function() { + describe('put', function () { + it('errors if metadata is not an object', async function () { const storageReference = firebase.storage().ref('/ok.jpeg'); try { storageReference.put(new jet.context.window.ArrayBuffer(), 123); @@ -532,7 +517,7 @@ describe('storage() -> StorageReference', function() { } }); - it('errors if metadata contains an unsupported property', async function() { + it('errors if metadata contains an unsupported property', async function () { const storageReference = firebase.storage().ref('/ok.jpeg'); try { storageReference.put(new jet.context.window.ArrayBuffer(), { foo: true }); @@ -543,7 +528,7 @@ describe('storage() -> StorageReference', function() { } }); - it('errors if metadata property value is not a string or null value', async function() { + it('errors if metadata property value is not a string or null value', async function () { const storageReference = firebase.storage().ref('/ok.jpeg'); try { storageReference.put(new jet.context.window.ArrayBuffer(), { contentType: true }); @@ -554,7 +539,7 @@ describe('storage() -> StorageReference', function() { } }); - it('errors if metadata.customMetadata is not an object', async function() { + it('errors if metadata.customMetadata is not an object', async function () { const storageReference = firebase.storage().ref('/ok.jpeg'); try { storageReference.put(new jet.context.window.ArrayBuffer(), { customMetadata: true }); diff --git a/packages/storage/e2e/StorageStatics.e2e.js b/packages/storage/e2e/StorageStatics.e2e.js index d7b92dab36..df0b35e9a0 100644 --- a/packages/storage/e2e/StorageStatics.e2e.js +++ b/packages/storage/e2e/StorageStatics.e2e.js @@ -15,8 +15,8 @@ * */ -describe('storage()', function() { - describe('statics', function() { +describe('storage()', function () { + describe('statics', function () { // TODO test statics correctly exported }); }); diff --git a/packages/storage/e2e/StorageTask.e2e.js b/packages/storage/e2e/StorageTask.e2e.js index 1065750987..825e4fc7c1 100644 --- a/packages/storage/e2e/StorageTask.e2e.js +++ b/packages/storage/e2e/StorageTask.e2e.js @@ -24,9 +24,9 @@ function snapshotProperties(snapshot) { snapshot.should.have.property('bytesTransferred'); } -describe('storage() -> StorageTask', function() { - describe('writeToFile()', function() { - it('errors if permission denied', async function() { +describe('storage() -> StorageTask', function () { + describe('writeToFile()', function () { + it('errors if permission denied', async function () { try { await firebase .storage() @@ -40,7 +40,7 @@ describe('storage() -> StorageTask', function() { } }); - it('downloads a file', async function() { + it('downloads a file', async function () { const meta = await firebase .storage() .ref('/ok.jpeg') @@ -51,8 +51,8 @@ describe('storage() -> StorageTask', function() { }); }); - describe('putString()', function() { - it('uploads a raw string', async function() { + describe('putString()', function () { + it('uploads a raw string', async function () { const jsonDerulo = JSON.stringify({ foo: 'bar' }); const uploadTaskSnapshot = await firebase @@ -67,7 +67,7 @@ describe('storage() -> StorageTask', function() { uploadTaskSnapshot.metadata.should.be.an.Object(); }); - it('uploads a data_url formatted string', async function() { + it('uploads a data_url formatted string', async function () { const dataUrl = 'data:application/json;base64,eyJmb28iOiJiYXNlNjQifQ=='; const uploadTaskSnapshot = await firebase .storage() @@ -79,7 +79,7 @@ describe('storage() -> StorageTask', function() { uploadTaskSnapshot.metadata.should.be.an.Object(); }); - it('uploads a url encoded data_url formatted string', async function() { + it('uploads a url encoded data_url formatted string', async function () { const dataUrl = 'data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E'; const uploadTaskSnapshot = await firebase .storage() @@ -91,7 +91,7 @@ describe('storage() -> StorageTask', function() { uploadTaskSnapshot.metadata.should.be.an.Object(); }); - it('when using data_url it still sets the content type if metadata is provided', async function() { + it('when using data_url it still sets the content type if metadata is provided', async function () { const dataUrl = 'data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E'; const uploadTaskSnapshot = await firebase @@ -109,7 +109,7 @@ describe('storage() -> StorageTask', function() { uploadTaskSnapshot.metadata.should.be.an.Object(); }); - it('uploads a base64 string', async function() { + it('uploads a base64 string', async function () { const base64String = 'eyJmb28iOiJiYXNlNjQifQ=='; const uploadTaskSnapshot = await firebase @@ -124,7 +124,7 @@ describe('storage() -> StorageTask', function() { uploadTaskSnapshot.metadata.should.be.an.Object(); }); - it('uploads a base64url string', async function() { + it('uploads a base64url string', async function () { const base64UrlString = 'eyJmb28iOiJiYXNlNjQifQ'; const uploadTaskSnapshot = await firebase @@ -139,7 +139,7 @@ describe('storage() -> StorageTask', function() { uploadTaskSnapshot.metadata.should.be.an.Object(); }); - it('throws an error on invalid data_url', async function() { + it('throws an error on invalid data_url', async function () { const dataUrl = ''; try { await firebase @@ -153,12 +153,9 @@ describe('storage() -> StorageTask', function() { } }); - it('throws if string arg is not a valid string', async function() { + it('throws if string arg is not a valid string', async function () { try { - await firebase - .storage() - .ref('/a.b') - .putString(1, 'base64'); + await firebase.storage().ref('/a.b').putString(1, 'base64'); return Promise.reject(new Error('Did not throw!')); } catch (error) { error.message.should.containEql("'string' expects a string value"); @@ -166,12 +163,9 @@ describe('storage() -> StorageTask', function() { } }); - it('throws an error on invalid string format', async function() { + it('throws an error on invalid string format', async function () { try { - await firebase - .storage() - .ref('/a.b') - .putString('fooby', 'abc'); + await firebase.storage().ref('/a.b').putString('fooby', 'abc'); return Promise.reject(new Error('Did not throw!')); } catch (error) { error.message.should.containEql("'format' provided is invalid, must be one of"); @@ -179,12 +173,9 @@ describe('storage() -> StorageTask', function() { } }); - it('throws an error if metadata is not an object', async function() { + it('throws an error if metadata is not an object', async function () { try { - await firebase - .storage() - .ref('/a.b') - .putString('fooby', 'raw', 1234); + await firebase.storage().ref('/a.b').putString('fooby', 'raw', 1234); return Promise.reject(new Error('Did not throw!')); } catch (error) { error.message.should.containEql('must be an object value if provided'); @@ -193,25 +184,22 @@ describe('storage() -> StorageTask', function() { }); }); - describe('put()', function() { - it('uploads a Blob', async function() { + describe('put()', function () { + it('uploads a Blob', async function () { const jsonDerulo = JSON.stringify({ foo: 'bar' }); const bob = new jet.context.Blob([jsonDerulo], { type: 'application/json', }); - const uploadTaskSnapshot = await firebase - .storage() - .ref('/putStringBlob.json') - .put(bob); + const uploadTaskSnapshot = await firebase.storage().ref('/putStringBlob.json').put(bob); uploadTaskSnapshot.state.should.eql(firebase.storage.TaskState.SUCCESS); uploadTaskSnapshot.bytesTransferred.should.eql(uploadTaskSnapshot.totalBytes); uploadTaskSnapshot.metadata.should.be.an.Object(); }); - it('uploads an ArrayBuffer', async function() { + it('uploads an ArrayBuffer', async function () { const jsonDerulo = JSON.stringify({ foo: 'bar' }); const arrayBuffer = new jet.context.window.ArrayBuffer(jsonDerulo.length); @@ -233,7 +221,7 @@ describe('storage() -> StorageTask', function() { uploadTaskSnapshot.metadata.should.be.an.Object(); }); - it('uploads an Uint8Array', async function() { + it('uploads an Uint8Array', async function () { const jsonDerulo = JSON.stringify({ foo: 'bar' }); const arrayBuffer = new jet.context.window.ArrayBuffer(jsonDerulo.length); @@ -255,17 +243,14 @@ describe('storage() -> StorageTask', function() { uploadTaskSnapshot.metadata.should.be.an.Object(); }); - it('should have access to the snapshot values outside of the Task thennable', async function() { + it('should have access to the snapshot values outside of the Task thennable', async function () { const jsonDerulo = JSON.stringify({ foo: 'bar' }); const bob = new jet.context.Blob([jsonDerulo], { type: 'application/json', }); - const uploadTaskSnapshot = firebase - .storage() - .ref('/putStringBlob.json') - .put(bob); + const uploadTaskSnapshot = firebase.storage().ref('/putStringBlob.json').put(bob); await uploadTaskSnapshot; @@ -275,8 +260,8 @@ describe('storage() -> StorageTask', function() { }); }); - describe('putFile()', function() { - before(async function() { + describe('putFile()', function () { + before(async function () { await firebase .storage() .ref('/ok.jpeg') @@ -291,7 +276,7 @@ describe('storage() -> StorageTask', function() { .writeToFile(`${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/hei.heic`); }); - it('errors if permission denied', async function() { + it('errors if permission denied', async function () { try { await firebase .storage() @@ -305,7 +290,7 @@ describe('storage() -> StorageTask', function() { } }); - it('supports thenable .catch()', async function() { + it('supports thenable .catch()', async function () { const out = await firebase .storage() .ref('/uploadNope.jpeg') @@ -318,7 +303,7 @@ describe('storage() -> StorageTask', function() { should.equal(out, 1); }); - it('uploads a file', async function() { + it('uploads a file', async function () { let uploadTaskSnapshot = await firebase .storage() .ref('/uploadOk.jpeg') @@ -349,7 +334,7 @@ describe('storage() -> StorageTask', function() { } }); - it('uploads a file without read permission', async function() { + it('uploads a file without read permission', async function () { const uploadTaskSnapshot = await firebase .storage() .ref('/writeOnly.jpeg') @@ -360,7 +345,7 @@ describe('storage() -> StorageTask', function() { uploadTaskSnapshot.metadata.should.be.an.Object(); }); - it('should have access to the snapshot values outside of the Task thennable', async function() { + it('should have access to the snapshot values outside of the Task thennable', async function () { const uploadTaskSnapshot = firebase .storage() .ref('/putStringBlob.json') @@ -373,7 +358,7 @@ describe('storage() -> StorageTask', function() { snapshotProperties(snapshot); }); - it('should have access to the snapshot values outside of the event subscriber', async function() { + it('should have access to the snapshot values outside of the event subscriber', async function () { const uploadTaskSnapshot = firebase .storage() .ref('/putStringBlob.json') @@ -393,15 +378,15 @@ describe('storage() -> StorageTask', function() { }); }); - describe('on()', function() { - before(async function() { + describe('on()', function () { + before(async function () { await firebase .storage() .ref('/ok.jpeg') .writeToFile(`${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/ok.jpeg`); }); - it('throws an Error if event is invalid', async function() { + it('throws an Error if event is invalid', async function () { const storageReference = firebase.storage().ref('/ok.jpeg'); try { const task = storageReference.putFile('abc'); @@ -415,7 +400,7 @@ describe('storage() -> StorageTask', function() { } }); - it('throws an Error if nextOrObserver is invalid', async function() { + it('throws an Error if nextOrObserver is invalid', async function () { const storageReference = firebase.storage().ref('/ok.jpeg'); try { const task = storageReference.putFile('abc'); @@ -427,7 +412,7 @@ describe('storage() -> StorageTask', function() { } }); - it('observer calls error callback', async function() { + it('observer calls error callback', async function () { const ref = firebase.storage().ref('/uploadOk.jpeg'); const { resolve, promise } = Promise.defer(); const path = `${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/notFoundFooFile.bar`; @@ -449,7 +434,7 @@ describe('storage() -> StorageTask', function() { await promise; }); - it('observer: calls next callback', async function() { + it('observer: calls next callback', async function () { const ref = firebase.storage().ref('/ok.jpeg'); const { resolve, promise } = Promise.defer(); const path = `${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/onDownload.jpeg`; @@ -467,7 +452,7 @@ describe('storage() -> StorageTask', function() { await promise; }); - it('observer: calls completion callback', async function() { + it('observer: calls completion callback', async function () { const ref = firebase.storage().ref('/ok.jpeg'); const { resolve, promise } = Promise.defer(); const path = `${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/onDownload.jpeg`; @@ -484,7 +469,7 @@ describe('storage() -> StorageTask', function() { await promise; }); - it('calls error callback', async function() { + it('calls error callback', async function () { const ref = firebase.storage().ref('/uploadOk.jpeg'); const { resolve, promise } = Promise.defer(); const path = `${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/notFoundFooFile.bar`; @@ -509,7 +494,7 @@ describe('storage() -> StorageTask', function() { await promise; }); - it('calls next callback', async function() { + it('calls next callback', async function () { const ref = firebase.storage().ref('/ok.jpeg'); const { resolve, promise } = Promise.defer(); const path = `${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/onDownload.jpeg`; @@ -525,7 +510,7 @@ describe('storage() -> StorageTask', function() { await promise; }); - it('calls completion callback', async function() { + it('calls completion callback', async function () { const ref = firebase.storage().ref('/ok.jpeg'); const { resolve, promise } = Promise.defer(); const path = `${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/onDownload.jpeg`; @@ -540,7 +525,7 @@ describe('storage() -> StorageTask', function() { await promise; }); - it('returns a subscribe fn', async function() { + it('returns a subscribe fn', async function () { const ref = firebase.storage().ref('/ok.jpeg'); const { resolve, promise } = Promise.defer(); const path = `${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/onDownload.jpeg`; @@ -558,7 +543,7 @@ describe('storage() -> StorageTask', function() { await promise; }); - it('returns a subscribe fn supporting observer usage syntax', async function() { + it('returns a subscribe fn supporting observer usage syntax', async function () { const ref = firebase.storage().ref('/ok.jpeg'); const { resolve, promise } = Promise.defer(); const path = `${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/onDownload.jpeg`; @@ -578,7 +563,7 @@ describe('storage() -> StorageTask', function() { await promise; }); - it('listens to download state', async function() { + it('listens to download state', async function () { const ref = firebase.storage().ref('/cat.gif'); const { resolve, reject, promise } = Promise.defer(); const path = `${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/onDownload.gif`; @@ -599,7 +584,7 @@ describe('storage() -> StorageTask', function() { await promise; }); - it('listens to upload state', async function() { + it('listens to upload state', async function () { const { resolve, reject, promise } = Promise.defer(); const path = `${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/ok.jpeg`; const ref = firebase.storage().ref('/uploadOk.jpeg'); @@ -621,7 +606,7 @@ describe('storage() -> StorageTask', function() { }); }); - describe('pause() resume()', function() { + describe('pause() resume()', function () { it('successfully pauses and resumes an upload', async function testRunner() { this.timeout(100 * 1000); @@ -687,7 +672,7 @@ describe('storage() -> StorageTask', function() { await promise; }); - it('successfully pauses and resumes a download', async function() { + it('successfully pauses and resumes a download', async function () { const ref = firebase .storage() .ref(device.getPlatform() === 'ios' ? '/1mbTestFile.gif' : '/cat.gif'); @@ -747,8 +732,8 @@ describe('storage() -> StorageTask', function() { }); }); - describe('cancel()', function() { - it('successfully cancels an upload', async function() { + describe('cancel()', function () { + it('successfully cancels an upload', async function () { await firebase .storage() .ref('/1mbTestFile.gif') @@ -801,7 +786,7 @@ describe('storage() -> StorageTask', function() { }); }); - it('successfully cancels a download', async function() { + it('successfully cancels a download', async function () { await Utils.sleep(10000); const ref = firebase.storage().ref('/1mbTestFile.gif'); const { resolve, reject, promise } = Promise.defer(); diff --git a/packages/storage/e2e/storage.e2e.js b/packages/storage/e2e/storage.e2e.js index 7960fc00f4..2cf12022bc 100644 --- a/packages/storage/e2e/storage.e2e.js +++ b/packages/storage/e2e/storage.e2e.js @@ -15,28 +15,25 @@ * */ -describe('storage()', function() { - describe('namespace', function() { - it('accessible from firebase.app()', function() { +describe('storage()', function () { + describe('namespace', function () { + it('accessible from firebase.app()', function () { const app = firebase.app(); should.exist(app.storage); app.storage().app.should.equal(app); }); - it('supports multiple apps', async function() { + it('supports multiple apps', async function () { firebase.storage().app.name.should.equal('[DEFAULT]'); firebase .storage(firebase.app('secondaryFromNative')) .app.name.should.equal('secondaryFromNative'); - firebase - .app('secondaryFromNative') - .storage() - .app.name.should.equal('secondaryFromNative'); + firebase.app('secondaryFromNative').storage().app.name.should.equal('secondaryFromNative'); }); - it('supports specifying a bucket', async function() { + it('supports specifying a bucket', async function () { const bucket = 'gs://react-native-firebase-testing'; const defaultInstance = firebase.storage(); defaultInstance.app.name.should.equal('[DEFAULT]'); @@ -49,7 +46,7 @@ describe('storage()', function() { instanceForBucket._customUrlOrRegion.should.equal(bucket); }); - it('throws an error if an invalid bucket url is provided', async function() { + it('throws an error if an invalid bucket url is provided', async function () { const bucket = 'invalid://react-native-firebase-testing'; try { firebase.app().storage(bucket); @@ -60,7 +57,7 @@ describe('storage()', function() { } }); - it('uploads to a custom bucket when specified', async function() { + it('uploads to a custom bucket when specified', async function () { const jsonDerulo = JSON.stringify({ foo: 'bar' }); const bucket = 'gs://react-native-firebase-testing'; @@ -78,23 +75,23 @@ describe('storage()', function() { }); }); - describe('ref', function() { - it('uses default path if none provided', async function() { + describe('ref', function () { + it('uses default path if none provided', async function () { const ref = firebase.storage().ref(); ref.fullPath.should.equal('/'); }); - it('accepts a custom path', async function() { + it('accepts a custom path', async function () { const ref = firebase.storage().ref('foo/bar/baz.png'); ref.fullPath.should.equal('foo/bar/baz.png'); }); - it('strips leading / from custom path', async function() { + it('strips leading / from custom path', async function () { const ref = firebase.storage().ref('/foo/bar/baz.png'); ref.fullPath.should.equal('foo/bar/baz.png'); }); - it('throws an error if custom path not a string', async function() { + it('throws an error if custom path not a string', async function () { try { firebase.storage().ref({ derp: true }); return Promise.reject(new Error('Did not throw an Error.')); @@ -105,14 +102,14 @@ describe('storage()', function() { }); }); - describe('refFromURL', function() { - it('accepts a gs url', async function() { + describe('refFromURL', function () { + it('accepts a gs url', async function () { const url = 'gs://foo/bar/baz.png'; const ref = firebase.storage().refFromURL(url); ref.toString().should.equal(url); }); - it('accepts a https url', async function() { + it('accepts a https url', async function () { const url = 'https://firebasestorage.googleapis.com/v0/b/react-native-firebase-testing.appspot.com/o/1mbTestFile.gif?alt=media'; const ref = firebase.storage().refFromURL(url); @@ -121,7 +118,7 @@ describe('storage()', function() { ref.toString().should.equal('gs://react-native-firebase-testing.appspot.com/1mbTestFile.gif'); }); - it('accepts a https encoded url', async function() { + it('accepts a https encoded url', async function () { const url = 'https%3A%2F%2Ffirebasestorage.googleapis.com%2Fv0%2Fb%2Freact-native-firebase-testing.appspot.com%2Fo%2F1mbTestFile.gif%3Falt%3Dmedia'; const ref = firebase.storage().refFromURL(url); @@ -130,7 +127,7 @@ describe('storage()', function() { ref.toString().should.equal('gs://react-native-firebase-testing.appspot.com/1mbTestFile.gif'); }); - it('throws an error if https url could not be parsed', async function() { + it('throws an error if https url could not be parsed', async function () { try { firebase.storage().refFromURL('https://invertase.io'); return Promise.reject(new Error('Did not throw an Error.')); @@ -140,13 +137,13 @@ describe('storage()', function() { } }); - it('accepts a gs url without a fullPath', async function() { + it('accepts a gs url without a fullPath', async function () { const url = 'gs://some-bucket'; const ref = firebase.storage().refFromURL(url); ref.toString().should.equal(url); }); - it('throws an error if url is not a string', async function() { + it('throws an error if url is not a string', async function () { try { firebase.storage().refFromURL({ derp: true }); return Promise.reject(new Error('Did not throw an Error.')); @@ -156,7 +153,7 @@ describe('storage()', function() { } }); - it('throws an error if url does not start with gs:// or https://', async function() { + it('throws an error if url does not start with gs:// or https://', async function () { try { firebase.storage().refFromURL('bs://foo/bar/cat.gif'); return Promise.reject(new Error('Did not throw an Error.')); @@ -167,14 +164,14 @@ describe('storage()', function() { }); }); - describe('setMaxOperationRetryTime', function() { - it('should set', async function() { + describe('setMaxOperationRetryTime', function () { + it('should set', async function () { firebase.storage().maxOperationRetryTime.should.equal(120000); await firebase.storage().setMaxOperationRetryTime(100000); firebase.storage().maxOperationRetryTime.should.equal(100000); }); - it('throws if time is not a number value', async function() { + it('throws if time is not a number value', async function () { try { await firebase.storage().setMaxOperationRetryTime('im a teapot'); return Promise.reject(new Error('Did not throw')); @@ -185,14 +182,14 @@ describe('storage()', function() { }); }); - describe('setMaxUploadRetryTime', function() { - it('should set', async function() { + describe('setMaxUploadRetryTime', function () { + it('should set', async function () { firebase.storage().maxUploadRetryTime.should.equal(600000); await firebase.storage().setMaxUploadRetryTime(120000); firebase.storage().maxUploadRetryTime.should.equal(120000); }); - it('throws if time is not a number value', async function() { + it('throws if time is not a number value', async function () { try { await firebase.storage().setMaxUploadRetryTime('im a teapot'); return Promise.reject(new Error('Did not throw')); @@ -203,14 +200,14 @@ describe('storage()', function() { }); }); - describe('setMaxDownloadRetryTime', function() { - it('should set', async function() { + describe('setMaxDownloadRetryTime', function () { + it('should set', async function () { firebase.storage().maxDownloadRetryTime.should.equal(600000); await firebase.storage().setMaxDownloadRetryTime(120000); firebase.storage().maxDownloadRetryTime.should.equal(120000); }); - it('throws if time is not a number value', async function() { + it('throws if time is not a number value', async function () { try { await firebase.storage().setMaxDownloadRetryTime('im a teapot'); return Promise.reject(new Error('Did not throw')); diff --git a/packages/storage/lib/index.d.ts b/packages/storage/lib/index.d.ts index d6ae110a41..8a4da33d7c 100644 --- a/packages/storage/lib/index.d.ts +++ b/packages/storage/lib/index.d.ts @@ -1113,6 +1113,7 @@ export default defaultExport; * Attach namespace to `firebase.` and `FirebaseApp.`. */ declare module '@react-native-firebase/app' { + // eslint-disable-next-line @typescript-eslint/no-unused-vars namespace ReactNativeFirebase { import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp; interface Module { diff --git a/tests/android/build.gradle b/tests/android/build.gradle index 1832bf9bbb..45fd364481 100644 --- a/tests/android/build.gradle +++ b/tests/android/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlinVersion = '1.4.20' + ext.kotlinVersion = '1.4.21' repositories { google() diff --git a/tests/e2e/init.js b/tests/e2e/init.js index 7b714ea140..d84309d79e 100644 --- a/tests/e2e/init.js +++ b/tests/e2e/init.js @@ -25,7 +25,7 @@ const { detox: config } = require('../package.json'); config.configurations['android.emu.debug'].device.avdName = process.env.ANDROID_AVD_NAME || config.configurations['android.emu.debug'].device.avdName; -before(async function() { +before(async function () { await detox.init(config); await jet.init(); }); @@ -49,7 +49,7 @@ beforeEach(async function beforeEach() { } }); -after(async function() { +after(async function () { console.log(' ✨ Tests Complete ✨ '); await device.terminateApp(); }); diff --git a/tests/ios/Podfile.lock b/tests/ios/Podfile.lock index 58d35592f8..cc37336491 100644 --- a/tests/ios/Podfile.lock +++ b/tests/ios/Podfile.lock @@ -708,69 +708,69 @@ PODS: - React-cxxreact (= 0.62.2) - React-jsi (= 0.62.2) - ReactCommon/callinvoker (= 0.62.2) - - RNFBAdMob (10.2.0): + - RNFBAdMob (10.3.1): - Firebase/AdMob (= 7.3.0) - PersonalizedAdConsent (~> 1.0.4) - React-Core - RNFBApp - - RNFBAnalytics (10.2.0): + - RNFBAnalytics (10.3.1): - Firebase/Analytics (= 7.3.0) - React-Core - RNFBApp - - RNFBApp (10.2.0): + - RNFBApp (10.3.0): - Firebase/CoreOnly (= 7.3.0) - React-Core - - RNFBAuth (10.2.0): + - RNFBAuth (10.3.1): - Firebase/Auth (= 7.3.0) - React-Core - RNFBApp - - RNFBCrashlytics (10.2.0): + - RNFBCrashlytics (10.3.1): - Firebase/Crashlytics (= 7.3.0) - React-Core - RNFBApp - - RNFBDatabase (10.2.0): + - RNFBDatabase (10.3.1): - Firebase/Database (= 7.3.0) - React-Core - RNFBApp - - RNFBDynamicLinks (10.2.0): + - RNFBDynamicLinks (10.3.1): - Firebase/DynamicLinks (= 7.3.0) - GoogleUtilities/AppDelegateSwizzler - React-Core - RNFBApp - - RNFBFirestore (10.2.0): + - RNFBFirestore (10.3.1): - Firebase/Firestore (= 7.3.0) - React-Core - RNFBApp - - RNFBFunctions (10.2.0): + - RNFBFunctions (10.3.1): - Firebase/Functions (= 7.3.0) - React-Core - RNFBApp - - RNFBIid (10.2.0): + - RNFBIid (10.3.1): - Firebase/CoreOnly (= 7.3.0) - FirebaseInstanceID - React-Core - RNFBApp - - RNFBInAppMessaging (10.2.0): + - RNFBInAppMessaging (10.3.1): - Firebase/InAppMessaging (= 7.3.0) - React-Core - RNFBApp - - RNFBMessaging (10.2.0): + - RNFBMessaging (10.3.1): - Firebase/Messaging (= 7.3.0) - React-Core - RNFBApp - - RNFBML (10.2.0): + - RNFBML (10.3.1): - Firebase/MLVision (= 7.3.0) - React-Core - RNFBApp - - RNFBPerf (10.2.0): + - RNFBPerf (10.3.1): - Firebase/Performance (= 7.3.0) - React-Core - RNFBApp - - RNFBRemoteConfig (10.2.0): + - RNFBRemoteConfig (10.3.1): - Firebase/RemoteConfig (= 7.3.0) - React-Core - RNFBApp - - RNFBStorage (10.2.0): + - RNFBStorage (10.3.1): - Firebase/Storage (= 7.3.0) - React-Core - RNFBApp @@ -1014,22 +1014,22 @@ SPEC CHECKSUMS: React-RCTText: fae545b10cfdb3d247c36c56f61a94cfd6dba41d React-RCTVibration: 4356114dbcba4ce66991096e51a66e61eda51256 ReactCommon: ed4e11d27609d571e7eee8b65548efc191116eb3 - RNFBAdMob: 9f2e2623a0cb4b75a548c1cac47c334547e9082a - RNFBAnalytics: bf045edef2f269bcf31d81007037afb57c8d7371 - RNFBApp: fd4be67593ac21e42ad9abfba81cabd79227e094 - RNFBAuth: 9171930995d3fa83b34c365a1553387f23c5f8e8 - RNFBCrashlytics: fca30344cb30b042bc9fddb5d86c05ff57c4124b - RNFBDatabase: d1136592fba24b7972658f2d94f77f0db470f293 - RNFBDynamicLinks: 676811143fd3601e75825fd4cc6eac61433aa34b - RNFBFirestore: 3c58f168e437c78200598c5945774397a1df24d1 - RNFBFunctions: 08efed83f47320dfff52ecaa7dd48c91119059b6 - RNFBIid: c3745573da38815e38b558104a88c5a9b19499ea - RNFBInAppMessaging: 028ca02ab5ffafcc88605fd9044bd84788d0d48f - RNFBMessaging: 13cd5384534e09454bcc74913a05e06598d6a18c - RNFBML: 6d77faa1249971a636c4256d009ccd56442cf15a - RNFBPerf: e3bf8a350f081f2ee2603dca3bd6f8c56aea7a2c - RNFBRemoteConfig: c7fe7222a5c8e4f214cca3a727337722642bbfe6 - RNFBStorage: dc9df0544ccea1cdad00239423966ef438461516 + RNFBAdMob: 88287d4b2bcc912bf78386de0c06e5ed26c28fc2 + RNFBAnalytics: 4cb9ac206293a82a2cbc34b89453ce1029135655 + RNFBApp: 92970246d22055f3ec6972ae9e25674b507a9d96 + RNFBAuth: 5ce3e6472762dd3bf07b4f0f8881cd2d47e489d2 + RNFBCrashlytics: 10726e5933bd02950540b516dfc6985fe70a968f + RNFBDatabase: 3eecf280ad6b7147e44b8f3ae37f3d6c66ca96d8 + RNFBDynamicLinks: 7bf8bec5709642f3c4ecd0ca81d0dd6e517ddd4a + RNFBFirestore: 680209de67b54e4316c0830a77766acce2716a90 + RNFBFunctions: dfe7e218089eacef69594758e41f10748b3f4f9b + RNFBIid: 6fedb1d590bfae67fb4e5523ca7436dd5d63f82d + RNFBInAppMessaging: 635ed405497e0811daf1a0da40c03fa77bc2f046 + RNFBMessaging: f3b89c460c8d723626f01abe11a2f02b821f08fa + RNFBML: 34ea0351464343056cb03f3ed3f17d9b82474038 + RNFBPerf: 9450efce70a451e26430a0939638833c40a2b8af + RNFBRemoteConfig: a8b5915d94501251438fd1c0ae385eb23b035552 + RNFBStorage: c1a850ee26d386031b68ca2be3c1dfcfbe22954a Yoga: 3ebccbdd559724312790e7742142d062476b698e PODFILE CHECKSUM: 25cda5a14df5322182a3bad4876faa9b94aafd3b diff --git a/tests/package.json b/tests/package.json index 8929643c2a..7e66b14696 100644 --- a/tests/package.json +++ b/tests/package.json @@ -32,7 +32,7 @@ "a2a": "^0.2.0", "babel-plugin-istanbul": "^6.0.0", "detox": "16.7.2", - "firebase-tools": "^8.12.1", + "firebase-tools": "^9.1.0", "jet": "^0.6.6-0", "mocha": "^6.1.4", "nyc": "^15.0.1", @@ -40,7 +40,7 @@ "react-native-port-patcher": "^1.0.4", "should": "^13.2.3", "should-sinon": "0.0.6", - "sinon": "^9.0.2" + "sinon": "^9.2.2" }, "detox": { "test-runner": "mocha", diff --git a/website/src/components/Advert.tsx b/website/src/components/Advert.tsx index 4db8a63be3..833a60c1af 100644 --- a/website/src/components/Advert.tsx +++ b/website/src/components/Advert.tsx @@ -20,11 +20,11 @@ import { graphql, useStaticQuery } from 'gatsby'; import { Advert as AdvertType } from '../types/docs'; import { Link } from './Link'; -function getRandomAdvert(adverts: AdvertType[]) { +function getRandomAdvert(adverts: AdvertType[]): AdvertType { return adverts[Math.floor(Math.random() * adverts.length)]; } -function Advert() { +function Advert(): JSX.Element { const { allAdvert } = useStaticQuery(graphql` query AdvertQuery { allAdvert { diff --git a/website/src/components/BlockQuote.tsx b/website/src/components/BlockQuote.tsx index 01e42c46b7..d5f6d3c701 100644 --- a/website/src/components/BlockQuote.tsx +++ b/website/src/components/BlockQuote.tsx @@ -17,7 +17,7 @@ import React from 'react'; -function BlockQuote({ children }: any) { +function BlockQuote({ children }: any): JSX.Element { return (
{children} diff --git a/website/src/components/EntityTable.tsx b/website/src/components/EntityTable.tsx index fa9b7decdb..f9e49a79f6 100644 --- a/website/src/components/EntityTable.tsx +++ b/website/src/components/EntityTable.tsx @@ -32,7 +32,7 @@ const Ul = styled.ul` row-gap: 2rem; `; -function EntityTable({ entities }: Props) { +function EntityTable({ entities }: Props): JSX.Element { return (
    diff --git a/website/src/components/Footer.tsx b/website/src/components/Footer.tsx index c50594a6b3..0d2a9d4427 100644 --- a/website/src/components/Footer.tsx +++ b/website/src/components/Footer.tsx @@ -18,7 +18,7 @@ import React from 'react'; import { Link } from './Link'; -function Footer() { +function Footer(): JSX.Element { return (