Skip to content

Commit

Permalink
test(ZNTA-1865): Write tests for CancellableProgressBar
Browse files Browse the repository at this point in the history
  • Loading branch information
Earl Floden committed Jul 6, 2017
1 parent 380caad commit 456f7da
Showing 1 changed file with 59 additions and 0 deletions.
@@ -0,0 +1,59 @@
jest.disableAutomock()

import React from 'react'
import ReactDOMServer from 'react-dom/server'
import CancellableProgressBar from './CancellableProgressBar'
import { ProgressBar } from 'react-bootstrap'
import { isProcessEnded } from '../../utils/EnumValueUtils'

describe('CancellableProgressBarTest', () => {
it('can render CancellableProgressBar markup', () => {
const clickFun = () => {}
const processShape = {
url: '/rest/process/key/TMMergeForVerKey-1-ja',
percentageComplete: 0,
statusCode: 'Running'
}
const actual = ReactDOMServer.renderToStaticMarkup(
<CancellableProgressBar onCancelOperation={clickFun}
processStatus={processShape} buttonLabel='Cancel TM Merge'
queryProgress={clickFun} />
)
const expected = ReactDOMServer.renderToStaticMarkup(
<div>
<ProgressBar now={0}label={' 0%'} />
<button type='button' className='btn-danger btn btn-primary'>
Cancel TM Merge
</button>
</div>
)
expect(actual).toEqual(expected)
})
it('detects loading process completion', () => {
const cancelledShape = {
url: '/rest/process/key/TMMergeForVerKey-1-ja',
percentageComplete: 0,
statusCode: 'Cancelled'
}
const clickFun = () => {}
// Test the isProcessEnded utils function
const cancelled = isProcessEnded(cancelledShape)
const cancelledExpected = true
expect(cancelled).toEqual(cancelledExpected)
// Test the CancellableProgressBar markup cancel button is disabled
const actual = ReactDOMServer.renderToStaticMarkup(
<CancellableProgressBar onCancelOperation={clickFun}
processStatus={cancelledShape} buttonLabel='Cancel TM Merge'
queryProgress={clickFun} />
)
const expected = ReactDOMServer.renderToStaticMarkup(
<div>
<ProgressBar now={0}label={' 0%'} />
<button disabled type='button' className='btn-danger btn btn-primary'>
Cancel TM Merge
</button>
</div>
)
expect(actual).toEqual(expected)
})
})

0 comments on commit 456f7da

Please sign in to comment.