Refactor IdMap test helper to medusa-test-utils package
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import mongoose from "mongoose"
|
||||
|
||||
class IdMap {
|
||||
ids = {}
|
||||
|
||||
getId(key) {
|
||||
if (this.ids[key]) {
|
||||
return this.ids[key]
|
||||
}
|
||||
const id = `${mongoose.Types.ObjectId()}`
|
||||
this.ids[key] = id
|
||||
return id
|
||||
}
|
||||
}
|
||||
|
||||
const instance = new IdMap()
|
||||
export default instance
|
||||
Reference in New Issue
Block a user