@instructure/quiz-interactions
Version:
A React UI component Library for quiz interaction types.
68 lines (58 loc) • 2.02 kB
JavaScript
import {expect} from '@instructure/ui-test-utils'
import FileUploadInteractionType from '../file_upload'
import checkUserResponseTransform from '../../__tests__/sharedRecordTests'
describe('FileUploadInteractionType', () => {
const FileUploadRecord = FileUploadInteractionType
const intType = new FileUploadRecord()
describe('#getDefaultInteractionData', () => {
it('returns the expected interactiond data', () => {
const intData = intType.getDefaultInteractionData()
expect(intData.restrictCount).to.be.false()
expect(intData.filesCount).to.be.equal('1')
})
})
describe('#getDefaultScoringData', () => {
it('returns a blank value', () => {
const scoringData = intType.getDefaultScoringData()
expect(scoringData).to.be.eql({value: ''})
})
})
describe('#getDefaultUserResponse', () => {
it('returns an empty array', () => {
const userResponse = intType.getDefaultUserResponse()
expect(userResponse).to.be.eql({value: []})
})
})
describe('#defaultProperties', () => {
it('enumerates to proper keys', () => {
const explicitProperties = Object.keys(intType.defaultProperties)
expect(explicitProperties).to.include('restrictTypes')
})
})
describe('#hasResponse', () => {
it('returns true when there is at least one file', () => {
const resp = [{id: 'id', name: 'file.ext', url: 'test.com', size: 12345}]
expect(intType.hasResponse(resp)).to.be.true()
})
it('returns false when there are no files', () => {
const resp = []
expect(intType.hasResponse(resp)).to.be.false()
})
})
const response = {
interactionData: {},
response: [{name: 'adb'}, {name: 'bcd'}],
expected: 'adb, bcd',
}
const invalidResponse = {
interactionData: {},
response: [{nae: 'adb'}, {name: 'bcd'}],
expected: ', bcd',
}
checkUserResponseTransform(
new FileUploadInteractionType(),
response,
invalidResponse,
out => out.props.children,
)
})