File tree Expand file tree Collapse file tree 2 files changed +67
-0
lines changed
Expand file tree Collapse file tree 2 files changed +67
-0
lines changed Original file line number Diff line number Diff line change 1+ import React , { Component } from 'react'
2+ import { RingLoader } from 'react-spinners'
3+ import { Container } from 'semantic-ui-react'
4+ import axios from 'axios'
5+ import ReactHtmlParser from 'react-html-parser'
6+
7+ export default class GettingStartedPage extends Component {
8+ state = { gettingStartedPage : null }
9+
10+ componentDidMount ( ) {
11+ axios . get ( 'api/v1/static/getting-started' )
12+ . then ( response => {
13+ this . setState ( { gettingStartedPage : response . data } )
14+ } )
15+ }
16+
17+ render ( ) {
18+ let { gettingStartedPage } = this . state
19+ if ( gettingStartedPage ) {
20+ return (
21+ < Container >
22+ < div >
23+ { ReactHtmlParser ( gettingStartedPage ) }
24+ </ div >
25+ </ Container >
26+ )
27+ } else {
28+ return (
29+ < Container >
30+ < RingLoader sizeUnit = { 'px' } size = { 200 } color = { '#34495E' } />
31+ </ Container >
32+ )
33+ }
34+ }
35+ }
Original file line number Diff line number Diff line change 1+ import React from 'react'
2+ import { mount } from 'enzyme'
3+ import GettingStartedPage from '../../containers/GettingStartedPage'
4+ import moxios from 'moxios'
5+
6+ describe ( 'GettingStartedPage' , ( ) => {
7+ let wrapper
8+ beforeEach ( ( ) => {
9+ moxios . install ( )
10+ wrapper = mount ( < GettingStartedPage /> )
11+ } )
12+ afterEach ( ( ) => {
13+ moxios . uninstall ( )
14+ } )
15+ it ( 'fetches the getting started page after component mounts' , done => {
16+ expect . assertions ( 1 )
17+ moxios . wait ( ( ) => {
18+ let request = moxios . requests . mostRecent ( )
19+ request
20+ . respondWith ( {
21+ status : 200 ,
22+ response : '<h1 id="getting-started-1-of-7">Getting Started 1 (of 7)</h1>'
23+ } ) . then ( ( ) => {
24+ expect ( wrapper . html ( ) ) . toContain ( '<h1 id="getting-started-1-of-7">Getting Started 1 (of 7)</h1>' )
25+ done ( )
26+ } )
27+ } )
28+ } )
29+ it ( 'displays a spinner while fetching the getting started page' , ( ) => {
30+ expect ( wrapper . find ( 'Loader' ) . props ( ) . loading ) . toBe ( true )
31+ } )
32+ } )
You can’t perform that action at this time.
0 commit comments