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

Commit

Permalink
Converted test-utils test to typescript (#1475)
Browse files Browse the repository at this point in the history
  • Loading branch information
excitement-engineer committed Dec 27, 2017
1 parent 0685f8d commit fd0763f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
3 changes: 2 additions & 1 deletion Changelog.md
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
@@ -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

0 comments on commit fd0763f

Please sign in to comment.