From 9065b647ad8137e559096fa3110022920b942d83 Mon Sep 17 00:00:00 2001 From: Daniel Gasienica Date: Tue, 3 Apr 2018 11:39:08 -0400 Subject: [PATCH] Run migrations before clearing database during tests --- test/_test.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/test/_test.js b/test/_test.js index 864242da2..183644cf5 100644 --- a/test/_test.js +++ b/test/_test.js @@ -66,18 +66,19 @@ before(function(done) { idbReq.onsuccess = function() { done(); }; }); -function clearDatabase(done) { - var convos = new Whisper.ConversationCollection(); - return convos.fetch().then(function() { - convos.destroyAll().then(function() { - var messages = new Whisper.MessageCollection(); - return messages.fetch().then(function() { - messages.destroyAll().then(function() { - if (done) { - done(); - } - }); - }); - }); - }); +async function clearDatabase(done) { + await Signal.Migrations.Migrations0DatabaseWithAttachmentData.run({ + Backbone, + databaseName: Whisper.Database.id, + }); + + const convos = new Whisper.ConversationCollection(); + await convos.fetch(); + await convos.destroyAll(); + const messages = new Whisper.MessageCollection(); + await messages.fetch(); + await messages.destroyAll(); + if (done) { + done(); + }; }