Skip to content

Commit

Permalink
chore: remove redundant test helper (#537)
Browse files Browse the repository at this point in the history
This is a minor test-only change.

We had two identical test helpers: `stripUndef` and
`removeUndefinedFields`. This removes `stripUndef` and uses
`removeUndefinedFields` everywhere.
  • Loading branch information
EvanHahn authored Apr 1, 2024
1 parent d5bf570 commit 9c3ca14
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
8 changes: 4 additions & 4 deletions test-e2e/project-crud.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { test } from 'brittle'
import { randomBytes } from 'crypto'
import { valueOf } from '../src/utils.js'
import { createManager, sortById, stripUndef } from './utils.js'
import { createManager, sortById, removeUndefinedFields } from './utils.js'
import { round } from './utils.js'
import { generate } from '@mapeo/mock-data'
import { setTimeout as delay } from 'timers/promises'
Expand Down Expand Up @@ -116,7 +116,7 @@ test('CRUD operations', async (t) => {
'return of update() matched return of getByDocId()'
)
st.alike(
valueOf(stripUndef(updated)),
valueOf(removeUndefinedFields(updated)),
updateValue,
'expected value is updated'
)
Expand Down Expand Up @@ -224,8 +224,8 @@ test('CRUD operations', async (t) => {
const manyValues2 = many2.map((doc) => valueOf(doc))

st.alike(
stripUndef(manyValues1),
stripUndef(manyValues2),
removeUndefinedFields(manyValues1),
removeUndefinedFields(manyValues2),
'expected values returned before closing and after re-opening'
)
})
Expand Down
8 changes: 1 addition & 7 deletions test-e2e/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,7 @@ function getRootKey(seed) {
}
return key
}
/**
* Remove undefined properties from an object, to allow deep comparison
* @param {object} obj
*/
export function stripUndef(obj) {
return JSON.parse(JSON.stringify(obj))
}

/**
*
* @param {number} value
Expand Down

0 comments on commit 9c3ca14

Please sign in to comment.