mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-29 04:35:43 +08:00
@@ -38,6 +38,7 @@ module.exports = {
|
|||||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||||
'@typescript-eslint/camelcase': 'off',
|
'@typescript-eslint/camelcase': 'off',
|
||||||
'@typescript-eslint/no-empty-function': 'off',
|
'@typescript-eslint/no-empty-function': 'off',
|
||||||
|
'@typescript-eslint/ban-ts-ignore': 'warn',
|
||||||
},
|
},
|
||||||
globals: {
|
globals: {
|
||||||
__DEV__: true,
|
__DEV__: true,
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
maxConcurrency: 10,
|
maxConcurrency: 10,
|
||||||
preset: './tests/node_modules/react-native/jest-preset.js',
|
preset: './tests/node_modules/react-native/jest-preset.js',
|
||||||
setupFiles: ['./jest.setup.js'],
|
transform: {
|
||||||
testMatch: ['**/packages/**/__tests__/**/*.test.js'],
|
'^.+\\.(js)$': '<rootDir>/node_modules/babel-jest',
|
||||||
|
'\\.(ts|tsx)$': 'ts-jest',
|
||||||
|
},
|
||||||
|
setupFiles: ['./jest.setup.ts'],
|
||||||
|
testMatch: ['**/packages/**/__tests__/**/*.test.(ts|js)'],
|
||||||
modulePaths: ['node_modules', './tests/node_modules'],
|
modulePaths: ['node_modules', './tests/node_modules'],
|
||||||
testPathIgnorePatterns: ['./packages/template'],
|
testPathIgnorePatterns: ['./packages/template'],
|
||||||
|
moduleDirectories: ['node_modules', './tests/node_modules'],
|
||||||
|
moduleFileExtensions: ['ts', 'tsx', 'js'],
|
||||||
};
|
};
|
||||||
|
|||||||
10
package.json
10
package.json
@@ -34,6 +34,9 @@
|
|||||||
"format:markdown": "prettier --write \"docs/**/*.md\""
|
"format:markdown": "prettier --write \"docs/**/*.md\""
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@babel/preset-env": "7.9.5",
|
||||||
|
"@babel/preset-flow": "7.9.0",
|
||||||
|
"@types/jest": "^25.2.1",
|
||||||
"@types/react-native": "^0.62.0",
|
"@types/react-native": "^0.62.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.18.0",
|
"@typescript-eslint/eslint-plugin": "^2.18.0",
|
||||||
"@typescript-eslint/parser": "^2.18.0",
|
"@typescript-eslint/parser": "^2.18.0",
|
||||||
@@ -45,15 +48,14 @@
|
|||||||
"eslint-plugin-react": "^7.19.0",
|
"eslint-plugin-react": "^7.19.0",
|
||||||
"genversion": "^2.2.0",
|
"genversion": "^2.2.0",
|
||||||
"inquirer": "^7.1.0",
|
"inquirer": "^7.1.0",
|
||||||
|
"jest": "^25.5.1",
|
||||||
"lerna": "3.20.2",
|
"lerna": "3.20.2",
|
||||||
"prettier": "^1.19.1",
|
"prettier": "^1.19.1",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"shelljs": "^0.8.3",
|
"shelljs": "^0.8.3",
|
||||||
|
"ts-jest": "^25.4.0",
|
||||||
"typedoc": "^0.15.0",
|
"typedoc": "^0.15.0",
|
||||||
"typescript": "^3.8.3",
|
"typescript": "^3.8.3"
|
||||||
"jest": "^24.9.0",
|
|
||||||
"@babel/preset-env": "7.9.5",
|
|
||||||
"@babel/preset-flow": "7.9.0"
|
|
||||||
},
|
},
|
||||||
"workspaces": {
|
"workspaces": {
|
||||||
"packages": [
|
"packages": [
|
||||||
|
|||||||
@@ -12,8 +12,13 @@ describe('Cloud Functions', () => {
|
|||||||
describe('useFunctionsEmulator()', () => {
|
describe('useFunctionsEmulator()', () => {
|
||||||
it('useFunctionsEmulator -> uses 10.0.2.2', () => {
|
it('useFunctionsEmulator -> uses 10.0.2.2', () => {
|
||||||
functions().useFunctionsEmulator('http://localhost');
|
functions().useFunctionsEmulator('http://localhost');
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
expect(functions()._useFunctionsEmulatorOrigin).toBe('http://10.0.2.2');
|
expect(functions()._useFunctionsEmulatorOrigin).toBe('http://10.0.2.2');
|
||||||
|
|
||||||
functions().useFunctionsEmulator('http://127.0.0.1');
|
functions().useFunctionsEmulator('http://127.0.0.1');
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
expect(functions()._useFunctionsEmulatorOrigin).toBe('http://10.0.2.2');
|
expect(functions()._useFunctionsEmulatorOrigin).toBe('http://10.0.2.2');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -22,6 +27,8 @@ describe('Cloud Functions', () => {
|
|||||||
it('throws an error with an incorrect timeout', () => {
|
it('throws an error with an incorrect timeout', () => {
|
||||||
try {
|
try {
|
||||||
const app = firebase.app();
|
const app = firebase.app();
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
app.functions().httpsCallable('example', { timeout: 'test' });
|
app.functions().httpsCallable('example', { timeout: 'test' });
|
||||||
return Promise.reject(new Error('Did not throw'));
|
return Promise.reject(new Error('Did not throw'));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -11,7 +11,10 @@ describe('Performance Monitoring', () => {
|
|||||||
|
|
||||||
describe('setPerformanceCollectionEnabled', () => {
|
describe('setPerformanceCollectionEnabled', () => {
|
||||||
it('errors if not boolean', () => {
|
it('errors if not boolean', () => {
|
||||||
expect(() => perf().setPerformanceCollectionEnabled()).toThrow('must be a boolean');
|
expect(() => {
|
||||||
|
// @ts-ignore
|
||||||
|
perf().setPerformanceCollectionEnabled();
|
||||||
|
}).toThrow('must be a boolean');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -19,11 +22,14 @@ describe('Performance Monitoring', () => {
|
|||||||
it('returns an instance of Trace', () => {
|
it('returns an instance of Trace', () => {
|
||||||
const trace = perf().newTrace('invertase');
|
const trace = perf().newTrace('invertase');
|
||||||
expect(trace.constructor.name).toEqual('Trace');
|
expect(trace.constructor.name).toEqual('Trace');
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
expect(trace._identifier).toEqual('invertase');
|
expect(trace._identifier).toEqual('invertase');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('errors if identifier not a string', () => {
|
it('errors if identifier not a string', () => {
|
||||||
try {
|
try {
|
||||||
|
// @ts-ignore
|
||||||
perf().newTrace(1337);
|
perf().newTrace(1337);
|
||||||
return Promise.reject(new Error('Did not throw'));
|
return Promise.reject(new Error('Did not throw'));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -51,12 +57,17 @@ describe('Performance Monitoring', () => {
|
|||||||
it('returns an instance of HttpMetric', async () => {
|
it('returns an instance of HttpMetric', async () => {
|
||||||
const metric = perf().newHttpMetric('https://invertase.io', 'GET');
|
const metric = perf().newHttpMetric('https://invertase.io', 'GET');
|
||||||
expect(metric.constructor.name).toEqual('HttpMetric');
|
expect(metric.constructor.name).toEqual('HttpMetric');
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
expect(metric._url).toEqual('https://invertase.io');
|
expect(metric._url).toEqual('https://invertase.io');
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
expect(metric._httpMethod).toEqual('GET');
|
expect(metric._httpMethod).toEqual('GET');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('errors if url not a string', async () => {
|
it('errors if url not a string', async () => {
|
||||||
try {
|
try {
|
||||||
|
// @ts-ignore
|
||||||
perf().newHttpMetric(1337, 7331);
|
perf().newHttpMetric(1337, 7331);
|
||||||
return Promise.reject(new Error('Did not throw'));
|
return Promise.reject(new Error('Did not throw'));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -67,6 +78,7 @@ describe('Performance Monitoring', () => {
|
|||||||
|
|
||||||
it('errors if httpMethod not a string', async () => {
|
it('errors if httpMethod not a string', async () => {
|
||||||
try {
|
try {
|
||||||
|
// @ts-ignore
|
||||||
perf().newHttpMetric('https://invertase.io', 1337);
|
perf().newHttpMetric('https://invertase.io', 1337);
|
||||||
return Promise.reject(new Error('Did not throw'));
|
return Promise.reject(new Error('Did not throw'));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -79,6 +91,7 @@ describe('Performance Monitoring', () => {
|
|||||||
|
|
||||||
it('errors if httpMethod not a valid type', async () => {
|
it('errors if httpMethod not a valid type', async () => {
|
||||||
try {
|
try {
|
||||||
|
// @ts-ignore
|
||||||
perf().newHttpMetric('https://invertase.io', 'FIRE');
|
perf().newHttpMetric('https://invertase.io', 'FIRE');
|
||||||
return Promise.reject(new Error('Did not throw'));
|
return Promise.reject(new Error('Did not throw'));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -93,6 +106,7 @@ describe('Performance Monitoring', () => {
|
|||||||
describe('setPerformanceCollectionEnabled()', () => {
|
describe('setPerformanceCollectionEnabled()', () => {
|
||||||
it('errors if not boolean', async () => {
|
it('errors if not boolean', async () => {
|
||||||
try {
|
try {
|
||||||
|
// @ts-ignore
|
||||||
firebase.perf().setPerformanceCollectionEnabled();
|
firebase.perf().setPerformanceCollectionEnabled();
|
||||||
return Promise.reject(new Error('Did not throw'));
|
return Promise.reject(new Error('Did not throw'));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Reference in New Issue
Block a user