const chai = require('chai')
const expect = chai.expect
const _ = require('lodash')
const cveRecordPublished = require('../../schemas/5.0/CVE-2017-4024_published.json')

const Cve = require('../../../src/model/cve')
const cveCopy = _.cloneDeep(cveRecordPublished)

describe('Testing validating CVE record that has an ADP container', () => {
  it('Should return TRUE for valid Cve record ADP container', () => {
    const validationObj = Cve.validateCveRecord(cveCopy)
    expect(validationObj.isValid).to.be.equal(true)
  })

  it('Should return FALSE for Cve record with invalid ADP container', () => {
    // providerMetadata is a required adpContainer field, so validation will fail
    delete cveCopy.containers.adp[0].providerMetadata

    const validationObj = Cve.validateCveRecord(cveCopy)
    expect(validationObj.isValid).to.be.equal(false)
  })
})
