Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
cartogram committed Aug 28, 2019
1 parent f4aac86 commit fefaf83
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
1 change: 0 additions & 1 deletion packages/react-effect/src/server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {EffectContext} from './context';
import {EffectManager} from './manager';
import {Pass} from './types';

export {Pass};
export {Effect} from './Effect';

interface Options {
Expand Down
10 changes: 5 additions & 5 deletions packages/react-server/src/render/render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
NetworkContext,
NetworkManager,
} from '@shopify/react-network/server';
import {extract, Pass} from '@shopify/react-effect/server';
import {ArgumentAtIndex} from '@shopify/useful-types';
import {extract} from '@shopify/react-effect/server';
import {
AsyncAssetContext,
AsyncAssetManager,
Expand All @@ -26,10 +27,9 @@ export type RenderContext = Context & {
};
export type RenderFunction = (ctx: RenderContext) => React.ReactElement<any>;

export interface Options {
afterEachPass?(pass: Pass): any;
betweenEachPass?(pass: Pass): any;
}
type Options = Partial<
Pick<ArgumentAtIndex<typeof extract, 1>, 'afterEachPass' | 'betweenEachPass'>
>;

/**
* Creates a Koa middleware for rendering an `@shopify/react-html` based React application defined by `options.render`.
Expand Down
8 changes: 3 additions & 5 deletions packages/react-server/src/render/test/render.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('createRender', () => {
});

describe('afterEachPass()', () => {
it('is called with the current pass object', async () => {
it('is called in the render middleware', async () => {
const ctx = createMockContext();
const afterEachPass = jest.fn();
const renderFunction = createRender(() => <>Markup</>, {afterEachPass});
Expand All @@ -69,7 +69,7 @@ describe('createRender', () => {
});

describe('betweenEachPass()', () => {
it('is called for each pass with current pass object', async () => {
it('is called in the render middleware', async () => {
const ctx = createMockContext();
const betweenEachPass = jest.fn();
const renderFunction = createRender(
Expand All @@ -85,9 +85,7 @@ describe('createRender', () => {

await renderFunction(ctx);

// 4 is used here because the default maxPasses
// is 5 which allows 4 `betweenEachPass()` calls
expect(betweenEachPass).toHaveBeenCalledTimes(4);
expect(betweenEachPass.mock.calls.length).toBeGreaterThanOrEqual(1);
});
});
});

0 comments on commit fefaf83

Please sign in to comment.