Skip to content

Commit

Permalink
fix: test cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jenniferarnesen committed Sep 6, 2023
1 parent 8b6c29a commit c1809ee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 27 deletions.
32 changes: 7 additions & 25 deletions src/components/Item/AppItem/__tests__/getIframeSrc.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import { getIframeSrc } from '../getIframeSrc.js'

const appDetails = { launchUrl: 'debug/dev' }
const dashboardItem = { id: 'rainbowdashitem' }
const expectedSrc = `${appDetails.launchUrl}?dashboardItemId=${dashboardItem.id}`

describe('getIframeSrc', () => {
it('no ou filter', () => {
const ouFilter = []

const src = getIframeSrc(appDetails, dashboardItem, { ou: ouFilter })
expect(src).toEqual(
`${appDetails.launchUrl}?dashboardItemId=${dashboardItem.id}`
)
expect(src).toEqual(expectedSrc)
})

it('should return the correct iframe src', () => {
Expand All @@ -27,12 +26,9 @@ describe('getIframeSrc', () => {
},
]

const appDetails = { launchUrl: 'debug/dev' }
const dashboardItem = { id: 'rainbowdashitem' }

const src = getIframeSrc(appDetails, dashboardItem, { ou: ouFilter })
expect(src).toEqual(
`${appDetails.launchUrl}?dashboardItemId=${dashboardItem.id}&userOrgUnit=fdc6uOvgoji,lc3eMKXaEfw`
`${expectedSrc}&userOrgUnit=fdc6uOvgoji,lc3eMKXaEfw`
)
})

Expand All @@ -49,12 +45,9 @@ describe('getIframeSrc', () => {
},
]

const appDetails = { launchUrl: 'debug/dev' }
const dashboardItem = { id: 'rainbowdashitem' }

const src = getIframeSrc(appDetails, dashboardItem, { ou: ouFilter })
expect(src).toEqual(
`${appDetails.launchUrl}?dashboardItemId=${dashboardItem.id}&userOrgUnit=OU_GROUP-b0EsAxm8Nge,lc3eMKXaEfw`
`${expectedSrc}&userOrgUnit=OU_GROUP-b0EsAxm8Nge,lc3eMKXaEfw`
)
})

Expand All @@ -71,12 +64,9 @@ describe('getIframeSrc', () => {
},
]

const appDetails = { launchUrl: 'debug/dev' }
const dashboardItem = { id: 'rainbowdashitem' }

const src = getIframeSrc(appDetails, dashboardItem, { ou: ouFilter })
expect(src).toEqual(
`${appDetails.launchUrl}?dashboardItemId=${dashboardItem.id}&userOrgUnit=LEVEL-m9lBJogzE95,fdc6uOvgoji`
`${expectedSrc}&userOrgUnit=LEVEL-m9lBJogzE95,fdc6uOvgoji`
)
})

Expand All @@ -88,13 +78,8 @@ describe('getIframeSrc', () => {
},
]

const appDetails = { launchUrl: 'debug/dev' }
const dashboardItem = { id: 'rainbowdashitem' }

const src = getIframeSrc(appDetails, dashboardItem, { ou: ouFilter })
expect(src).toEqual(
`${appDetails.launchUrl}?dashboardItemId=${dashboardItem.id}&userOrgUnit=USER_ORGUNIT`
)
expect(src).toEqual(`${expectedSrc}&userOrgUnit=USER_ORGUNIT`)
})

it('all user org units in filter', () => {
Expand All @@ -113,12 +98,9 @@ describe('getIframeSrc', () => {
},
]

const appDetails = { launchUrl: 'debug/dev' }
const dashboardItem = { id: 'rainbowdashitem' }

const src = getIframeSrc(appDetails, dashboardItem, { ou: ouFilter })
expect(src).toEqual(
`${appDetails.launchUrl}?dashboardItemId=${dashboardItem.id}&userOrgUnit=USER_ORGUNIT_CHILDREN,USER_ORGUNIT_GRANDCHILDREN,USER_ORGUNIT`
`${expectedSrc}&userOrgUnit=USER_ORGUNIT_CHILDREN,USER_ORGUNIT_GRANDCHILDREN,USER_ORGUNIT`
)
})
})
2 changes: 0 additions & 2 deletions src/components/Item/AppItem/getIframeSrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { FILTER_ORG_UNIT } from '../../../actions/itemFilters.js'
export const getIframeSrc = (appDetails, item, itemFilters) => {
let iframeSrc = `${appDetails.launchUrl}?dashboardItemId=${item.id}`

console.log('jj itemfilters', itemFilters)

if (itemFilters[FILTER_ORG_UNIT] && itemFilters[FILTER_ORG_UNIT].length) {
const ouIds = itemFilters[FILTER_ORG_UNIT].map(({ id, path }) =>
path ? path.split('/').slice(-1)[0] : id
Expand Down

0 comments on commit c1809ee

Please sign in to comment.