import QtiImport from '../QtiImport'

describe('QtiImport Record', () => {
  describe('#isImporting', () => {
    it('returns true if status is "started"', () => {
      const inProgressImport = new QtiImport({status: 'importing'})
      expect(inProgressImport.isImporting()).to.be.true()
    })

    it('returns false if status is "completed"', () => {
      const doneImport = new QtiImport({status: 'completed'})
      expect(doneImport.isImporting()).to.be.false()
    })
  })

  describe('#progressNumber', () => {
    const progressNum = 0.3
    context('status is importing', () => {
      it('returns the proress value', () => {
        const inProgressImport = new QtiImport({status: 'importing', progress: progressNum})
        expect(inProgressImport.progressNumber()).to.be.equal(progressNum)
      })
    })
    context('status is completed', () => {
      it('returns 1.0 regardless of progress value', () => {
        const doneImport = new QtiImport({status: 'completed', progress: progressNum})
        expect(doneImport.progressNumber()).to.be.equal(1.0)
      })
    })
    context('failed stauts', () => {
      it('returns 0.0 regardless of progress value', () => {
        const failedImport = new QtiImport({status: 'failed', progress: progressNum})
        expect(failedImport.progressNumber()).to.be.equal(0.0)
      })
    })
  })
})
