Export init function
Summary: This way we can mock it during tests. Reviewed By: jknoxville Differential Revision: D9788349 fbshipit-source-id: 55b2a61186e6294a8098db7add50fd8bbac7a680
This commit is contained in:
committed by
Facebook Github Bot
parent
5e0271cfc3
commit
fc653d8057
10
src/__mocks__/init.js
Normal file
10
src/__mocks__/init.js
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Copyright 2018-present Facebook.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* @format
|
||||
*/
|
||||
|
||||
export default function init() {
|
||||
// no-op
|
||||
}
|
||||
@@ -14,9 +14,10 @@ export {SonarBasePlugin, SonarPlugin, SonarDevicePlugin} from './plugin.js';
|
||||
export {createTablePlugin} from './createTablePlugin.js';
|
||||
export {default as SonarSidebar} from './chrome/SonarSidebar.js';
|
||||
|
||||
export * from './init.js';
|
||||
export {default} from './init.js';
|
||||
|
||||
export {default as AndroidDevice} from './devices/AndroidDevice.js';
|
||||
export {default as Device} from './devices/BaseDevice.js';
|
||||
export {default as IOSDevice} from './devices/IOSDevice.js';
|
||||
|
||||
import init from './init.js';
|
||||
|
||||
init();
|
||||
|
||||
28
src/init.js
28
src/init.js
@@ -62,16 +62,18 @@ const AppFrame = () => (
|
||||
</TooltipProvider>
|
||||
);
|
||||
|
||||
// $FlowFixMe: this element exists!
|
||||
ReactDOM.render(<AppFrame />, document.getElementById('root'));
|
||||
// $FlowFixMe: service workers exist!
|
||||
navigator.serviceWorker
|
||||
.register(
|
||||
process.env.NODE_ENV === 'production'
|
||||
? path.join(__dirname, 'serviceWorker.js')
|
||||
: './serviceWorker.js',
|
||||
)
|
||||
.then(r => {
|
||||
(r.installing || r.active).postMessage({precachedIcons});
|
||||
})
|
||||
.catch(console.error);
|
||||
export default function init() {
|
||||
// $FlowFixMe: this element exists!
|
||||
ReactDOM.render(<AppFrame />, document.getElementById('root'));
|
||||
// $FlowFixMe: service workers exist!
|
||||
navigator.serviceWorker
|
||||
.register(
|
||||
process.env.NODE_ENV === 'production'
|
||||
? path.join(__dirname, 'serviceWorker.js')
|
||||
: './serviceWorker.js',
|
||||
)
|
||||
.then(r => {
|
||||
(r.installing || r.active).postMessage({precachedIcons});
|
||||
})
|
||||
.catch(console.error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user