Skip to content

Commit 611d3b9

Browse files
linting
1 parent 44534d9 commit 611d3b9

File tree

3 files changed

+26
-17
lines changed

3 files changed

+26
-17
lines changed

node_package/tests/RSCClientRoot.test.jsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ import { createNodeReadableStream } from './testUtils';
1919
// const __filename = fileURLToPath(import.meta.url);
2020
// const __dirname = path.dirname(__filename);
2121

22-
import RSCClientRoot, {resetRenderCache } from '../src/RSCClientRoot';
22+
import RSCClientRoot, { resetRenderCache } from '../src/RSCClientRoot';
2323

2424
enableFetchMocks();
2525

2626
describe('RSCClientRoot', () => {
2727
beforeEach(() => {
2828
jest.clearAllMocks();
29-
29+
3030
jest.resetModules();
3131
resetRenderCache();
3232
});
3333

3434
it('throws error when React.use is not defined', () => {
3535
jest.mock('react', () => ({
3636
...jest.requireActual('react'),
37-
use: undefined
37+
use: undefined,
3838
}));
3939

4040
expect(() => {
@@ -44,7 +44,12 @@ describe('RSCClientRoot', () => {
4444
});
4545

4646
const mockRSCRequest = (rscRenderingUrlPath = 'rsc-render') => {
47-
const chunksDirectory = path.join(__dirname, 'fixtures', 'rsc-payloads', 'simple-shell-with-async-component');
47+
const chunksDirectory = path.join(
48+
__dirname,
49+
'fixtures',
50+
'rsc-payloads',
51+
'simple-shell-with-async-component',
52+
);
4853
const chunk1 = JSON.parse(fs.readFileSync(path.join(chunksDirectory, 'chunk1.json'), 'utf8'));
4954
const chunk2 = JSON.parse(fs.readFileSync(path.join(chunksDirectory, 'chunk2.json'), 'utf8'));
5055

@@ -53,7 +58,7 @@ describe('RSCClientRoot', () => {
5358

5459
const props = {
5560
componentName: 'TestComponent',
56-
rscRenderingUrlPath
61+
rscRenderingUrlPath,
5762
};
5863

5964
const { rerender } = render(<RSCClientRoot {...props} />);
@@ -64,8 +69,8 @@ describe('RSCClientRoot', () => {
6469
pushSecondChunk: () => push(JSON.stringify(chunk2)),
6570
pushCustomChunk: (chunk) => push(chunk),
6671
endStream: () => push(null),
67-
}
68-
}
72+
};
73+
};
6974

7075
it('fetches and caches component data', async () => {
7176
const { rerender, pushFirstChunk, pushSecondChunk, endStream } = mockRSCRequest();

node_package/tests/fixtures/rsc-payloads/simple-shell-with-async-component/chunk2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
"consoleReplayScript": "\n\u003cscript id=\"consoleReplayLog\"\u003e\nconsole.log.apply(console, [\"[SERVER] Console log at second chunk\"]);\n\u003c/script\u003e",
44
"hasErrors": false,
55
"isShellReady": true
6-
}
6+
}

node_package/tests/jest.setup.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,19 @@ if (typeof window !== 'undefined') {
2525
// Note: Node's Readable stream exists in node 'stream' built-in module, can be imported as `import { Readable } from 'stream'`
2626
jest.mock('../src/utils', () => ({
2727
...jest.requireActual('../src/utils'),
28-
fetch: (...args) => jest.requireActual('../src/utils').fetch(...args).then(res => {
29-
const originalBody = res.body;
30-
if (originalBody instanceof Readable) {
31-
Object.defineProperty(res, 'body', {
32-
value: Readable.toWeb(originalBody),
33-
});
34-
}
35-
return res;
36-
}),
28+
fetch: (...args) =>
29+
jest
30+
.requireActual('../src/utils')
31+
.fetch(...args)
32+
.then((res) => {
33+
const originalBody = res.body;
34+
if (originalBody instanceof Readable) {
35+
Object.defineProperty(res, 'body', {
36+
value: Readable.toWeb(originalBody),
37+
});
38+
}
39+
return res;
40+
}),
3741
}));
3842

3943
global.TextEncoder = TextEncoder;

0 commit comments

Comments
 (0)