Skip to content

Commit

Permalink
SchedulerMock.unstable_yieldValue -> SchedulerMock.log
Browse files Browse the repository at this point in the history
(This only affects our own internal repo; it's not a public API.)

I think most of us agree this is a less confusing name. It's possible
someone will confuse it with `console.log`. If that becomes a problem
we can warn in dev or something.
  • Loading branch information
acdlite committed Mar 4, 2023
1 parent 0cba581 commit cb2d008
Show file tree
Hide file tree
Showing 88 changed files with 1,989 additions and 2,519 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const Scheduler = require('scheduler/unstable_mock');
describe('ReactInternalTestUtils', () => {
test('waitFor', async () => {
const Yield = ({id}) => {
Scheduler.unstable_yieldValue(id);
Scheduler.log(id);
return id;
};

Expand All @@ -51,7 +51,7 @@ describe('ReactInternalTestUtils', () => {

test('waitForAll', async () => {
const Yield = ({id}) => {
Scheduler.unstable_yieldValue(id);
Scheduler.log(id);
return id;
};

Expand All @@ -72,7 +72,7 @@ describe('ReactInternalTestUtils', () => {

test('waitForThrow', async () => {
const Yield = ({id}) => {
Scheduler.unstable_yieldValue(id);
Scheduler.log(id);
return id;
};

Expand Down Expand Up @@ -113,7 +113,7 @@ describe('ReactInternalTestUtils', () => {
function App({prop}) {
const deferred = useDeferredValue(prop);
const text = `Urgent: ${prop}, Deferred: ${deferred}`;
Scheduler.unstable_yieldValue(text);
Scheduler.log(text);
return text;
}

Expand All @@ -137,7 +137,7 @@ describe('ReactInternalTestUtils', () => {

test('assertLog', async () => {
const Yield = ({id}) => {
Scheduler.unstable_yieldValue(id);
Scheduler.log(id);
return id;
};

Expand Down
24 changes: 10 additions & 14 deletions packages/react-cache/src/__tests__/ReactCacheOld-test.internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,12 @@ describe('ReactCache', () => {
listeners = [{resolve, reject}];
setTimeout(() => {
if (textResourceShouldFail) {
Scheduler.unstable_yieldValue(
`Promise rejected [${text}]`,
);
Scheduler.log(`Promise rejected [${text}]`);
status = 'rejected';
value = new Error('Failed to load: ' + text);
listeners.forEach(listener => listener.reject(value));
} else {
Scheduler.unstable_yieldValue(
`Promise resolved [${text}]`,
);
Scheduler.log(`Promise resolved [${text}]`);
status = 'resolved';
value = text;
listeners.forEach(listener => listener.resolve(value));
Expand Down Expand Up @@ -93,21 +89,21 @@ describe('ReactCache', () => {
});

function Text(props) {
Scheduler.unstable_yieldValue(props.text);
Scheduler.log(props.text);
return props.text;
}

function AsyncText(props) {
const text = props.text;
try {
TextResource.read([props.text, props.ms]);
Scheduler.unstable_yieldValue(text);
Scheduler.log(text);
return text;
} catch (promise) {
if (typeof promise.then === 'function') {
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
Scheduler.log(`Suspend! [${text}]`);
} else {
Scheduler.unstable_yieldValue(`Error! [${text}]`);
Scheduler.log(`Error! [${text}]`);
}
throw promise;
}
Expand Down Expand Up @@ -171,7 +167,7 @@ describe('ReactCache', () => {
});

function App() {
Scheduler.unstable_yieldValue('App');
Scheduler.log('App');
return BadTextResource.read(['Hi', 100]);
}

Expand Down Expand Up @@ -322,13 +318,13 @@ describe('ReactCache', () => {
const text = props.text;
try {
const actualText = BadTextResource.read([props.text, props.ms]);
Scheduler.unstable_yieldValue(actualText);
Scheduler.log(actualText);
return actualText;
} catch (promise) {
if (typeof promise.then === 'function') {
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
Scheduler.log(`Suspend! [${text}]`);
} else {
Scheduler.unstable_yieldValue(`Error! [${text}]`);
Scheduler.log(`Error! [${text}]`);
}
throw promise;
}
Expand Down
8 changes: 4 additions & 4 deletions packages/react-client/src/__tests__/ReactFlight-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ describe('ReactFlight', () => {
}

function ClientDoubler({el}) {
Scheduler.unstable_yieldValue('ClientDoubler');
Scheduler.log('ClientDoubler');
return (
<>
{el}
Expand Down Expand Up @@ -990,10 +990,10 @@ describe('ReactFlight', () => {

function Bar() {
if (!promise.unsuspend) {
Scheduler.unstable_yieldValue('suspended');
Scheduler.log('suspended');
throw promise;
}
Scheduler.unstable_yieldValue('rendered');
Scheduler.log('rendered');
const context = React.useContext(ServerContext);
return context;
}
Expand Down Expand Up @@ -1027,7 +1027,7 @@ describe('ReactFlight', () => {
);

function ClientBar() {
Scheduler.unstable_yieldValue('ClientBar');
Scheduler.log('ClientBar');
const context = React.useContext(ServerContext);
return <span>{context}</span>;
}
Expand Down
Loading

0 comments on commit cb2d008

Please sign in to comment.