Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
property = claim.mainsnak.property
} else {
const datatype = config.properties[property]
claim = findSnak(property, datatype, claims[property], oldValue)
}
if (!claim) {
throw error_.new('claim not found', 400, { id, property, oldValue, newValue, guid })
}
guid = claim.id
claim.value = newValue
const data = { id, claims: {} }
const simplifiedClaim = simplify.claim(claim, simplifyOptions)
simplifiedClaim.value = newValue
data.claims[property] = simplifiedClaim
// Use wbeditentity as the endpoint is more complete
// Pass the reqConfig to avoid getting into errors of the kind
// 'credentials should either be passed at initialization or per request'
// as API.entity.edit is already bound to the generalConfig
return API.entity.edit(data, reqConfig)
.then(res => {
const { entity, success } = res
const updatedClaim = entity.claims[property].find(isGuidClaim(guid))
// Mimick claim actions responses
return { claim: updatedClaim, success }
})
})
}
.then(res2 => {
res1.claim.id.should.equal(res2.claim.id)
simplify.claim(res2.claim).split('T')[0].should.equal(newValue)
done()
})
})
.then(res => {
res.claim.id.should.equal(guid)
simplify.claim(res.claim).split('T')[0].should.equal(newValue)
done()
})
})
.then(resB => {
const simplifiedClaim = simplify.claim(resB.claim, { keepIds: true, keepQualifiers: true, keepReferences: true })
simplifiedClaim.id.should.equal(guid)
simplifiedClaim.value.should.equal(newValue)
simplifiedClaim.qualifiers[property][0].should.equal(qualifierValue)
simplifiedClaim.references[0][property][0].should.equal(referenceValue)
done()
})
})
.then(res2 => {
res1.claim.id.should.equal(res2.claim.id)
simplify.claim(res2.claim).should.equal(newValue.amount)
done()
})
})
.then(res => {
res.claim.id.should.equal(guid)
simplify.claim(res.claim, { keepRichValues: true }).should.deepEqual(newValue)
done()
})
})