Skip to content

Instantly share code, notes, and snippets.

@dbousamra
Last active August 29, 2015 14:15
Show Gist options
  • Select an option

  • Save dbousamra/0120212d1170a4e3d35c to your computer and use it in GitHub Desktop.

Select an option

Save dbousamra/0120212d1170a4e3d35c to your computer and use it in GitHub Desktop.
describe("Event save", () => {
it("Should be able to retrieve an event from the database, mutate the data, and save it", (done) => {
return eventRepo.findOneById('54c305fd1431209617db8221').then((eventO: m.Option<domain.Event>) => {
var event = eventO.get();
event.hash = 'foobar';
return eventRepo.save(event).then((savedEvent) => {
return eventRepo.findOneById('54c305fd1431209617db8221').then((updatedEvent) => {
updatedEvent.isDefined.should.be.true
updatedEvent.foreach((ev) => ev.should.eql(event))
});
});
})
.done(done)
});
});
describe("Event save", () => {
it("Should be able to retrieve an event from the database, mutate the data, and save it", (done) => {
return eventRepo.findOneById('54c305fd1431209617db8221').then((eventO: m.Option<domain.Event>) => {
eventO.match({
Some: (event) => {
event.hash = 'foobar';
eventRepo.save(event).then(() => {
return eventRepo.findOneById('54c305fd1431209617db8221').then((updatedEventO) => {
updatedEventO.match({
Some: (ev) => ev.should.eql(event)),
None: () => // what do
})
});
});
},
None: () => // what to do here?
})
})
.done(done)
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment