SFJS 0.3.60

This commit is contained in:
Mo Bitar
2019-05-28 14:09:29 -05:00
parent 8d4f86242a
commit 394958241b
7 changed files with 31 additions and 7709 deletions

View File

@@ -56,6 +56,10 @@ export default class Factory {
return new SFModelManager();
}
static yesterday() {
return new Date(new Date().setDate(new Date().getDate() - 1));
}
static createItemParams() {
var params = {
uuid: SFJS.crypto.generateUUIDSync(),

View File

@@ -255,13 +255,7 @@ describe("notes and tags", () => {
let note = modelManager.allItemsMatchingTypes(["Note"])[0];
let tag = modelManager.allItemsMatchingTypes(["Tag"])[0];
// Usually content_type will be provided by a server response
var duplicateParams = _.merge({content_type: "Tag"}, tag);
duplicateParams.uuid = null;
expect(duplicateParams.content_type).to.equal("Tag");
var duplicateTag = await modelManager.createConflictedItem(duplicateParams);
modelManager.addConflictedItem(duplicateTag, tag);
var duplicateTag = await modelManager.duplicateItemAndAddAsConflict(tag);
expect(tag.uuid).to.not.equal(duplicateTag.uuid);
@@ -293,15 +287,9 @@ describe("notes and tags", () => {
let note = modelManager.allItemsMatchingTypes(["Note"])[0];
let tag = modelManager.allItemsMatchingTypes(["Tag"])[0];
// Usually content_type will be provided by a server response
var duplicateParams = _.merge({content_type: "Note"}, note);
duplicateParams.uuid = null;
var duplicateNote = await modelManager.createConflictedItem(duplicateParams);
modelManager.addConflictedItem(duplicateNote, note);
var duplicateNote = await modelManager.duplicateItemAndAddAsConflict(note);
expect(note.uuid).to.not.equal(duplicateNote.uuid);
expect(duplicateNote.tags.length).to.equal(note.tags.length);
});
@@ -579,6 +567,7 @@ describe("syncing", () => {
})
it('duplicating a tag should maintian its relationships', async () => {
await syncManager.loadLocalItems();
modelManager.handleSignout();
let pair = createRelatedNoteTagPair();
let noteParams = pair[0];
@@ -597,6 +586,7 @@ describe("syncing", () => {
expect(modelManager.allItems.length).to.equal(2);
tag.title = `${Math.random()}`
tag.updated_at = Factory.yesterday();
tag.setDirty(true);
expect(note.referencingObjects.length).to.equal(1);