Skip to content

Commit

Permalink
Set up Premium offering page
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwr18 committed Feb 21, 2019
1 parent 1fb78ff commit 1782a37
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ package-lock.json
cypress/videos
cypress/screenshots
.env
.vscode/
2 changes: 2 additions & 0 deletions src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Subscriptions from './Subscriptions'
import PayPalSuccess from './PayPalSuccess'
import MembershipPlansPage from '../containers/MembershipPlansPage'
import PremiumMobMembershipPage from '../containers/PremiumMobMembershipPage'
import PremiumMembershipPage from '../containers/PremiumMembershipPage'
import { withCookies } from 'react-cookie'

class App extends Component {
Expand Down Expand Up @@ -63,6 +64,7 @@ class App extends Component {
/>
<Route path='/membership-plans' component={MembershipPlansPage} />
<Route path='/premiummob' component={PremiumMobMembershipPage} />
<Route path='/premium' component={PremiumMembershipPage} />
</Switch>
</Fragment>
)
Expand Down
34 changes: 34 additions & 0 deletions src/containers/PremiumMembershipPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React, { Component } from 'react'
import { RingLoader } from 'react-spinners'
import { Container } from 'semantic-ui-react'
import axios from 'axios'
import ReactHtmlParser from 'react-html-parser'

export default class PremiumMembershipPage extends Component {
state = { premiumMembershipPage: null }
componentDidMount () {
axios.get('api/v1/static-pages/premium')
.then(response => {
this.setState({ premiumMembershipPage: response.data })
})
}

render () {
let { premiumMembershipPage } = this.state
if (premiumMembershipPage) {
return (
<Container>
<div>
{ ReactHtmlParser(premiumMembershipPage) }
</div>
</Container>
)
} else {
return (
<Container>
<RingLoader sizeUnit={'px'} size={200} color={'#34495E'} />
</Container>
)
}
}
}
34 changes: 34 additions & 0 deletions src/tests/containers/PremiumMembershipPage.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react'
import { mount } from 'enzyme'
import PremiumMembershipPage from '../../containers/PremiumMembershipPage'
import moxios from 'moxios'

describe('PremiumMembershipPage', () => {
let wrapper
beforeEach(() => {
moxios.install()
wrapper = mount(<PremiumMembershipPage />)
})

afterEach(() => {
moxios.uninstall()
})

it('fetches the premium static page after component mounts', done => {
expect.assertions(1)
moxios.wait(() => {
let request = moxios.requests.mostRecent()
request.respondWith({
status: 200,
response: '<h1 id="premium-membership">Premium Membership</h1>'
}).then(() => {
expect(wrapper.html()).toContain('<h1 id="premium-membership">Premium Membership</h1>')
done()
})
})
})

it('displays a spinner while fetching the static membership plans page', () => {
expect(wrapper.find('Loader').props().loading).toBe(true)
})
})

0 comments on commit 1782a37

Please sign in to comment.