From 3a5523d71642d3f06538f11368436d8a298e0b4c Mon Sep 17 00:00:00 2001 From: James Baxley Date: Fri, 28 Apr 2017 23:23:06 -0400 Subject: [PATCH] failing test for #170 (again) --- npm-debug.log.3540064644 | 24 +++++++++++ .../react-web/client/graphql/queries.test.tsx | 41 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 npm-debug.log.3540064644 diff --git a/npm-debug.log.3540064644 b/npm-debug.log.3540064644 new file mode 100644 index 0000000000..cfd8b83b9a --- /dev/null +++ b/npm-debug.log.3540064644 @@ -0,0 +1,24 @@ +0 info it worked if it ends with ok +1 verbose cli [ '/usr/bin/nodejs', '/usr/bin/npm', 'run', 'test--watch' ] +2 info using npm@3.10.10 +3 info using node@v6.10.0 +4 verbose stack Error: missing script: test--watch +4 verbose stack at run (/usr/lib/node_modules/npm/lib/run-script.js:151:19) +4 verbose stack at /usr/lib/node_modules/npm/lib/run-script.js:61:5 +4 verbose stack at /usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:356:5 +4 verbose stack at checkBinReferences_ (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:320:45) +4 verbose stack at final (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:354:3) +4 verbose stack at then (/usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:124:5) +4 verbose stack at /usr/lib/node_modules/npm/node_modules/read-package-json/read-json.js:311:12 +4 verbose stack at /usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16 +4 verbose stack at tryToString (fs.js:455:3) +4 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:442:12) +5 verbose cwd /mnt/c/Users/james.baxley/Products/apollo/react-apollo +6 error Linux 4.4.0-43-Microsoft +7 error argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "test--watch" +8 error node v6.10.0 +9 error npm v3.10.10 +10 error missing script: test--watch +11 error If you need help, you may report this error at: +11 error +12 verbose exit [ 1, true ] diff --git a/test/react-web/client/graphql/queries.test.tsx b/test/react-web/client/graphql/queries.test.tsx index d01f0cc584..b8cb6690b4 100644 --- a/test/react-web/client/graphql/queries.test.tsx +++ b/test/react-web/client/graphql/queries.test.tsx @@ -2185,6 +2185,47 @@ describe('queries', () => { expect(Object.keys((client as any).queryManager.observableQueries)).toEqual(['1']); }); + it('renders loading state correctly when recycling queries with different variables but the same result', (done) => { + const query = gql` + query remount($first: Int) { allPeople(first: $first) { people { name } } } + `; + const data = { allPeople: null }; + const variables = { first: 1 }; + const variables2 = { first: 2 }; + const networkInterface = mockNetworkInterface( + { request: { query, variables }, result: { data }, delay: 10 }, + { request: { query, variables: variables2 }, result: { data }, delay: 10 } + ); + const client = new ApolloClient({ networkInterface, addTypename: false }); + let count = 0; + let firstCount = 1; + let wrapper; + @graphql(query, { options: ({ first }) => ({ variables: { first: firstCount }})}) + class Container extends React.Component { + + componentWillReceiveProps(props) { + if (count === 0) { + expect(props.data.loading).toBe(false); // got data for first request + wrapper.unmount(); + firstCount = 2; + wrapper = renderer.create(); + } + + if (count === 1) { + expect(props.data.loading).toBe(false); // on second request + done(); + } + + count++; + } + render() { + return null; + } + }; + wrapper = renderer.create(); + + }); + it('will not try to refetch recycled `ObservableQuery`s when resetting the client store', (done) => { const query = gql`query people { allPeople(first: 1) { people { name } } }`; const data = { allPeople: { people: [ { name: 'Luke Skywalker' } ] } };