From fd0763fa0bed2e71f9b6e07be4195a2b83755d46 Mon Sep 17 00:00:00 2001 From: Dirk-Jan Rutten Date: Wed, 27 Dec 2017 13:14:28 +0100 Subject: [PATCH] Converted test-utils test to typescript (#1475) --- Changelog.md | 3 ++- .../test-utils.test.tsx.snap} | 0 ...test-utils.test.js => test-utils.test.tsx} | 26 ++++++------------- 3 files changed, 10 insertions(+), 19 deletions(-) rename test/{test-utils/__snapshots__/test-utils.test.js.snap => __snapshots__/test-utils.test.tsx.snap} (100%) rename test/{test-utils/test-utils.test.js => test-utils.test.tsx} (87%) diff --git a/Changelog.md b/Changelog.md index 59cfe90d8e..56c4d746e1 100644 --- a/Changelog.md +++ b/Changelog.md @@ -26,7 +26,8 @@ first three params (`TChildProps` can be derived). [#1402](https://github.com/ap - Update rollup configurations, refine package exports [#1467](https://github.com/apollographql/react-apollo/pull/1467) - Removed unused gzip script [#1468](https://github.com/apollographql/react-apollo/pull/1468) - Minify umd and ensure umd name consistency [#1469](https://github.com/apollographql/react-apollo/pull/1469) - + - Converted `test/test-utils/test-utils.test.js` to `test/test-utils.test.tsx` [#1475](https://github.com/apollographql/react-apollo/pull/1475) + ### 2.0.4 - rolled back on the lodash-es changes from [#1344](https://github.com/apollographql/react-apollo/pull/1344) due to build diff --git a/test/test-utils/__snapshots__/test-utils.test.js.snap b/test/__snapshots__/test-utils.test.tsx.snap similarity index 100% rename from test/test-utils/__snapshots__/test-utils.test.js.snap rename to test/__snapshots__/test-utils.test.tsx.snap diff --git a/test/test-utils/test-utils.test.js b/test/test-utils.test.tsx similarity index 87% rename from test/test-utils/test-utils.test.js rename to test/test-utils.test.tsx index 7ad26b3983..4152a3ee7b 100644 --- a/test/test-utils/test-utils.test.js +++ b/test/test-utils.test.tsx @@ -1,11 +1,11 @@ -import React, { Component } from 'react'; +import * as React from 'react'; +import * as renderer from 'react-test-renderer'; import { InMemoryCache } from 'apollo-cache-inmemory'; import ApolloClient from 'apollo-client'; import gql from 'graphql-tag'; -import renderer from 'react-test-renderer'; -import { graphql } from '../../src'; -import { MockedProvider, mockSingleLink } from '../../src/test-utils'; +import { graphql } from '../src'; +import { MockedProvider, mockSingleLink } from '../src/test-utils'; const variables = { username: 'mock_username', @@ -41,7 +41,7 @@ const withUser = graphql(queryWithoutTypename, { }); it('mocks the data and adds the typename to the query', done => { - class Container extends Component { + class Container extends React.Component { componentWillReceiveProps(nextProps) { try { expect(nextProps.data.user).toMatchSnapshot(); @@ -76,7 +76,7 @@ it('mocks the data and adds the typename to the query', done => { }); it('mocks a network error', done => { - class Container extends Component { + class Container extends React.Component { componentWillReceiveProps(nextProps) { try { expect(nextProps.data.error).toEqual( @@ -113,7 +113,7 @@ it('mocks a network error', done => { }); it('mocks the data without adding the typename', done => { - class Container extends Component { + class Container extends React.Component { componentWillReceiveProps(nextProps) { try { expect(nextProps.data.user).toMatchSnapshot(); @@ -160,7 +160,7 @@ it('allows for passing a custom client', done => { cache: new InMemoryCache(), }); - class Container extends Component { + class Container extends React.Component { componentWillReceiveProps(nextProps) { try { expect(nextProps.data.user).toMatchSnapshot(); @@ -177,16 +177,6 @@ it('allows for passing a custom client', done => { const ContainerWithData = withUser(Container); - const mocks = [ - { - request: { - query, - variables, - }, - result: { data: { user } }, - }, - ]; - renderer.create(