Skip to content

Commit

Permalink
test: compactionLevel
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Aug 27, 2024
1 parent 653df6a commit 992cc4e
Showing 1 changed file with 168 additions and 0 deletions.
168 changes: 168 additions & 0 deletions test/components/stages.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,174 @@ describe('Stages', () => {
${design.icons.info.figure} Static: this is a static key:value pair
${design.icons.info.figure} Dynamic: this is a dynamic key:value pair`)
})

it('should render compactionLevel=1', async () => {
const stageTracker = new StageTracker(['step1', 'step2'])
stageTracker.set('step1', 'current')
const preStageInfos = [{type: 'message', value: 'pre-stage hello'}] as FormattedKeyValue[]
const postStageInfos = [{type: 'message', value: 'post-stage hello'}] as FormattedKeyValue[]
const stageSpecificInfos = [{stage: 'step1', type: 'message', value: 'stage-specific hello'}] as FormattedKeyValue[]

const {frames, unmount} = render(
<Stages
preStagesBlock={preStageInfos}
postStagesBlock={postStageInfos}
stageSpecificBlock={stageSpecificInfos}
design={design}
stageTracker={stageTracker}
title="Test"
compactionLevel={1}
/>,
)
unmount()
const lastFrame = lastValidFrame(frames)
expect(lastFrame).to.include('─ Test ─')
expect(lastFrame).to.include('pre-stage hello')
expect(lastFrame).to.include(`[1/2] Step1`)
expect(lastFrame).to.include('stage-specific hello')
expect(lastFrame).to.include('post-stage hello')
expect(lastFrame).to.include('Elapsed Time:')
})

it('should render compactionLevel=2', async () => {
const stageTracker = new StageTracker(['step1', 'step2'])
stageTracker.set('step1', 'current')
const preStageInfos = [{type: 'message', value: 'pre-stage hello'}] as FormattedKeyValue[]
const postStageInfos = [{type: 'message', value: 'post-stage hello'}] as FormattedKeyValue[]
const stageSpecificInfos = [{stage: 'step1', type: 'message', value: 'stage-specific hello'}] as FormattedKeyValue[]

const {frames, unmount} = render(
<Stages
preStagesBlock={preStageInfos}
postStagesBlock={postStageInfos}
stageSpecificBlock={stageSpecificInfos}
design={design}
stageTracker={stageTracker}
title="Test"
compactionLevel={2}
/>,
)
unmount()
const lastFrame = lastValidFrame(frames)
expect(lastFrame).to.include('─ Test ─')
expect(lastFrame).to.include('pre-stage hello')
expect(lastFrame).to.include(`[1/2] Step1`)
expect(lastFrame).to.include('stage-specific hello')
expect(lastFrame).to.include('post-stage hello')
expect(lastFrame).to.not.include('Elapsed Time:')
})

it('should render compactionLevel=3', async () => {
const stageTracker = new StageTracker(['step1', 'step2'])
stageTracker.set('step1', 'current')
const preStageInfos = [{type: 'message', value: 'pre-stage hello'}] as FormattedKeyValue[]
const postStageInfos = [{type: 'message', value: 'post-stage hello'}] as FormattedKeyValue[]
const stageSpecificInfos = [{stage: 'step1', type: 'message', value: 'stage-specific hello'}] as FormattedKeyValue[]

const {frames, unmount} = render(
<Stages
preStagesBlock={preStageInfos}
postStagesBlock={postStageInfos}
stageSpecificBlock={stageSpecificInfos}
design={design}
stageTracker={stageTracker}
title="Test"
compactionLevel={3}
/>,
)
unmount()
const lastFrame = lastValidFrame(frames)
expect(lastFrame).to.not.include('─ Test ─')
expect(lastFrame).to.include('pre-stage hello')
expect(lastFrame).to.include(`[1/2] Step1`)
expect(lastFrame).to.include('stage-specific hello')
expect(lastFrame).to.include('post-stage hello')
expect(lastFrame).to.not.include('Elapsed Time:')
})

it('should render compactionLevel=4', async () => {
const stageTracker = new StageTracker(['step1', 'step2'])
stageTracker.set('step1', 'current')
const preStageInfos = [{type: 'message', value: 'pre-stage hello'}] as FormattedKeyValue[]
const postStageInfos = [{type: 'message', value: 'post-stage hello'}] as FormattedKeyValue[]
const stageSpecificInfos = [{stage: 'step1', type: 'message', value: 'stage-specific hello'}] as FormattedKeyValue[]

const {frames, unmount} = render(
<Stages
preStagesBlock={preStageInfos}
postStagesBlock={postStageInfos}
stageSpecificBlock={stageSpecificInfos}
design={design}
stageTracker={stageTracker}
title="Test"
compactionLevel={4}
/>,
)
unmount()
const lastFrame = lastValidFrame(frames)
expect(lastFrame).to.not.include('─ Test ─')
expect(lastFrame).to.not.include('pre-stage hello')
expect(lastFrame).to.include(`[1/2] Step1`)
expect(lastFrame).to.include('stage-specific hello')
expect(lastFrame).to.include('post-stage hello')
expect(lastFrame).to.not.include('Elapsed Time:')
})

it('should render compactionLevel=5', async () => {
const stageTracker = new StageTracker(['step1', 'step2'])
stageTracker.set('step1', 'current')
const preStageInfos = [{type: 'message', value: 'pre-stage hello'}] as FormattedKeyValue[]
const postStageInfos = [{type: 'message', value: 'post-stage hello'}] as FormattedKeyValue[]
const stageSpecificInfos = [{stage: 'step1', type: 'message', value: 'stage-specific hello'}] as FormattedKeyValue[]

const {frames, unmount} = render(
<Stages
preStagesBlock={preStageInfos}
postStagesBlock={postStageInfos}
stageSpecificBlock={stageSpecificInfos}
design={design}
stageTracker={stageTracker}
title="Test"
compactionLevel={5}
/>,
)
unmount()
const lastFrame = lastValidFrame(frames)
expect(lastFrame).to.not.include('─ Test ─')
expect(lastFrame).to.not.include('pre-stage hello')
expect(lastFrame).to.include(`[1/2] Step1`)
expect(lastFrame).to.include('stage-specific hello')
expect(lastFrame).to.not.include('post-stage hello')
expect(lastFrame).to.not.include('Elapsed Time:')
})

it('should render compactionLevel=6', async () => {
const stageTracker = new StageTracker(['step1', 'step2'])
stageTracker.set('step1', 'current')
const preStageInfos = [{type: 'message', value: 'pre-stage hello'}] as FormattedKeyValue[]
const postStageInfos = [{type: 'message', value: 'post-stage hello'}] as FormattedKeyValue[]
const stageSpecificInfos = [{stage: 'step1', type: 'message', value: 'stage-specific hello'}] as FormattedKeyValue[]

const {frames, unmount} = render(
<Stages
preStagesBlock={preStageInfos}
postStagesBlock={postStageInfos}
stageSpecificBlock={stageSpecificInfos}
design={design}
stageTracker={stageTracker}
title="Test"
compactionLevel={6}
/>,
)
unmount()
const lastFrame = lastValidFrame(frames)
expect(lastFrame).to.not.include('─ Test ─')
expect(lastFrame).to.not.include('pre-stage hello')
expect(lastFrame).to.include(`[1/2] Step1`)
expect(lastFrame).to.not.include('stage-specific hello')
expect(lastFrame).to.not.include('post-stage hello')
expect(lastFrame).to.not.include('Elapsed Time:')
})
})

describe('determineCompactionLevel', () => {
Expand Down

0 comments on commit 992cc4e

Please sign in to comment.