Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Converted test-utils test to typescript #1475

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 8 additions & 18 deletions test/test-utils/test-utils.test.js → test/test-utils.test.tsx
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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(
<MockedProvider client={client}>
<ContainerWithData {...variables} />
Expand Down