Skip to content

Commit

Permalink
Fixing some Spacing, Fixing Env Var
Browse files Browse the repository at this point in the history
  • Loading branch information
jedtan committed Jul 13, 2023
1 parent c927e75 commit 493ab92
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ NEXT_PUBLIC_GROWTHBOOK_ENV=dev

########## Estimated Money Per Tab ##########

EST_MONEY_RAISED_PER_TAB=0.000765
NEXT_EST_MONEY_RAISED_PER_TAB=0.000765
2 changes: 1 addition & 1 deletion .env.local.info
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ NEXT_PUBLIC_GROWTHBOOK_ENV=local

########## Estimated Money Per Tab ##########

EST_MONEY_RAISED_PER_TAB=0.000765
NEXT_EST_MONEY_RAISED_PER_TAB=0.000765
4 changes: 4 additions & 0 deletions .env.preview.info
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ NEXT_PUBLIC_MEDIA_ENDPOINT=https://prod-tab2017-media.gladly.io
########## Growthbook ##########

NEXT_PUBLIC_GROWTHBOOK_ENV=dev

########## Estimated Money Per Tab ##########

NEXT_EST_MONEY_RAISED_PER_TAB=0.000765
2 changes: 1 addition & 1 deletion .env.production.info
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ NEXT_PUBLIC_GROWTHBOOK_ENV=production

########## Estimated Money Per Tab ##########

EST_MONEY_RAISED_PER_TAB=0.000765
NEXT_EST_MONEY_RAISED_PER_TAB=0.000765
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ const useStyles = makeStyles((theme) => ({
marginRight: theme.spacing(2),
width: '90px',
},
subtitle: {
marginBottom: theme.spacing(2),
},
}))

const Leaderboard = ({ leaderboardEntries, userId, onClose }) => {
Expand Down Expand Up @@ -100,7 +103,7 @@ const Leaderboard = ({ leaderboardEntries, userId, onClose }) => {
<Typography variant="h5" className={classes.robotoBold}>
LEADERBOARD
</Typography>
<Typography variant="body2">
<Typography variant="body2" className={classes.subtitle}>
Impact points earned for this group goal by opening tabs, searching,
and/or shopping
</Typography>
Expand Down
1 change: 0 additions & 1 deletion src/components/groupImpactComponents/GroupImpactSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ const useStyles = makeStyles((theme) => ({
display: 'flex',
flexDirection: 'row',
paddingLeft: theme.spacing(2),
paddingRight: theme.spacing(2),
cursor: 'pointer',
position: 'relative',
maxHeight: '100vh',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const getMockProps = () => ({
})

beforeEach(() => {
process.env.EST_MONEY_RAISED_PER_TAB = 0.00001
process.env.NEXT_EST_MONEY_RAISED_PER_TAB = 0.00001
})

describe('GroupImpactLeaderboard component', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const getMockProps = () => ({
})

beforeEach(() => {
process.env.EST_MONEY_RAISED_PER_TAB = 0.00001
process.env.NEXT_EST_MONEY_RAISED_PER_TAB = 0.00001
})

describe('GroupImpactLeaderboardRow component', () => {
Expand Down
14 changes: 7 additions & 7 deletions src/utils/__tests__/misc.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
jest.mock('../logger')

beforeEach(() => {
process.env.EST_MONEY_RAISED_PER_TAB = '0.01287'
process.env.NEXT_EST_MONEY_RAISED_PER_TAB = '0.01287'
})

afterEach(() => {
Expand All @@ -10,25 +10,25 @@ afterEach(() => {

describe('globals', () => {
it('returns the estimated money raised per tab [test #1]', () => {
process.env.EST_MONEY_RAISED_PER_TAB = '0.01287'
process.env.NEXT_EST_MONEY_RAISED_PER_TAB = '0.01287'
const { getEstimatedMoneyRaisedPerTab } = require('../misc')
expect(getEstimatedMoneyRaisedPerTab()).toBe(0.01287)
})

it('returns the estimated money raised per tab [test #2]', () => {
process.env.EST_MONEY_RAISED_PER_TAB = '2'
process.env.NEXT_EST_MONEY_RAISED_PER_TAB = '2'
const { getEstimatedMoneyRaisedPerTab } = require('../misc')
expect(getEstimatedMoneyRaisedPerTab()).toBe(2.0)
})

it('returns 0 for the estimated money raised per tab if process.env.EST_MONEY_RAISED_PER_TAB is undefined', () => {
process.env.EST_MONEY_RAISED_PER_TAB = undefined
it('returns 0 for the estimated money raised per tab if process.env.NEXT_EST_MONEY_RAISED_PER_TAB is undefined', () => {
process.env.NEXT_EST_MONEY_RAISED_PER_TAB = undefined
const { getEstimatedMoneyRaisedPerTab } = require('../misc')
expect(getEstimatedMoneyRaisedPerTab()).toBe(0.0)
})

it('returns 0 for the estimated money raised per tab if process.env.EST_MONEY_RAISED_PER_TAB does not parse into a float', () => {
process.env.EST_MONEY_RAISED_PER_TAB = 'xyz'
it('returns 0 for the estimated money raised per tab if process.env.NEXT_EST_MONEY_RAISED_PER_TAB does not parse into a float', () => {
process.env.NEXT_EST_MONEY_RAISED_PER_TAB = 'xyz'
const { getEstimatedMoneyRaisedPerTab } = require('../misc')
expect(getEstimatedMoneyRaisedPerTab()).toBe(0.0)
})
Expand Down
4 changes: 2 additions & 2 deletions src/utils/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import logger from './logger'
* @return {Number}
*/
export const getEstimatedMoneyRaisedPerTab = () => {
let moneyRaised = parseFloat(process.env.EST_MONEY_RAISED_PER_TAB)
let moneyRaised = parseFloat(process.env.NEXT_EST_MONEY_RAISED_PER_TAB)
if (Number.isNaN(moneyRaised)) {
moneyRaised = 0.0
logger.error(
`Could not parse float from money raised env var value ${process.env.EST_MONEY_RAISED_PER_TAB}`
`Could not parse float from money raised env var value ${process.env.NEXT_EST_MONEY_RAISED_PER_TAB}`
)
}
return moneyRaised
Expand Down

0 comments on commit 493ab92

Please sign in to comment.