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

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
James Baxley committed Jun 28, 2016
1 parent fe36c44 commit da01a4e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 39 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"compile:browser": "rm -rf ./dist && mkdir ./dist && browserify ./lib/src/index.js --i react --i apollo-client -o=./dist/index.js && npm run minify:browser",
"minify:browser": "uglifyjs --compress --mangle --screw-ie8 -o=./dist/index.min.js -- ./dist/index.js",
"watch": "tsc -w",
"lint": "tslint src/*.ts* && tslint test/*.ts*",
"lint": "tslint 'src/*.ts*' && tslint 'test/*.ts*'",
"coverage": "istanbul cover ./node_modules/mocha/bin/_mocha -- --require ./test/fixtures/setup.js --reporter spec --full-trace --recursive ./lib/test",
"postcoverage": "remap-istanbul --input coverage/coverage.json --type lcovonly --output coverage/lcov.info"
},
Expand Down
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import ApolloProvider from './ApolloProvider';
import connect from './connect';
import { getData, renderToStringWithData } from './server';

export { ApolloProvider, connect, getData, renderToStringWithData };
export { ApolloProvider, connect };
71 changes: 36 additions & 35 deletions test/server/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import * as chai from 'chai';
import * as React from 'react';
import * as ReactDOM from 'react-dom/server';
import ApolloClient, { createNetworkInterface } from 'apollo-client';
import { connect, ApolloProvider, getData, renderToStringWithData } from '../../src';
import { connect, ApolloProvider } from '../../src';
import { getData, renderToStringWithData } from '../../src/server';
import 'isomorphic-fetch';

import gql from 'graphql-tag';
Expand All @@ -12,27 +13,27 @@ import mockNetworkInterface from '../mocks/mockNetworkInterface';
const { expect } = chai;

const client = new ApolloClient({
networkInterface: createNetworkInterface('https://www.graphqlhub.com/playground')
networkInterface: createNetworkInterface('https://www.graphqlhub.com/playground'),
});

describe('SSR', () => {
it('should render the expected markup', (done) => {
const Element = ({ data }) => {
return <div>{data.loading ? 'loading' : 'loaded'}</div>;
}
};

const WrappedElement = connect({
mapQueriesToProps: ({ ownProps }) => ({
mapQueriesToProps: () => ({
data: {
query: gql`
query Feed {
currentUser {
login
}
}
`
}
})
`,
},
}),
})(Element);

const component = (
Expand Down Expand Up @@ -82,7 +83,7 @@ describe('SSR', () => {
}
);

const client = new ApolloClient({
const apolloClient = new ApolloClient({
networkInterface,
});

Expand All @@ -92,11 +93,11 @@ describe('SSR', () => {
query,
ssr: true, // block during SSR render
},
})
}),
})(Element);

const app = (
<ApolloProvider client={client}>
<ApolloProvider client={apolloClient}>
<WrappedElement />
</ApolloProvider>
);
Expand Down Expand Up @@ -136,18 +137,18 @@ describe('SSR', () => {
}
);

const client = new ApolloClient({
const apolloClient = new ApolloClient({
networkInterface,
});

const WrappedElement = connect({
mapQueriesToProps: () => ({
data: { query },
})
}),
})(Element);

const app = (
<ApolloProvider client={client}>
<ApolloProvider client={apolloClient}>
<WrappedElement />
</ApolloProvider>
);
Expand Down Expand Up @@ -186,18 +187,18 @@ describe('SSR', () => {
}
);

const client = new ApolloClient({
const apolloClient = new ApolloClient({
networkInterface,
});

const WrappedElement = connect({
mapQueriesToProps: () => ({
data: { query, ssr: false },
})
}),
})(Element);

const app = (
<ApolloProvider client={client}>
<ApolloProvider client={apolloClient}>
<WrappedElement />
</ApolloProvider>
);
Expand All @@ -216,18 +217,18 @@ describe('SSR', () => {
// XXX mock all queries
it('should work on a non trivial example', function(done) {
this.timeout(10000);
const networkInterface = createNetworkInterface("http://graphql-swapi.parseapp.com/");
const client = new ApolloClient({
const networkInterface = createNetworkInterface('http://graphql-swapi.parseapp.com/');
const apolloClient = new ApolloClient({
networkInterface,
// shouldBatch: true,
});

class Film extends React.Component<any, any>{
render(){
class Film extends React.Component<any, any> {
render() {
const { data } = this.props;
if (data.loading) return null
if (data.loading) return null;
const { film } = data;
return <h6>{film.title}</h6>
return <h6>{film.title}</h6>;
}
};

Expand All @@ -248,8 +249,8 @@ describe('SSR', () => {
}),
})(Film);

class Starship extends React.Component<any, any>{
render(){
class Starship extends React.Component<any, any> {
render() {
const { data } = this.props;
if (data.loading) return null;
const { ship } = data;
Expand All @@ -265,7 +266,7 @@ describe('SSR', () => {
))}
</ul>
</div>
)
);
}
};

Expand All @@ -291,8 +292,8 @@ describe('SSR', () => {
}),
})(Starship);

class Element extends React.Component<any, any>{
render(){
class Element extends React.Component<any, any> {
render() {
const { data } = this.props;
return (
<ul>
Expand All @@ -302,7 +303,7 @@ describe('SSR', () => {
</li>
))}
</ul>
)
);
}
}

Expand All @@ -319,7 +320,7 @@ describe('SSR', () => {
}
`,
},
})
}),
})(Element);

class Planet extends React.Component<any, any> {
Expand All @@ -334,7 +335,7 @@ describe('SSR', () => {
<div key={key}>{planet.name}</div>
))}
</div>
)
);
}
}
const AllPlanetsWithData = connect({
Expand All @@ -351,14 +352,14 @@ describe('SSR', () => {
`,
},
}),
})(Planet)
})(Planet);

const Foo = () => (
<div>
<h1>Foo</h1>
<Bar />
</div>
)
);

class Bar extends React.Component<any, any> {
render() {
Expand All @@ -367,12 +368,12 @@ describe('SSR', () => {
<h2>Bar</h2>
<AllPlanetsWithData />
</div>
)
);
}
}

const app = (
<ApolloProvider client={client}>
<ApolloProvider client={apolloClient}>
<div>
<AllShipsWithData />
<hr />
Expand All @@ -391,7 +392,7 @@ describe('SSR', () => {
expect(markup).to.match(/__apollo_data__/);
done();
})
.catch(done)
.catch(done);
});
});
});
1 change: 0 additions & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
true,
"spaces"
],
"interface-name": false,
"jsdoc-format": true,
"label-position": true,
"label-undefined": true,
Expand Down

0 comments on commit da01a4e

Please sign in to comment.