From 64df1d040f6632fef55079bd98bcb129901c2c80 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 14 Feb 2019 15:09:28 +1100 Subject: [PATCH] Fixes how tests are run, fixes up the content picker, removes unecessary tests --- .../contentpicker/contentpicker.controller.js | 4 +- .../test/config/karma.conf.js | 6 +++ .../content-picker-controller.spec.js | 24 ++++++------ .../template-editor-controller.spec.js | 37 ------------------- 4 files changed, 20 insertions(+), 51 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/contentpicker/contentpicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/contentpicker/contentpicker.controller.js index 16aa7efceb..2bebc55beb 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/contentpicker/contentpicker.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/contentpicker/contentpicker.controller.js @@ -191,7 +191,7 @@ function contentPickerController($scope, entityResource, editorState, iconHelper //if we have a query for the startnode, we will use that. var rootId = $routeParams.id; entityResource.getByQuery($scope.model.config.startNode.query, rootId, "Document").then(function (ent) { - dialogOptions.startNodeId = $scope.model.config.idType === "udi" ? ent.udi : ent.id; + dialogOptions.startNodeId = ($scope.model.config.idType === "udi" ? ent.udi : ent.id).toString(); }); } else { @@ -261,7 +261,7 @@ function contentPickerController($scope, entityResource, editorState, iconHelper $scope.add = function (item) { var currIds = $scope.model.value ? $scope.model.value.split(',') : []; - var itemId = $scope.model.config.idType === "udi" ? item.udi : item.id; + var itemId = ($scope.model.config.idType === "udi" ? item.udi : item.id).toString(); if (currIds.indexOf(itemId) < 0) { currIds.push(itemId); diff --git a/src/Umbraco.Web.UI.Client/test/config/karma.conf.js b/src/Umbraco.Web.UI.Client/test/config/karma.conf.js index 6029d2e75b..08223de092 100644 --- a/src/Umbraco.Web.UI.Client/test/config/karma.conf.js +++ b/src/Umbraco.Web.UI.Client/test/config/karma.conf.js @@ -113,6 +113,12 @@ module.exports = function (config) { nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element properties: {} // key value pair of properties to add to the section of the report + }, + + client: { + jasmine: { + random: false + } } }); }; diff --git a/src/Umbraco.Web.UI.Client/test/unit/app/propertyeditors/content-picker-controller.spec.js b/src/Umbraco.Web.UI.Client/test/unit/app/propertyeditors/content-picker-controller.spec.js index 238d77b5fe..49d8914ac6 100644 --- a/src/Umbraco.Web.UI.Client/test/unit/app/propertyeditors/content-picker-controller.spec.js +++ b/src/Umbraco.Web.UI.Client/test/unit/app/propertyeditors/content-picker-controller.spec.js @@ -12,6 +12,7 @@ describe('Content picker controller tests', function () { httpBackend = $httpBackend; scope = $rootScope.$new(); + scope.model = { alias: "property", value:"1233,1231,23121", @@ -86,28 +87,27 @@ describe('Content picker controller tests', function () { }); it("Adding an item should update renderModel, ids and model.value", function(){ + scope.add(item); scope.$apply(); - setTimeout(function(){ - expect(scope.renderModel.length).toBe(4); - expect(scope.model.value).toBe("1233,1231,23121,666"); - }, 1000); + httpBackend.flush(); + + expect(scope.renderModel.length).toBe(4); + expect(scope.model.value).toBe("1233,1231,23121,666"); }); it("Adding a duplicate item should note update renderModel, ids and model.value", function(){ scope.add(item); scope.$apply(); - setTimeout(function(){ - expect(scope.renderModel.length).toBe(4); - expect(scope.model.value).toBe("1233,1231,23121,666"); - }, 1000); + httpBackend.flush(); + expect(scope.renderModel.length).toBe(4); + expect(scope.model.value).toBe("1233,1231,23121,666"); scope.add(item); scope.$apply(); - setTimeout(function(){ - expect(scope.renderModel.length).toBe(4); - expect(scope.model.value).toBe("1233,1231,23121,666"); - }, 1000); + + expect(scope.renderModel.length).toBe(4); + expect(scope.model.value).toBe("1233,1231,23121,666"); }); }); diff --git a/src/Umbraco.Web.UI.Client/test/unit/app/templates/template-editor-controller.spec.js b/src/Umbraco.Web.UI.Client/test/unit/app/templates/template-editor-controller.spec.js index ac49709ee4..b4615eaad8 100644 --- a/src/Umbraco.Web.UI.Client/test/unit/app/templates/template-editor-controller.spec.js +++ b/src/Umbraco.Web.UI.Client/test/unit/app/templates/template-editor-controller.spec.js @@ -102,43 +102,6 @@ it("has ace editor", function () { expect(controller.editor).toBe(ace); }); - - it("sets masterpage on template", function () { - controller.setLayout = function() {}; - - controller.openMasterTemplateOverlay(); - setTimeout(function(){ - controller.masterTemplateOverlay.submit({ - selectedItem: { - alias: "NewMasterPage" - } - }); - expect(controller.template.masterTemplateAlias).toBe("NewMasterPage"); - }, 1000); - }); - - //// TODO: THIS FAILED - //it("changes layout value when masterpage is selected", function() { - // var newTemplate; - // ace.clearSelection = nada; - // ace.navigateFileStart = nada; - // ace.getValue = function () { - // return "@{ Layout = null; }"; - // } - // ace.setValue = function (value) { - // newTemplate = value; - // } - - // controller.openMasterTemplateOverlay(); - // setTimeout(function(){ - // controller.masterTemplateOverlay.submit({ - // selectedItem: { - // alias: "NewMasterPage" - // } - // }); - // expect(newTemplate).toBe("@{ Layout = \"NewMasterPage.cshtml\"; }"); - // }, 1000); - //}); });