[admob] Add tests
This commit is contained in:
parent
e12567e57f
commit
a6705dfb3d
|
@ -36,7 +36,7 @@ AdMob Banners in RNFirebase are exported as a usable React component, allowing y
|
|||
|
||||
```js
|
||||
const Banner = firebase.admob.Banner;
|
||||
const AdRequest = firebase.admob.Banner;
|
||||
const AdRequest = firebase.admob.AdRequest;
|
||||
const request = new AdRequest();
|
||||
request.addKeyword('foobar');
|
||||
...
|
||||
|
@ -121,7 +121,9 @@ styling (background color, positions, font size etc). Native Express adverts are
|
|||
|
||||
```js
|
||||
const Banner = firebase.admob.Banner;
|
||||
const AdRequest = firebase.admob.NativeExpress;
|
||||
const NativeExpress = firebase.admob.NativeExpress;
|
||||
const NativeExpress = firebase.admob.AdRequest;
|
||||
|
||||
const request = new AdRequest();
|
||||
request.addKeyword('foobar');
|
||||
...
|
||||
|
|
|
@ -30,7 +30,7 @@ export default class AdRequest {
|
|||
}
|
||||
|
||||
setGender(gender: 'male | female | unknown') {
|
||||
const genders = ['male | female | unknown'];
|
||||
const genders = ['male', 'female', 'unknown'];
|
||||
if (genders.includes(gender)) {
|
||||
this._props.gender = gender;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ export default class Interstitial {
|
|||
* @param request
|
||||
* @returns {*}
|
||||
*/
|
||||
loadAd(request: AdRequest) {
|
||||
loadAd(request: Object) {
|
||||
return FirebaseAdMob.interstitialLoadAd(this.adUnit, request);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,156 @@
|
|||
export default function addTests({ before, fdescribe, describe, it, firebase }) {
|
||||
|
||||
before(() => {
|
||||
firebase.native.admob().initialize('ca-app-pub-3940256099942544~3347511713');
|
||||
});
|
||||
|
||||
describe('AdMob', () => {
|
||||
it('should return static variables', () => {
|
||||
return new Promise((resolve) => {
|
||||
const statics = firebase.native.admob;
|
||||
|
||||
statics.should.have.property('Banner').and.be.a.Function();
|
||||
statics.should.have.property('NativeExpress').and.be.a.Function();
|
||||
statics.should.have.property('AdRequest').and.be.a.Function();
|
||||
statics.should.have.property('VideoOptions').and.be.a.Function();
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return instance methods', () => {
|
||||
return new Promise((resolve) => {
|
||||
const admob = firebase.native.admob();
|
||||
|
||||
admob.should.have.property('initialize').and.be.a.Function();
|
||||
admob.should.have.property('interstitial').and.be.a.Function();
|
||||
admob.should.have.property('rewarded').and.be.a.Function();
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('AdRequest', () => {
|
||||
|
||||
it('should return AdRequest methods', () => {
|
||||
return new Promise((resolve) => {
|
||||
const request = new firebase.native.admob.AdRequest();
|
||||
|
||||
request.should.have.property('build').and.be.a.Function();
|
||||
request.should.have.property('addTestDevice').and.be.a.Function();
|
||||
request.should.have.property('addKeyword').and.be.a.Function();
|
||||
request.should.have.property('setBirthday').and.be.a.Function();
|
||||
request.should.have.property('setContentUrl').and.be.a.Function();
|
||||
request.should.have.property('setGender').and.be.a.Function();
|
||||
request.should.have.property('setLocation').and.be.a.Function();
|
||||
request.should.have.property('setRequestAgent').and.be.a.Function();
|
||||
request.should.have.property('setIsDesignedForFamilies').and.be.a.Function();
|
||||
request.should.have.property('tagForChildDirectedTreatment').and.be.a.Function();
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
it('should build an empty request', () => {
|
||||
return new Promise((resolve) => {
|
||||
const request = new firebase.native.admob.AdRequest();
|
||||
const build = request.build();
|
||||
|
||||
build.should.have.property('keywords').and.be.a.Array();
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
it('should build a full request', () => {
|
||||
return new Promise((resolve) => {
|
||||
const request = new firebase.native.admob.AdRequest();
|
||||
|
||||
request
|
||||
.addTestDevice()
|
||||
.addKeyword('foo')
|
||||
.addKeyword('bar')
|
||||
// .setBirthday() // TODO
|
||||
.setContentUrl('http://google.com')
|
||||
.setGender('female')
|
||||
// .setLocation() // TODO
|
||||
.setRequestAgent('foobar')
|
||||
.setIsDesignedForFamilies(true)
|
||||
.tagForChildDirectedTreatment(true);
|
||||
|
||||
const build = request.build();
|
||||
|
||||
build.should.have.property('keywords').and.be.a.Array();
|
||||
build.keywords.should.containEql('foo');
|
||||
build.keywords.should.containEql('bar');
|
||||
build.should.have.property('contentUrl').and.be.a.equal('http://google.com');
|
||||
build.should.have.property('gender').and.be.a.equal('female');
|
||||
build.should.have.property('requestAgent').and.be.a.equal('foobar');
|
||||
build.should.have.property('isDesignedForFamilies').and.be.a.equal(true);
|
||||
build.should.have.property('tagForChildDirectedTreatment').and.be.a.equal(true);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('VideoOptions', () => {
|
||||
it('should return VideoOptions methods', () => {
|
||||
return new Promise((resolve) => {
|
||||
const options = new firebase.native.admob.VideoOptions();
|
||||
|
||||
options.should.have.property('build').and.be.a.Function();
|
||||
options.should.have.property('setStartMuted').and.be.a.Function();
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
it('should build an empty request', () => {
|
||||
return new Promise((resolve) => {
|
||||
const options = new firebase.native.admob.VideoOptions();
|
||||
const build = options.build();
|
||||
|
||||
build.should.have.property('startMuted').and.be.a.equal(true);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
it('should build all options', () => {
|
||||
return new Promise((resolve) => {
|
||||
const options = new firebase.native.admob.VideoOptions();
|
||||
|
||||
options.setStartMuted(false);
|
||||
|
||||
const build = options.build();
|
||||
|
||||
build.should.have.property('startMuted').and.be.a.equal(false);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
describe('Interstitial', () => {
|
||||
it('should return a new instance with methods', () => {
|
||||
return new Promise((resolve) => {
|
||||
const advert = firebase.native.admob().interstitial('ca-app-pub-3940256099942544/1033173712');
|
||||
|
||||
advert.should.have.property('loadAd').and.be.a.Function();
|
||||
advert.should.have.property('isLoaded').and.be.a.Function();
|
||||
advert.should.have.property('show').and.be.a.Function();
|
||||
advert.should.have.property('on').and.be.a.Function();
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Rewarded', () => {
|
||||
it('should return a new instance with methods', () => {
|
||||
return new Promise((resolve) => {
|
||||
const advert = firebase.native.admob().rewarded('ca-app-pub-3940256099942544/1033173712');
|
||||
|
||||
advert.should.have.property('loadAd').and.be.a.Function();
|
||||
advert.should.have.property('isLoaded').and.be.a.Function();
|
||||
advert.should.have.property('show').and.be.a.Function();
|
||||
advert.should.have.property('on').and.be.a.Function();
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
import firebase from '../../firebase';
|
||||
import TestSuite from '../../../lib/TestSuite';
|
||||
import admobTests from './admob';
|
||||
|
||||
const suite = new TestSuite('AdMob', 'firebase.admob()', firebase);
|
||||
|
||||
suite.addTests(admobTests);
|
||||
|
||||
export default suite;
|
|
@ -1,29 +1,5 @@
|
|||
|
||||
export default function addTests({ fdescribe, describe, it, firebase }) {
|
||||
// it('works', () => {
|
||||
// return new Promise((resolve) => {
|
||||
// firebase.native.remoteConfig().enableDeveloperMode();
|
||||
//
|
||||
// firebase.native.remoteConfig().setDefaults({
|
||||
// foobar: '123',
|
||||
// barbaz: '345'
|
||||
// });
|
||||
//
|
||||
// firebase.native.remoteConfig().fetch()
|
||||
// .then(() => {
|
||||
// return firebase.native.remoteConfig().activateFetched();
|
||||
// })
|
||||
// .then(() => {
|
||||
// return firebase.native.remoteConfig().getValue('foobar')
|
||||
// })
|
||||
// .then((res) => {
|
||||
// console.log('>>>>>', res.val())
|
||||
// return Promise.resolve();
|
||||
// })
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
describe('Analytics', () => {
|
||||
it('logEvent: it should log a text event without error', () => {
|
||||
return new Promise((resolve) => {
|
||||
|
|
|
@ -7,6 +7,7 @@ import storage from './storage/index';
|
|||
import auth from './auth/index';
|
||||
import config from './config/index';
|
||||
import performance from './perf/index';
|
||||
import admob from './admob/index';
|
||||
|
||||
const testSuiteInstances = [
|
||||
database,
|
||||
|
@ -17,6 +18,7 @@ const testSuiteInstances = [
|
|||
storage,
|
||||
config,
|
||||
performance,
|
||||
admob,
|
||||
];
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue