Skip to content

Commit

Permalink
Merge branch 'main' into nocheck
Browse files Browse the repository at this point in the history
  • Loading branch information
drewatk authored Aug 1, 2024
2 parents 5f86e72 + 8ba8b9f commit 0040f06
Show file tree
Hide file tree
Showing 9 changed files with 696 additions and 610 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,12 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2023-11-11
# Should stay in sync with tools/third-party/rustfmt/.rustfmt-version
toolchain: nightly-2024-07-28
override: true
components: rustfmt
- name: "rustfmt"
run: grep -r --include "*.rs" --files-without-match "@generated" crates | xargs rustfmt --check --config="skip_children=true"
run: grep -r --include "*.rs" --files-without-match $'\x40generated' crates | xargs rustfmt --check --config="skip_children=true"
working-directory: ./compiler/

build-compiler:
Expand Down

This file was deleted.

114 changes: 67 additions & 47 deletions packages/react-relay/__tests__/ReactRelayTestMocker-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,22 @@ describe('ReactRelayTestMocker', () => {
/>
);

const tree = ReactTestRenderer.create(toRender);
let tree;
ReactTestRenderer.act(() => {
tree = ReactTestRenderer.create(toRender);
});

expect(JSON.stringify(tree.toJSON())).toEqual(
expect(JSON.stringify(tree?.toJSON())).toEqual(
expect.stringContaining('My name is ' + name),
);

expect(JSON.stringify(tree.toJSON())).toEqual(
expect(JSON.stringify(tree?.toJSON())).toEqual(
expect.stringContaining('Birth month is 1'),
);

tree.unmount();
ReactTestRenderer.act(() => {
tree.unmount();
});
writer.unsetDefault(testQueryDefault);
writer.unsetDefault(nestedQueryDefault);
});
Expand All @@ -201,37 +206,49 @@ describe('ReactRelayTestMocker', () => {
/>
);

let tree = ReactTestRenderer.create(toRender);
expect(tree.toJSON()).toMatchSnapshot();

writer.networkWrite({
query: ReactRelayTestMockerTestQuery,
payload: {data: payload},
let tree;
ReactTestRenderer.act(() => {
tree = ReactTestRenderer.create(toRender);
});
expect(tree?.toJSON()).toMatchSnapshot();
ReactTestRenderer.act(() => {
writer.networkWrite({
query: ReactRelayTestMockerTestQuery,
payload: {data: payload},
});
});
ReactTestRenderer.act(() => {
jest.runAllTimers();
});
jest.runAllTimers();
expect(JSON.stringify(tree.toJSON())).toEqual(
expect(JSON.stringify(tree?.toJSON())).toEqual(
expect.stringContaining('My name is ' + name),
);
expect(tree.toJSON()).toMatchSnapshot();
tree.unmount();

// rerender to test error behavior
tree = ReactTestRenderer.create(toRender);

writer.networkWrite({
query: ReactRelayTestMockerTestQuery,
payload: {
data: null,
errors: [
{
message: 'Uh oh',
},
],
},
expect(tree?.toJSON()).toMatchSnapshot();
ReactTestRenderer.act(() => {
tree.unmount();
// rerender to test error behavior
tree = ReactTestRenderer.create(toRender);
});
ReactTestRenderer.act(() => {
writer.networkWrite({
query: ReactRelayTestMockerTestQuery,
payload: {
data: null,
errors: [
{
message: 'Uh oh',
},
],
},
});
});
ReactTestRenderer.act(() => {
jest.runAllTimers();
});
expect(tree?.toJSON()).toMatchSnapshot();
ReactTestRenderer.act(() => {
tree.unmount();
});
jest.runAllTimers();
expect(tree.toJSON()).toMatchSnapshot();
tree.unmount();
});

it('properly updates a component wrapped in a fragment container', () => {
Expand All @@ -252,16 +269,19 @@ describe('ReactRelayTestMocker', () => {
variables,
});

const tree = ReactTestRenderer.create(
<RelayTestRenderer
environment={environment}
query={q}
variables={variables}>
<Component />
</RelayTestRenderer>,
);
let tree;
ReactTestRenderer.act(() => {
tree = ReactTestRenderer.create(
<RelayTestRenderer
environment={environment}
query={q}
variables={variables}>
<Component />
</RelayTestRenderer>,
);
});

expect(tree.toJSON()).toMatchSnapshot();
expect(tree?.toJSON()).toMatchSnapshot();

const newPayload = {
me: {
Expand All @@ -270,14 +290,14 @@ describe('ReactRelayTestMocker', () => {
name: 'new name',
},
};

writer.dataWrite({
query: ReactRelayTestMockerTestFragContainerTestQuery,
payload: {data: newPayload},
variables,
ReactTestRenderer.act(() => {
writer.dataWrite({
query: ReactRelayTestMockerTestFragContainerTestQuery,
payload: {data: newPayload},
variables,
});
});

expect(tree.toJSON()).toMatchSnapshot();
expect(tree?.toJSON()).toMatchSnapshot();
});
});
});
Loading

0 comments on commit 0040f06

Please sign in to comment.