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

Commit

Permalink
Make mock links mock parameter readonly (#2284)
Browse files Browse the repository at this point in the history
* Make mock links mock parameter readonly

Since mocks are not modified at runtime, allow readonly mock lists

* Changelog update
  • Loading branch information
amacleay authored and hwillson committed Aug 22, 2018
1 parent 0836918 commit a6021bb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
- Allow a custom `cache` object to be passed into the test-utils
`MockedProvider`. <br/>
[@palmfjord](https://github.com/palmfjord) in [#2254](https://github.com/apollographql/react-apollo/pull/2254)
- Make the `MockedProvider` `mocks` prop read only. <br/>
[@amacleay](https://github.com/amacleay) in [#2284](https://github.com/apollographql/react-apollo/pull/2284)

## 2.1.11 (August 9, 2018)

Expand Down
2 changes: 1 addition & 1 deletion src/test-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class MockLink extends ApolloLink {
public addTypename: Boolean = true;
private mockedResponsesByKey: { [key: string]: MockedResponse[] } = {};

constructor(mockedResponses: MockedResponse[], addTypename: Boolean = true) {
constructor(mockedResponses: ReadonlyArray<MockedResponse>, addTypename: Boolean = true) {
super();
this.addTypename = addTypename;
if (mockedResponses)
Expand Down
2 changes: 1 addition & 1 deletion src/test-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ApolloCache } from 'apollo-cache';
export * from './test-links';

export interface MockedProviderProps<TSerializedCache = {}> {
mocks?: MockedResponse[];
mocks?: ReadonlyArray<MockedResponse>;
addTypename?: boolean;
defaultOptions?: DefaultOptions;
cache?: ApolloCache<TSerializedCache>;
Expand Down
3 changes: 2 additions & 1 deletion test/test-utils.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import gql from 'graphql-tag';

import { graphql, ChildProps } from '../src';
import { MockedProvider, mockSingleLink } from '../src/test-utils';
import { MockedResponse } from '../src/test-links';
import { DocumentNode } from 'graphql';

const variables = {
Expand Down Expand Up @@ -53,7 +54,7 @@ const withUser = graphql<Variables, Data, Variables>(query, {
}),
});

const mocks = [
const mocks: ReadonlyArray<MockedResponse> = [
{
request: {
query,
Expand Down

0 comments on commit a6021bb

Please sign in to comment.