Relationship test

This commit is contained in:
Mo Bitar
2018-07-14 10:08:06 -05:00
parent c6bf9d8b48
commit 78587e68bd
3 changed files with 3728 additions and 2 deletions

View File

@@ -4,7 +4,7 @@ class ComponentManager {
constructor($rootScope, modelManager, syncManager, desktopManager, nativeExtManager, $timeout, $compile) {
/* This domain will be used to save context item client data */
ComponentManager.ClientDataDomain = "org.standardnotes.sn.components";
this.$compile = $compile;
this.$rootScope = $rootScope;
this.modelManager = modelManager;
@@ -882,7 +882,9 @@ class ComponentManager {
var setSize = function(element, size) {
var widthString = typeof size.width === 'string' ? size.width : `${data.width}px`;
var heightString = typeof size.height === 'string' ? size.height : `${data.height}px`;
element.setAttribute("style", `width:${widthString}; height:${heightString};`);
if(element) {
element.setAttribute("style", `width:${widthString}; height:${heightString};`);
}
}
if(component.area == "rooms" || component.area == "modal") {
@@ -893,6 +895,9 @@ class ComponentManager {
}
} else {
var iframe = this.iframeForComponent(component);
if(!iframe) {
return;
}
var width = data.width;
var height = data.height;
iframe.width = width;

3699
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -49,6 +49,28 @@ describe("notes and tags", () => {
expect(note).to.be.an.instanceOf(SNNote);
});
it.only('properly handles legacy relationships', () => {
// legacy relationships are when a note has a reference to a tag
let modelManager = Factory.createModelManager();
let pair = createRelatedNoteTagPair();
let noteParams = pair[0];
let tagParams = pair[1];
tagParams.content.references = null;
noteParams.content.references = [
{
uuid: tagParams.uuid,
content_type: tagParams.content_type
}
];
modelManager.mapResponseItemsToLocalModels([noteParams, tagParams]);
let note = modelManager.allItemsMatchingTypes(["Note"])[0];
let tag = modelManager.allItemsMatchingTypes(["Tag"])[0];
expect(note.tags.length).to.equal(1);
expect(tag.notes.length).to.equal(1);
})
it('creates two-way relationship between note and tag', () => {
let modelManager = Factory.createModelManager();