1
0
Fork 0

don't use non-null assertions

pull/1487/head
Bethany 2023-08-09 17:48:53 -07:00
parent 188abfc20b
commit 58858b5078
1 changed files with 18 additions and 12 deletions

View File

@ -14,11 +14,13 @@ describe('retention', () => {
const exp = retention.getExpiration(30) const exp = retention.getExpiration(30)
expect(exp).toBeDefined() expect(exp).toBeDefined()
const expDate = Timestamp.toDate(exp!) // we check whether exp is defined above if (exp) {
const expected = new Date() const expDate = Timestamp.toDate(exp)
expected.setDate(expected.getDate() + 30) const expected = new Date()
expected.setDate(expected.getDate() + 30)
expect(expDate).toEqual(expected) expect(expDate).toEqual(expected)
}
}) })
it('should return the max retention days if the inputted retention days is greater than the max retention days', () => { it('should return the max retention days if the inputted retention days is greater than the max retention days', () => {
@ -30,11 +32,13 @@ describe('retention', () => {
const exp = retention.getExpiration(120) const exp = retention.getExpiration(120)
expect(exp).toBeDefined() expect(exp).toBeDefined()
const expDate = Timestamp.toDate(exp!) // we check whether exp is defined above if (exp) {
const expected = new Date() const expDate = Timestamp.toDate(exp) // we check whether exp is defined above
expected.setDate(expected.getDate() + 90) const expected = new Date()
expected.setDate(expected.getDate() + 90)
expect(expDate).toEqual(expected) expect(expDate).toEqual(expected)
}
}) })
it('should return undefined if the inputted retention days is undefined', () => { it('should return undefined if the inputted retention days is undefined', () => {
@ -50,10 +54,12 @@ describe('retention', () => {
const exp = retention.getExpiration(30) const exp = retention.getExpiration(30)
expect(exp).toBeDefined() expect(exp).toBeDefined()
const expDate = Timestamp.toDate(exp!) // we check whether exp is defined above if (exp) {
const expected = new Date() const expDate = Timestamp.toDate(exp) // we check whether exp is defined above
expected.setDate(expected.getDate() + 30) const expected = new Date()
expected.setDate(expected.getDate() + 30)
expect(expDate).toEqual(expected) expect(expDate).toEqual(expected)
}
}) })
}) })