Skip to content

Commit

Permalink
[CLD-567] update notification message (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
zlatanpham authored Jan 2, 2020
1 parent 6f70494 commit 1ee54f3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@reapit/elements",
"version": "0.5.23",
"version": "0.5.24",
"description": "A collection of React components and utilities for building apps for Reapit Marketplace",
"main": "dist/index.js",
"umd:main": "dist/elements.umd.production.js",
Expand Down
4 changes: 2 additions & 2 deletions src/components/Info/__tests__/__snapshots__/index.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ exports[`Info should match a snapshot for variant CLIENT_APPS_EMPTY 1`] = `

exports[`Info should match a snapshot for variant DEVELOPER_APPS_EMPTY 1`] = `
<Component
message="You currently have no apps listed. Go to the submit app page to submit an app. After submission, you will need to edit the app and set status to isListed to appear in the marketplace"
message="It looks like you haven’t submitted an App yet . When you’re ready, click on ‘Submit’ from the menu to get started."
type="info"
/>
`;

exports[`Info should match a snapshot for variant INSTALLED_APPS_EMPTY 1`] = `
<Component
message="You have no apps installed - try browsing the apps list for apps you might find useful"
message="It looks like you haven’t installed any Apps yet. Have a look at what’s available by clicking ‘Browse’ from the menu."
type="info"
/>
`;
11 changes: 11 additions & 0 deletions src/components/Info/__tests__/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import * as React from 'react'
import { shallow } from 'enzyme'
import toJson from 'enzyme-to-json'
import { Info, InfoType } from '..'
import { infoText } from '../index'
import Alert from '../../Alert'

const variants: InfoType[] = [
'404',
Expand All @@ -18,4 +20,13 @@ describe('Info', () => {
expect(toJson(shallow(<Info infoType={variant} />))).toMatchSnapshot()
})
})

variants.forEach(variant => {
it(`should have message \"${infoText(variant)}\" when info type is \"${variant}\"`, () => {
const alert = shallow(<Info infoType={variant} />)
.find(Alert)
.dive()
expect(alert.text()).toBe(infoText(variant))
})
})
})
6 changes: 3 additions & 3 deletions src/components/Info/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ export interface InfoProps {
infoType: InfoType
}

const infoText = (infoType: InfoType) => {
export const infoText = (infoType: InfoType) => {
switch (infoType) {
case '404':
return 'Page not found'
case 'CLIENT_APPS_EMPTY':
return 'We are sorry, there are no apps listed compatible with your account'
case 'INSTALLED_APPS_EMPTY':
return 'You have no apps installed - try browsing the apps list for apps you might find useful'
return 'It looks like you haven’t installed any Apps yet. Have a look at what’s available by clicking ‘Browse’ from the menu.'
case 'DEVELOPER_APPS_EMPTY':
return 'You currently have no apps listed. Go to the submit app page to submit an app. After submission, you will need to edit the app and set status to isListed to appear in the marketplace'
return 'It looks like you haven’t submitted an App yet . When you’re ready, click on ‘Submit’ from the menu to get started.'
case 'ADMIN_APPROVALS_EMPTY':
return 'There are no updates that require approval'
default:
Expand Down
1 change: 1 addition & 0 deletions src/components/Info/info.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ import { Info } from './index'
storiesOf('Info', module)
.add('404', () => <Info infoType="404" />)
.add('NoAppsInstalled', () => <Info infoType="INSTALLED_APPS_EMPTY" />)
.add('DeveloperAppsEmpty', () => <Info infoType="DEVELOPER_APPS_EMPTY" />)

0 comments on commit 1ee54f3

Please sign in to comment.