testing - MongoDB/Mongoose: embedded document update verification -
how verify/test on mongoose, document update call, embedded documents not being duplicated?
i'm using mongoose, sinon, mocha , chai. have document contains embedded document, , both created external data pulled @ regular intervals.
format similar to:
{ title: testingtitle, flag: true, color: orange, list: [{ name: testname, status: overdue }, { name: othertestname, status: due, }] } i have 2 separate schemas. format similar this:
let embeddedschema = new mongoose.schema({ name: {type: string, required: true}, staus: {type: string, required: true} createdat: {type: date, default: moment} }); let mainschema = new mongoose.schema({ title: {type: string, required: true}, flag: {type: string, defualt: null}, color: {type: object, defualt: null}, list: [embeddedschema] }) it seems works. when run logic (which calls update if main document exists) doesn't appear duplicate of sublist items. unfortunately way system set it's difficult verify truth.
- is there blatantly wrong set up? main concern every item in list potentially duplicated, instead of updated on changes, because there no uniqueid connect them stored items.
- how go testing using sinon?
Comments
Post a Comment