This repository has been archived by the owner on Apr 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 786
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added inital test coverage for SSR (#75)
* added inital test coverage for SSR * added timeout to ensure ssr doesn't fail * fix typings definitions * package bump
- Loading branch information
James Baxley
authored
Jun 24, 2016
1 parent
d255aa8
commit a4e1646
Showing
72 changed files
with
472 additions
and
27,316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
LODASH | ||
*/ | ||
declare module 'lodash.isobject' { | ||
import main = require('~lodash/index'); | ||
export = main.isObject; | ||
} | ||
|
||
declare module 'lodash.isequal' { | ||
import main = require('~lodash/index'); | ||
export = main.isEqual; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
/// <reference path="../../typings/main.d.ts" /> | ||
|
||
import * as React from 'react'; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
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 } from '../../src'; | ||
import 'isomorphic-fetch'; | ||
|
||
// Globally register gql template literal tag | ||
import gql from 'apollo-client/gql'; | ||
|
||
const { expect } = chai; | ||
|
||
const client = new ApolloClient({ | ||
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 }) => ({ | ||
data: { | ||
query: gql` | ||
query Feed { | ||
currentUser { | ||
login | ||
} | ||
} | ||
` | ||
} | ||
}) | ||
})(Element); | ||
|
||
const component = ( | ||
<ApolloProvider client={client}> | ||
<WrappedElement /> | ||
</ApolloProvider> | ||
); | ||
|
||
try { | ||
const data = ReactDOM.renderToString(component); | ||
expect(data).to.match(/loading/); | ||
// We do a timeout to ensure the rest of the application does not fail | ||
// after the render | ||
setTimeout(() => { | ||
done(); | ||
}, 1000); | ||
} catch (e) { | ||
done(e); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.