mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
Added Jest test to verify UMD API-forwarding for scheduling package (#13532)
* Added Jest test to verify UMD API-forwarding for scheduling package * Added separate dev/prod UMD bundles for scheduler package
This commit is contained in:
@@ -63,8 +63,8 @@
|
||||
</li>
|
||||
</ol>
|
||||
<!-- Load the tracking API before react to test that it's lazily evaluated -->
|
||||
<script src="../../build/node_modules/react-scheduler/umd/react-scheduler.js"></script>
|
||||
<script src="../../build/node_modules/react-scheduler/umd/react-scheduler-tracking.js"></script>
|
||||
<script src="../../build/node_modules/react-scheduler/umd/react-scheduler.development.js"></script>
|
||||
<script src="../../build/node_modules/react-scheduler/umd/react-scheduler-tracking.development.js"></script>
|
||||
<script src="../../build/node_modules/react/umd/react.development.js"></script>
|
||||
<script src="../../build/node_modules/react-dom/umd/react-dom.development.js"></script>
|
||||
<script src="./script.js"></script>
|
||||
|
||||
95
packages/react-scheduler/npm/umd/react-scheduler-tracking.production.min.js
vendored
Normal file
95
packages/react-scheduler/npm/umd/react-scheduler-tracking.production.min.js
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* @license React
|
||||
*
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
(function(global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined'
|
||||
? (module.exports = factory(require('react')))
|
||||
: typeof define === 'function' && define.amd // eslint-disable-line no-undef
|
||||
? define(['react'], factory) // eslint-disable-line no-undef
|
||||
: (global.ReactSchedulerTracking = factory(global));
|
||||
})(this, function(global) {
|
||||
function __getInteractionsRef() {
|
||||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.__getInteractionsRef.apply(
|
||||
this,
|
||||
arguments
|
||||
);
|
||||
}
|
||||
|
||||
function __getSubscriberRef() {
|
||||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.__getSubscriberRef.apply(
|
||||
this,
|
||||
arguments
|
||||
);
|
||||
}
|
||||
|
||||
function unstable_clear() {
|
||||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.unstable_clear.apply(
|
||||
this,
|
||||
arguments
|
||||
);
|
||||
}
|
||||
|
||||
function unstable_getCurrent() {
|
||||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.unstable_getCurrent.apply(
|
||||
this,
|
||||
arguments
|
||||
);
|
||||
}
|
||||
|
||||
function unstable_getThreadID() {
|
||||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.unstable_getThreadID.apply(
|
||||
this,
|
||||
arguments
|
||||
);
|
||||
}
|
||||
|
||||
function unstable_subscribe() {
|
||||
// eslint-disable-next-line max-len
|
||||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.unstable_subscribe.apply(
|
||||
this,
|
||||
arguments
|
||||
);
|
||||
}
|
||||
|
||||
function unstable_track() {
|
||||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.unstable_track.apply(
|
||||
this,
|
||||
arguments
|
||||
);
|
||||
}
|
||||
|
||||
function unstable_unsubscribe() {
|
||||
// eslint-disable-next-line max-len
|
||||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.unstable_unsubscribe.apply(
|
||||
this,
|
||||
arguments
|
||||
);
|
||||
}
|
||||
|
||||
function unstable_wrap() {
|
||||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.SchedulerTracking.unstable_wrap.apply(
|
||||
this,
|
||||
arguments
|
||||
);
|
||||
}
|
||||
|
||||
return Object.freeze({
|
||||
__getInteractionsRef: __getInteractionsRef,
|
||||
__getSubscriberRef: __getSubscriberRef,
|
||||
unstable_clear: unstable_clear,
|
||||
unstable_getCurrent: unstable_getCurrent,
|
||||
unstable_getThreadID: unstable_getThreadID,
|
||||
unstable_subscribe: unstable_subscribe,
|
||||
unstable_track: unstable_track,
|
||||
unstable_unsubscribe: unstable_unsubscribe,
|
||||
unstable_wrap: unstable_wrap,
|
||||
});
|
||||
});
|
||||
45
packages/react-scheduler/npm/umd/react-scheduler.production.min.js
vendored
Normal file
45
packages/react-scheduler/npm/umd/react-scheduler.production.min.js
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* @license React
|
||||
*
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
(function(global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined'
|
||||
? (module.exports = factory(require('react')))
|
||||
: typeof define === 'function' && define.amd // eslint-disable-line no-undef
|
||||
? define(['react'], factory) // eslint-disable-line no-undef
|
||||
: (global.ReactScheduler = factory(global));
|
||||
})(this, function(global) {
|
||||
function unstable_now() {
|
||||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_now.apply(
|
||||
this,
|
||||
arguments
|
||||
);
|
||||
}
|
||||
|
||||
function unstable_scheduleWork() {
|
||||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_scheduleWork.apply(
|
||||
this,
|
||||
arguments
|
||||
);
|
||||
}
|
||||
|
||||
function unstable_cancelScheduledWork() {
|
||||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_cancelScheduledWork.apply(
|
||||
this,
|
||||
arguments
|
||||
);
|
||||
}
|
||||
|
||||
return Object.freeze({
|
||||
unstable_now: unstable_now,
|
||||
unstable_scheduleWork: unstable_scheduleWork,
|
||||
unstable_cancelScheduledWork: unstable_cancelScheduledWork,
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @jest-environment node
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
describe('Scheduling UMD bundle', () => {
|
||||
beforeEach(() => {
|
||||
// Fool SECRET_INTERNALS object into including UMD forwarding methods.
|
||||
global.__UMD__ = true;
|
||||
|
||||
jest.resetModules();
|
||||
});
|
||||
|
||||
function compareAPIS(apis) {
|
||||
apis = apis.map(api => Object.keys(api).sort());
|
||||
for (let i = 1; i < apis.length; i++) {
|
||||
expect(apis[0]).toEqual(apis[i]);
|
||||
}
|
||||
}
|
||||
|
||||
it('should define the same scheduling API', () => {
|
||||
const umdAPIDev = require('../../npm/umd/react-scheduler.development');
|
||||
const umdAPIProd = require('../../npm/umd/react-scheduler.production.min');
|
||||
const cjsAPI = require('../../index');
|
||||
const secretAPI = require('react/src/ReactSharedInternals').default;
|
||||
compareAPIS([umdAPIDev, umdAPIProd, cjsAPI, secretAPI.Scheduler]);
|
||||
});
|
||||
|
||||
it('should define the same tracking API', () => {
|
||||
const umdAPIDev = require('../../npm/umd/react-scheduler-tracking.development');
|
||||
const umdAPIProd = require('../../npm/umd/react-scheduler-tracking.production.min');
|
||||
const cjsAPI = require('../../tracking');
|
||||
const secretAPI = require('react/src/ReactSharedInternals').default;
|
||||
compareAPIS([umdAPIDev, umdAPIProd, cjsAPI, secretAPI.SchedulerTracking]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user