mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-30 05:05:52 +08:00
[tests] refactor to use latest Jet setup
This commit is contained in:
@@ -1 +1 @@
|
|||||||
{}
|
{}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class Root extends Component {
|
|||||||
message: '',
|
message: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
jet.setBridgeProperty('module', firebase);
|
jet.exposeContextProperty('module', firebase);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|||||||
@@ -1,124 +0,0 @@
|
|||||||
const should = require('should');
|
|
||||||
|
|
||||||
describe('bridge', () => {
|
|
||||||
// beforeEach(async function beforeEach() {
|
|
||||||
// await device.reloadReactNative();
|
|
||||||
// bridge.root.setState({ message: this.currentTest.title });
|
|
||||||
// });
|
|
||||||
|
|
||||||
it('should provide -> global.bridge', async () => {
|
|
||||||
should(bridge).not.be.undefined();
|
|
||||||
return Promise.resolve();
|
|
||||||
});
|
|
||||||
|
|
||||||
// main react-native module you're testing on
|
|
||||||
// in our case react-native-firebase
|
|
||||||
it('should provide -> bridge.module', async () => {
|
|
||||||
should(bridge.module).not.be.undefined();
|
|
||||||
return Promise.resolve();
|
|
||||||
});
|
|
||||||
|
|
||||||
// react-native module access
|
|
||||||
it('should provide -> bridge.rn', () => {
|
|
||||||
should(bridge.rn).not.be.undefined();
|
|
||||||
should(bridge.rn.Platform.OS).be.a.String();
|
|
||||||
should(bridge.rn.Platform.OS).equal(device.getPlatform());
|
|
||||||
return Promise.resolve();
|
|
||||||
});
|
|
||||||
|
|
||||||
// 'global' context of the app's JS environment
|
|
||||||
it('should provide -> bridge.context', () => {
|
|
||||||
should(bridge.context).not.be.undefined();
|
|
||||||
should(bridge.context.setTimeout).be.a.Function();
|
|
||||||
should(bridge.context.window).be.a.Object();
|
|
||||||
// etc ... e.g. __coverage__ is here also if covering
|
|
||||||
return Promise.resolve();
|
|
||||||
});
|
|
||||||
|
|
||||||
// the apps root component
|
|
||||||
// allows you to read and set state if required
|
|
||||||
xit('should provide -> bridge.root', async () => {
|
|
||||||
should(bridge.root).not.be.undefined();
|
|
||||||
should(bridge.root.setState).be.a.Function();
|
|
||||||
should(bridge.root.state).be.a.Object();
|
|
||||||
|
|
||||||
// test setting state
|
|
||||||
await new Promise(resolve =>
|
|
||||||
bridge.root.setState({ message: 'hello world' }, resolve)
|
|
||||||
);
|
|
||||||
should(bridge.root.state.message).equal('hello world');
|
|
||||||
return Promise.resolve();
|
|
||||||
});
|
|
||||||
|
|
||||||
// we shim our own reloadReactNative functionality as the detox reloadReactNative built-in
|
|
||||||
// hangs often and seems unpredictable - todo: investigate & PR if solution found
|
|
||||||
// reloadReactNative is replaced on init with bridge.root automatically
|
|
||||||
xit('should allow reloadReactNative usage without breaking remote debug', async () => {
|
|
||||||
should(bridge.reload).be.a.Function();
|
|
||||||
// and check it works without breaking anything
|
|
||||||
await device.reloadReactNative();
|
|
||||||
should(bridge.reload).be.a.Function();
|
|
||||||
return Promise.resolve();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should allow launchApp usage without breaking remote debug', async () => {
|
|
||||||
should(bridge.module).not.be.undefined();
|
|
||||||
should(bridge.reload).be.a.Function();
|
|
||||||
should(bridge.rn).not.be.undefined();
|
|
||||||
should(bridge.rn.Platform.OS).be.a.String();
|
|
||||||
should(bridge.rn.Platform.OS).equal(device.getPlatform());
|
|
||||||
|
|
||||||
await device.launchApp({ newInstance: true });
|
|
||||||
|
|
||||||
should(bridge.module).not.be.undefined();
|
|
||||||
should(bridge.reload).be.a.Function();
|
|
||||||
should(bridge.rn).not.be.undefined();
|
|
||||||
should(bridge.rn.Platform.OS).be.a.String();
|
|
||||||
should(bridge.rn.Platform.OS).equal(device.getPlatform());
|
|
||||||
return Promise.resolve();
|
|
||||||
});
|
|
||||||
|
|
||||||
// TIMERS
|
|
||||||
it('timing.setTimeout', cb => {
|
|
||||||
const start = Date.now();
|
|
||||||
bridge.context.setTimeout(() => {
|
|
||||||
const timeTaken = Date.now() - start;
|
|
||||||
if (timeTaken >= 50) cb();
|
|
||||||
else cb(new Error('setTimeout fn called too soon.'));
|
|
||||||
}, 50);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('timing.setInterval', cb => {
|
|
||||||
let times = 0;
|
|
||||||
let interval;
|
|
||||||
const start = Date.now();
|
|
||||||
|
|
||||||
interval = bridge.context.setInterval(() => {
|
|
||||||
const timeTaken = Date.now() - start;
|
|
||||||
|
|
||||||
times++;
|
|
||||||
bridge.context.clearInterval(interval);
|
|
||||||
if (times >= 2) {
|
|
||||||
return cb(new Error('Interval did not cancel correctly.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (timeTaken < 50) {
|
|
||||||
return cb(new Error('setInterval fn called too soon.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return bridge.context.setTimeout(cb, 100);
|
|
||||||
}, 50);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('timing.setImmediate', cb => {
|
|
||||||
bridge.context.setImmediate(() => cb());
|
|
||||||
});
|
|
||||||
|
|
||||||
it('timing.requestIdleCallback', cb => {
|
|
||||||
bridge.context.requestIdleCallback(() => cb());
|
|
||||||
});
|
|
||||||
|
|
||||||
it('timing.requestAnimationFrame', cb => {
|
|
||||||
bridge.context.requestAnimationFrame(() => cb());
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -16,7 +16,7 @@ describe('database()', () => {
|
|||||||
const dataTypeValue = CONTENTS.DEFAULT[dataRef];
|
const dataTypeValue = CONTENTS.DEFAULT[dataRef];
|
||||||
const ref = firebase.database().ref(`tests/types/${dataRef}`);
|
const ref = firebase.database().ref(`tests/types/${dataRef}`);
|
||||||
return ref.once('value').then(snapshot => {
|
return ref.once('value').then(snapshot => {
|
||||||
snapshot.val().should.eql(bridge.contextify(dataTypeValue));
|
snapshot.val().should.eql(jet.contextify(dataTypeValue));
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -16,14 +16,14 @@ describe('database()', () => {
|
|||||||
it('changes value', async () => {
|
it('changes value', async () => {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
Object.keys(CONTENTS.DEFAULT).map(async dataRef => {
|
Object.keys(CONTENTS.DEFAULT).map(async dataRef => {
|
||||||
const previousValue = bridge.contextify(CONTENTS.DEFAULT[dataRef]);
|
const previousValue = jet.contextify(CONTENTS.DEFAULT[dataRef]);
|
||||||
|
|
||||||
const ref = firebase.database().ref(`tests/types/${dataRef}`);
|
const ref = firebase.database().ref(`tests/types/${dataRef}`);
|
||||||
|
|
||||||
const snapshot = await ref.once('value');
|
const snapshot = await ref.once('value');
|
||||||
snapshot.val().should.eql(previousValue);
|
snapshot.val().should.eql(previousValue);
|
||||||
|
|
||||||
const newValue = bridge.contextify(CONTENTS.NEW[dataRef]);
|
const newValue = jet.contextify(CONTENTS.NEW[dataRef]);
|
||||||
|
|
||||||
await ref.set(newValue);
|
await ref.set(newValue);
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ describe('database()', () => {
|
|||||||
it('can unset values', async () => {
|
it('can unset values', async () => {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
Object.keys(CONTENTS.DEFAULT).map(async dataRef => {
|
Object.keys(CONTENTS.DEFAULT).map(async dataRef => {
|
||||||
const previousValue = bridge.contextify(CONTENTS.DEFAULT[dataRef]);
|
const previousValue = jet.contextify(CONTENTS.DEFAULT[dataRef]);
|
||||||
const ref = firebase.database().ref(`tests/types/${dataRef}`);
|
const ref = firebase.database().ref(`tests/types/${dataRef}`);
|
||||||
|
|
||||||
const snapshot = await ref.once('value');
|
const snapshot = await ref.once('value');
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ describe('database()', () => {
|
|||||||
.once('value');
|
.once('value');
|
||||||
|
|
||||||
snapshot.val.should.be.a.Function();
|
snapshot.val.should.be.a.Function();
|
||||||
snapshot.val().should.eql(bridge.Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]));
|
snapshot.val().should.eql(jet.Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should provide a functioning child() method', async () => {
|
it('should provide a functioning child() method', async () => {
|
||||||
@@ -71,7 +71,7 @@ describe('database()', () => {
|
|||||||
const snapshot = await ref.once('value');
|
const snapshot = await ref.once('value');
|
||||||
snapshot.getPriority.should.be.a.Function();
|
snapshot.getPriority.should.be.a.Function();
|
||||||
snapshot.getPriority().should.equal(666);
|
snapshot.getPriority().should.equal(666);
|
||||||
snapshot.val().should.eql(bridge.Object({ foo: 'bar' }));
|
snapshot.val().should.eql(jet.Object({ foo: 'bar' }));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should provide a functioning forEach() method', async () => {
|
it('should provide a functioning forEach() method', async () => {
|
||||||
|
|||||||
@@ -11,19 +11,19 @@ const {
|
|||||||
} = TestHelpers.firestore;
|
} = TestHelpers.firestore;
|
||||||
|
|
||||||
function getCollectionReferenceClass() {
|
function getCollectionReferenceClass() {
|
||||||
return bridge.require('src/modules/firestore/CollectionReference');
|
return jet.require('src/modules/firestore/CollectionReference');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDocumentReferenceClass() {
|
function getDocumentReferenceClass() {
|
||||||
return bridge.require('src/modules/firestore/DocumentReference');
|
return jet.require('src/modules/firestore/DocumentReference');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDocumentSnapshotClass() {
|
function getDocumentSnapshotClass() {
|
||||||
return bridge.require('src/modules/firestore/DocumentSnapshot');
|
return jet.require('src/modules/firestore/DocumentSnapshot');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPathClass() {
|
function getPathClass() {
|
||||||
return bridge.require('src/modules/firestore/Path');
|
return jet.require('src/modules/firestore/Path');
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('firestore()', () => {
|
describe('firestore()', () => {
|
||||||
|
|||||||
@@ -622,14 +622,14 @@ describe('firestore()', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should handle Date field', async () => {
|
it('should handle Date field', async () => {
|
||||||
const date = new bridge.context.window.Date();
|
const date = new jet.context.window.Date();
|
||||||
const docRef = test2DocRef('reference');
|
const docRef = test2DocRef('reference');
|
||||||
await docRef.set({
|
await docRef.set({
|
||||||
field: date,
|
field: date,
|
||||||
});
|
});
|
||||||
|
|
||||||
const doc = await docRef.get();
|
const doc = await docRef.get();
|
||||||
doc.data().field.should.be.instanceof(bridge.context.window.Date);
|
doc.data().field.should.be.instanceof(jet.context.window.Date);
|
||||||
should.equal(doc.data().field.toISOString(), date.toISOString());
|
should.equal(doc.data().field.toISOString(), date.toISOString());
|
||||||
should.equal(doc.data().field.getTime(), date.getTime());
|
should.equal(doc.data().field.getTime(), date.getTime());
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ describe('firestore()', () => {
|
|||||||
describe('ref', () => {
|
describe('ref', () => {
|
||||||
it('returns a DocumentReference', async () => {
|
it('returns a DocumentReference', async () => {
|
||||||
const snapshot = await testCollectionDoc(COL_DOC_1_PATH).get();
|
const snapshot = await testCollectionDoc(COL_DOC_1_PATH).get();
|
||||||
const DocumentReference = bridge.require(
|
const DocumentReference = jet.require(
|
||||||
'src/modules/firestore/DocumentReference'
|
'src/modules/firestore/DocumentReference'
|
||||||
);
|
);
|
||||||
snapshot.ref.should.be.an.instanceOf(DocumentReference);
|
snapshot.ref.should.be.an.instanceOf(DocumentReference);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ describe('firestore()', () => {
|
|||||||
).get();
|
).get();
|
||||||
|
|
||||||
dataAfterUpdate().creationDate.should.be.instanceof(
|
dataAfterUpdate().creationDate.should.be.instanceof(
|
||||||
bridge.context.window.Date
|
jet.context.window.Date
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ describe('firestore()', () => {
|
|||||||
describe('Path', () => {
|
describe('Path', () => {
|
||||||
describe('id', () => {
|
describe('id', () => {
|
||||||
it('returns the document id', async () => {
|
it('returns the document id', async () => {
|
||||||
const Path = bridge.require('src/modules/firestore/Path');
|
const Path = jet.require('src/modules/firestore/Path');
|
||||||
|
|
||||||
const path = Path.fromName('collection/documentId');
|
const path = Path.fromName('collection/documentId');
|
||||||
path.id.should.be.equal('documentId');
|
path.id.should.be.equal('documentId');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns null if no path', async () => {
|
it('returns null if no path', async () => {
|
||||||
const Path = bridge.require('src/modules/firestore/Path');
|
const Path = jet.require('src/modules/firestore/Path');
|
||||||
|
|
||||||
const path = Path.fromName('');
|
const path = Path.fromName('');
|
||||||
should.equal(path.id, null);
|
should.equal(path.id, null);
|
||||||
@@ -18,14 +18,14 @@ describe('firestore()', () => {
|
|||||||
|
|
||||||
describe('isDocument', () => {
|
describe('isDocument', () => {
|
||||||
it('returns true if path is a document', async () => {
|
it('returns true if path is a document', async () => {
|
||||||
const Path = bridge.require('src/modules/firestore/Path');
|
const Path = jet.require('src/modules/firestore/Path');
|
||||||
|
|
||||||
const path = Path.fromName('collection/documentId');
|
const path = Path.fromName('collection/documentId');
|
||||||
path.isDocument.should.be.equal(true);
|
path.isDocument.should.be.equal(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns false if path is a collection', async () => {
|
it('returns false if path is a collection', async () => {
|
||||||
const Path = bridge.require('src/modules/firestore/Path');
|
const Path = jet.require('src/modules/firestore/Path');
|
||||||
|
|
||||||
const path = Path.fromName('collection');
|
const path = Path.fromName('collection');
|
||||||
path.isDocument.should.be.equal(false);
|
path.isDocument.should.be.equal(false);
|
||||||
@@ -34,14 +34,14 @@ describe('firestore()', () => {
|
|||||||
|
|
||||||
describe('isCollection', () => {
|
describe('isCollection', () => {
|
||||||
it('returns true if path is a collection', async () => {
|
it('returns true if path is a collection', async () => {
|
||||||
const Path = bridge.require('src/modules/firestore/Path');
|
const Path = jet.require('src/modules/firestore/Path');
|
||||||
|
|
||||||
const path = Path.fromName('collection');
|
const path = Path.fromName('collection');
|
||||||
path.isCollection.should.be.equal(true);
|
path.isCollection.should.be.equal(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns false if path is a document', async () => {
|
it('returns false if path is a document', async () => {
|
||||||
const Path = bridge.require('src/modules/firestore/Path');
|
const Path = jet.require('src/modules/firestore/Path');
|
||||||
|
|
||||||
const path = Path.fromName('collection/documentId');
|
const path = Path.fromName('collection/documentId');
|
||||||
path.isCollection.should.be.equal(false);
|
path.isCollection.should.be.equal(false);
|
||||||
@@ -50,7 +50,7 @@ describe('firestore()', () => {
|
|||||||
|
|
||||||
describe('relativeName', () => {
|
describe('relativeName', () => {
|
||||||
it('returns original full path', async () => {
|
it('returns original full path', async () => {
|
||||||
const Path = bridge.require('src/modules/firestore/Path');
|
const Path = jet.require('src/modules/firestore/Path');
|
||||||
|
|
||||||
const path = Path.fromName('collection');
|
const path = Path.fromName('collection');
|
||||||
const path2 = Path.fromName('collection/documentId');
|
const path2 = Path.fromName('collection/documentId');
|
||||||
@@ -61,7 +61,7 @@ describe('firestore()', () => {
|
|||||||
|
|
||||||
describe('child()', () => {
|
describe('child()', () => {
|
||||||
it('returns original path joined with the provided child path', async () => {
|
it('returns original path joined with the provided child path', async () => {
|
||||||
const Path = bridge.require('src/modules/firestore/Path');
|
const Path = jet.require('src/modules/firestore/Path');
|
||||||
|
|
||||||
const path = Path.fromName('collection');
|
const path = Path.fromName('collection');
|
||||||
const path2 = path.child('documentId');
|
const path2 = path.child('documentId');
|
||||||
@@ -72,7 +72,7 @@ describe('firestore()', () => {
|
|||||||
|
|
||||||
describe('parent()', () => {
|
describe('parent()', () => {
|
||||||
it('returns the parent of the current child path', async () => {
|
it('returns the parent of the current child path', async () => {
|
||||||
const Path = bridge.require('src/modules/firestore/Path');
|
const Path = jet.require('src/modules/firestore/Path');
|
||||||
|
|
||||||
const path = Path.fromName('collection/documentId');
|
const path = Path.fromName('collection/documentId');
|
||||||
const path2 = path.parent();
|
const path2 = path.parent();
|
||||||
@@ -81,7 +81,7 @@ describe('firestore()', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns null if no path', async () => {
|
it('returns null if no path', async () => {
|
||||||
const Path = bridge.require('src/modules/firestore/Path');
|
const Path = jet.require('src/modules/firestore/Path');
|
||||||
|
|
||||||
const path = Path.fromName('');
|
const path = Path.fromName('');
|
||||||
const path2 = path.parent();
|
const path2 = path.parent();
|
||||||
@@ -92,7 +92,7 @@ describe('firestore()', () => {
|
|||||||
|
|
||||||
describe('static fromName()', () => {
|
describe('static fromName()', () => {
|
||||||
it('returns a new instance from a / delimited path string', async () => {
|
it('returns a new instance from a / delimited path string', async () => {
|
||||||
const Path = bridge.require('src/modules/firestore/Path');
|
const Path = jet.require('src/modules/firestore/Path');
|
||||||
|
|
||||||
const path = Path.fromName('collection/document');
|
const path = Path.fromName('collection/document');
|
||||||
path.should.be.instanceOf(Path);
|
path.should.be.instanceOf(Path);
|
||||||
@@ -100,7 +100,7 @@ describe('firestore()', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns a new instance from an empty string', async () => {
|
it('returns a new instance from an empty string', async () => {
|
||||||
const Path = bridge.require('src/modules/firestore/Path');
|
const Path = jet.require('src/modules/firestore/Path');
|
||||||
|
|
||||||
const path = Path.fromName('');
|
const path = Path.fromName('');
|
||||||
path.should.be.instanceOf(Path);
|
path.should.be.instanceOf(Path);
|
||||||
@@ -109,7 +109,7 @@ describe('firestore()', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns a new instance with no args provided', async () => {
|
it('returns a new instance with no args provided', async () => {
|
||||||
const Path = bridge.require('src/modules/firestore/Path');
|
const Path = jet.require('src/modules/firestore/Path');
|
||||||
|
|
||||||
const path = Path.fromName();
|
const path = Path.fromName();
|
||||||
path.should.be.instanceOf(Path);
|
path.should.be.instanceOf(Path);
|
||||||
|
|||||||
126
tests/e2e/jet.spec.js
Executable file
126
tests/e2e/jet.spec.js
Executable file
@@ -0,0 +1,126 @@
|
|||||||
|
const should = require('should');
|
||||||
|
|
||||||
|
describe('jet', () => {
|
||||||
|
// beforeEach(async function beforeEach() {
|
||||||
|
// await device.reloadReactNative();
|
||||||
|
// jet.root.setState({ message: this.currentTest.title });
|
||||||
|
// });
|
||||||
|
|
||||||
|
it('should provide -> global.jet', async () => {
|
||||||
|
should(jet).not.be.undefined();
|
||||||
|
return Promise.resolve();
|
||||||
|
});
|
||||||
|
|
||||||
|
// main react-native module you're testing on
|
||||||
|
// in our case react-native-firebase
|
||||||
|
it('should provide -> jet.module', async () => {
|
||||||
|
should(jet.module).not.be.undefined();
|
||||||
|
return Promise.resolve();
|
||||||
|
});
|
||||||
|
|
||||||
|
// react-native module access
|
||||||
|
it('should provide -> jet.rn', () => {
|
||||||
|
should(jet.rn).not.be.undefined();
|
||||||
|
should(jet.rn.Platform.OS).be.a.String();
|
||||||
|
should(jet.rn.Platform.OS).equal(device.getPlatform());
|
||||||
|
return Promise.resolve();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 'global' context of the app's JS environment
|
||||||
|
it('should provide -> jet.context', () => {
|
||||||
|
should(jet.context).not.be.undefined();
|
||||||
|
should(jet.context.setTimeout).be.a.Function();
|
||||||
|
should(jet.context.window).be.a.Object();
|
||||||
|
// etc ... e.g. __coverage__ is here also if covering
|
||||||
|
return Promise.resolve();
|
||||||
|
});
|
||||||
|
|
||||||
|
// the apps root component
|
||||||
|
// allows you to read and set state if required
|
||||||
|
xit('should provide -> jet.root', async () => {
|
||||||
|
should(jet.root).not.be.undefined();
|
||||||
|
should(jet.root.setState).be.a.Function();
|
||||||
|
should(jet.root.state).be.a.Object();
|
||||||
|
|
||||||
|
// test setting state
|
||||||
|
await new Promise(resolve =>
|
||||||
|
jet.root.setState({ message: 'hello world' }, resolve)
|
||||||
|
);
|
||||||
|
should(jet.root.state.message).equal('hello world');
|
||||||
|
return Promise.resolve();
|
||||||
|
});
|
||||||
|
|
||||||
|
// we shim our own reloadReactNative functionality as the detox reloadReactNative built-in
|
||||||
|
// hangs often and seems unpredictable - todo: investigate & PR if solution found
|
||||||
|
// reloadReactNative is replaced on init with jet.root automatically
|
||||||
|
xit('should allow reloadReactNative usage without breaking remote debug', async () => {
|
||||||
|
should(jet.reload).be.a.Function();
|
||||||
|
// and check it works without breaking anything
|
||||||
|
await device.reloadReactNative();
|
||||||
|
should(jet.reload).be.a.Function();
|
||||||
|
return Promise.resolve();
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO flakey - "This method must not be called before the JS thread is created"
|
||||||
|
// https://github.com/facebook/react-native/blob/master/React/CxxBridge/RCTCxxBridge.mm
|
||||||
|
xit('should allow launchApp usage without breaking remote debug', async () => {
|
||||||
|
should(jet.module).not.be.undefined();
|
||||||
|
should(jet.reload).be.a.Function();
|
||||||
|
should(jet.rn).not.be.undefined();
|
||||||
|
should(jet.rn.Platform.OS).be.a.String();
|
||||||
|
should(jet.rn.Platform.OS).equal(device.getPlatform());
|
||||||
|
|
||||||
|
await device.launchApp({ newInstance: true });
|
||||||
|
|
||||||
|
should(jet.module).not.be.undefined();
|
||||||
|
should(jet.reload).be.a.Function();
|
||||||
|
should(jet.rn).not.be.undefined();
|
||||||
|
should(jet.rn.Platform.OS).be.a.String();
|
||||||
|
should(jet.rn.Platform.OS).equal(device.getPlatform());
|
||||||
|
return Promise.resolve();
|
||||||
|
});
|
||||||
|
|
||||||
|
// TIMERS
|
||||||
|
it('timing.setTimeout', cb => {
|
||||||
|
const start = Date.now();
|
||||||
|
jet.context.setTimeout(() => {
|
||||||
|
const timeTaken = Date.now() - start;
|
||||||
|
if (timeTaken >= 50) cb();
|
||||||
|
else cb(new Error('setTimeout fn called too soon.'));
|
||||||
|
}, 50);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('timing.setInterval', cb => {
|
||||||
|
let times = 0;
|
||||||
|
let interval;
|
||||||
|
const start = Date.now();
|
||||||
|
|
||||||
|
interval = jet.context.setInterval(() => {
|
||||||
|
const timeTaken = Date.now() - start;
|
||||||
|
|
||||||
|
times++;
|
||||||
|
jet.context.clearInterval(interval);
|
||||||
|
if (times >= 2) {
|
||||||
|
return cb(new Error('Interval did not cancel correctly.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (timeTaken < 50) {
|
||||||
|
return cb(new Error('setInterval fn called too soon.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return jet.context.setTimeout(cb, 100);
|
||||||
|
}, 50);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('timing.setImmediate', cb => {
|
||||||
|
jet.context.setImmediate(() => cb());
|
||||||
|
});
|
||||||
|
|
||||||
|
it('timing.requestIdleCallback', cb => {
|
||||||
|
jet.context.requestIdleCallback(() => cb());
|
||||||
|
});
|
||||||
|
|
||||||
|
it('timing.requestAnimationFrame', cb => {
|
||||||
|
jet.context.requestAnimationFrame(() => cb());
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -41,7 +41,7 @@ module.exports = {
|
|||||||
object: {
|
object: {
|
||||||
daz: 123,
|
daz: 123,
|
||||||
},
|
},
|
||||||
timestamp: new bridge.context.window.Date(2017, 2, 10, 10, 0, 0),
|
timestamp: new jet.context.window.Date(2017, 2, 10, 10, 0, 0),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ module.exports = {
|
|||||||
object: {
|
object: {
|
||||||
daz: 123,
|
daz: 123,
|
||||||
},
|
},
|
||||||
timestamp: new bridge.context.window.Date(2017, 2, 10, 10, 0, 0),
|
timestamp: new jet.context.window.Date(2017, 2, 10, 10, 0, 0),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -5,39 +5,7 @@ global.should = require('should');
|
|||||||
|
|
||||||
Object.defineProperty(global, 'firebase', {
|
Object.defineProperty(global, 'firebase', {
|
||||||
get() {
|
get() {
|
||||||
return bridge.module;
|
return jet.module;
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// TODO move as part of bridge
|
|
||||||
const { Uint8Array } = global;
|
|
||||||
Object.defineProperty(global, 'Uint8Array', {
|
|
||||||
get() {
|
|
||||||
const { stack } = new Error();
|
|
||||||
if (
|
|
||||||
(stack.includes('Context.it') || stack.includes('Context.beforeEach')) &&
|
|
||||||
global.bridge &&
|
|
||||||
global.bridge.context
|
|
||||||
) {
|
|
||||||
return bridge.context.window.Uint8Array;
|
|
||||||
}
|
|
||||||
return Uint8Array;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// TODO move as part of bridge
|
|
||||||
const { Array } = global;
|
|
||||||
Object.defineProperty(global, 'Array', {
|
|
||||||
get() {
|
|
||||||
const { stack } = new Error();
|
|
||||||
if (
|
|
||||||
(stack.includes('Context.it') || stack.includes('Context.beforeEach')) &&
|
|
||||||
global.bridge &&
|
|
||||||
global.bridge.context
|
|
||||||
) {
|
|
||||||
return bridge.context.window.Array;
|
|
||||||
}
|
|
||||||
return Array;
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -76,7 +44,9 @@ global.firebaseAdmin = require('firebase-admin');
|
|||||||
|
|
||||||
firebaseAdmin.initializeApp({
|
firebaseAdmin.initializeApp({
|
||||||
credential: firebaseAdmin.credential.cert(
|
credential: firebaseAdmin.credential.cert(
|
||||||
JSON.parse(process.env.FIREBASE_SERVICE_ACCOUNT)
|
JSON.parse(
|
||||||
|
process.env.FIREBASE_SERVICE_ACCOUNT
|
||||||
|
)
|
||||||
),
|
),
|
||||||
databaseURL: 'https://rnfirebase-b9ad4.firebaseio.com',
|
databaseURL: 'https://rnfirebase-b9ad4.firebaseio.com',
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -221,25 +221,25 @@ PODS:
|
|||||||
- nanopb/decode (0.3.8)
|
- nanopb/decode (0.3.8)
|
||||||
- nanopb/encode (0.3.8)
|
- nanopb/encode (0.3.8)
|
||||||
- Protobuf (3.6.1)
|
- Protobuf (3.6.1)
|
||||||
- React (0.57.0-rc.4):
|
- React (0.57.0):
|
||||||
- React/Core (= 0.57.0-rc.4)
|
- React/Core (= 0.57.0)
|
||||||
- React/Core (0.57.0-rc.4):
|
- React/Core (0.57.0):
|
||||||
- yoga (= 0.57.0-rc.4.React)
|
- yoga (= 0.57.0.React)
|
||||||
- React/fishhook (0.57.0-rc.4)
|
- React/fishhook (0.57.0)
|
||||||
- React/RCTBlob (0.57.0-rc.4):
|
- React/RCTBlob (0.57.0):
|
||||||
- React/Core
|
- React/Core
|
||||||
- React/RCTNetwork (0.57.0-rc.4):
|
- React/RCTNetwork (0.57.0):
|
||||||
- React/Core
|
- React/Core
|
||||||
- React/RCTText (0.57.0-rc.4):
|
- React/RCTText (0.57.0):
|
||||||
- React/Core
|
- React/Core
|
||||||
- React/RCTWebSocket (0.57.0-rc.4):
|
- React/RCTWebSocket (0.57.0):
|
||||||
- React/Core
|
- React/Core
|
||||||
- React/fishhook
|
- React/fishhook
|
||||||
- React/RCTBlob
|
- React/RCTBlob
|
||||||
- RNFirebase (5.0.0-rc1):
|
- RNFirebase (5.0.0-rc1):
|
||||||
- Firebase/Core
|
- Firebase/Core
|
||||||
- React
|
- React
|
||||||
- yoga (0.57.0-rc.4.React)
|
- yoga (0.57.0.React)
|
||||||
|
|
||||||
DEPENDENCIES:
|
DEPENDENCIES:
|
||||||
- Crashlytics (~> 3.10.7)
|
- Crashlytics (~> 3.10.7)
|
||||||
|
|||||||
@@ -6485,9 +6485,9 @@ react-deep-force-update@^1.0.0:
|
|||||||
version "1.1.2"
|
version "1.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/react-deep-force-update/-/react-deep-force-update-1.1.2.tgz#3d2ae45c2c9040cbb1772be52f8ea1ade6ca2ee1"
|
resolved "https://registry.yarnpkg.com/react-deep-force-update/-/react-deep-force-update-1.1.2.tgz#3d2ae45c2c9040cbb1772be52f8ea1ade6ca2ee1"
|
||||||
|
|
||||||
react-devtools-core@^3.2.2:
|
react-devtools-core@3.3.4:
|
||||||
version "3.3.3"
|
version "3.3.4"
|
||||||
resolved "https://registry.yarnpkg.com/react-devtools-core/-/react-devtools-core-3.3.3.tgz#3f41c5e8a61142c1022f173151ee4d4e699b81b9"
|
resolved "https://registry.yarnpkg.com/react-devtools-core/-/react-devtools-core-3.3.4.tgz#9e497a94b73413b91774bf3e3197e539d5f9a21d"
|
||||||
dependencies:
|
dependencies:
|
||||||
shell-quote "^1.6.1"
|
shell-quote "^1.6.1"
|
||||||
ws "^3.3.1"
|
ws "^3.3.1"
|
||||||
@@ -6522,9 +6522,9 @@ react-motion@^0.5.2:
|
|||||||
prop-types "^15.5.8"
|
prop-types "^15.5.8"
|
||||||
raf "^3.1.0"
|
raf "^3.1.0"
|
||||||
|
|
||||||
react-native@^0.57.0-rc.4:
|
react-native@^0.57.0:
|
||||||
version "0.57.0-rc.4"
|
version "0.57.0"
|
||||||
resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.57.0-rc.4.tgz#d8227aad5b7a7f49d066fccb02b36938a3dd4506"
|
resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.57.0.tgz#b0d098bbd5393fc3c079f8d7c2a8bf9a10b86b9e"
|
||||||
dependencies:
|
dependencies:
|
||||||
absolute-path "^0.0.0"
|
absolute-path "^0.0.0"
|
||||||
art "^0.10.0"
|
art "^0.10.0"
|
||||||
@@ -6565,7 +6565,7 @@ react-native@^0.57.0-rc.4:
|
|||||||
promise "^7.1.1"
|
promise "^7.1.1"
|
||||||
prop-types "^15.5.8"
|
prop-types "^15.5.8"
|
||||||
react-clone-referenced-element "^1.0.1"
|
react-clone-referenced-element "^1.0.1"
|
||||||
react-devtools-core "^3.2.2"
|
react-devtools-core "3.3.4"
|
||||||
react-timer-mixin "^0.13.2"
|
react-timer-mixin "^0.13.2"
|
||||||
regenerator-runtime "^0.11.0"
|
regenerator-runtime "^0.11.0"
|
||||||
rimraf "^2.5.4"
|
rimraf "^2.5.4"
|
||||||
|
|||||||
Reference in New Issue
Block a user