diff --git a/src/Umbraco.Web.UI.Client/src/common/mocks/resources/content.resource.js b/src/Umbraco.Web.UI.Client/src/common/mocks/resources/content.mocks.js similarity index 92% rename from src/Umbraco.Web.UI.Client/src/common/mocks/resources/content.resource.js rename to src/Umbraco.Web.UI.Client/src/common/mocks/resources/content.mocks.js index 50790fbaa0..0e2c57d442 100644 --- a/src/Umbraco.Web.UI.Client/src/common/mocks/resources/content.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/mocks/resources/content.mocks.js @@ -1,8 +1,8 @@ -angular.module('umbraco.mocks'). - factory('contentMocks', ['$httpBackend', 'mocksUtills', function ($httpBackend, mocksUtills) { - 'use strict'; - - function returnNodebyId(status, data, headers) { +angular.module('umbraco.mocks'). + factory('contentMocks', ['$httpBackend', 'mocksUtills', function ($httpBackend, mocksUtills) { + 'use strict'; + + function returnNodebyId(status, data, headers) { var id = mocksUtills.getParameterByName(data, "id") || 1234; var node = { @@ -74,18 +74,19 @@ angular.module('umbraco.mocks'). ] }; return [200, node, null]; - } - - - - return { - register: function() { - - $httpBackend - .whenGET(mocksUtills.urlRegex('/umbraco/UmbracoApi/Content/GetById')) - .respond(returnNodebyId); - - - } - }; + } + + + + return { + register: function() { + $httpBackend + .whenGET(mocksUtills.urlRegex('/umbraco/UmbracoApi/Content/GetById')) + .respond(returnNodebyId); + }, + expectGetById: function() { + $httpBackend + .expectGET(mocksUtills.urlRegex('/umbraco/UmbracoApi/Content/GetById')); + } + }; }]); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/common/mocks/resources/contenttype.resource.js b/src/Umbraco.Web.UI.Client/src/common/mocks/resources/contenttype.mocks.js similarity index 82% rename from src/Umbraco.Web.UI.Client/src/common/mocks/resources/contenttype.resource.js rename to src/Umbraco.Web.UI.Client/src/common/mocks/resources/contenttype.mocks.js index 1f23b2c602..fdc15f5b30 100644 --- a/src/Umbraco.Web.UI.Client/src/common/mocks/resources/contenttype.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/mocks/resources/contenttype.mocks.js @@ -3,22 +3,24 @@ angular.module('umbraco.mocks'). 'use strict'; function returnAllowedChildren(status, data, headers) { - var types = [ - { name: "News Article", description: "Standard news article", alias: "newsArticle", id: 1234, cssClass: "file" }, - { name: "News Area", description: "Area to hold all news articles, there should be only one", alias: "newsArea", id: 1234, cssClass: "suitcase" }, - { name: "Employee", description: "Employee profile information page", alias: "employee", id: 1234, cssClass: "user" } - ]; - + var types = [ + { name: "News Article", description: "Standard news article", alias: "newsArticle", id: 1234, cssClass: "file" }, + { name: "News Area", description: "Area to hold all news articles, there should be only one", alias: "newsArea", id: 1234, cssClass: "suitcase" }, + { name: "Employee", description: "Employee profile information page", alias: "employee", id: 1234, cssClass: "user" } + ]; return [200, types, null]; } return { register: function() { - - $httpBackend - .whenGET(mocksUtills.urlRegex('/umbraco/Api/')) + $httpBackend + .whenGET(mocksUtills.urlRegex('/umbraco/Api/')) .respond(returnAllowedChildren); + }, + expectAllowedChildren: function(){ + console.log("expecting get"); + $httpBackend.expectGET(mocksUtills.urlRegex('/umbraco/Api/')); } }; }]); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/common/mocks/resources/tree.resource.js b/src/Umbraco.Web.UI.Client/src/common/mocks/resources/tree.mocks.js similarity index 100% rename from src/Umbraco.Web.UI.Client/src/common/mocks/resources/tree.resource.js rename to src/Umbraco.Web.UI.Client/src/common/mocks/resources/tree.mocks.js diff --git a/src/Umbraco.Web.UI.Client/src/common/mocks/resources/user.resource.js b/src/Umbraco.Web.UI.Client/src/common/mocks/resources/user.mocks.js similarity index 100% rename from src/Umbraco.Web.UI.Client/src/common/mocks/resources/user.resource.js rename to src/Umbraco.Web.UI.Client/src/common/mocks/resources/user.mocks.js diff --git a/src/Umbraco.Web.UI.Client/src/common/mocks/umbraco.httpbackend.js b/src/Umbraco.Web.UI.Client/src/common/mocks/umbraco.httpbackend.js index f32dcb6971..3f39a186b0 100644 --- a/src/Umbraco.Web.UI.Client/src/common/mocks/umbraco.httpbackend.js +++ b/src/Umbraco.Web.UI.Client/src/common/mocks/umbraco.httpbackend.js @@ -1,8 +1,10 @@ -var umbracoAppDev = angular.module('umbraco.httpbackend', ['umbraco', 'ngMockE2E', 'umbraco.mocks']); - - +var umbracoAppDev = angular.module('umbraco.httpbackend', ['umbraco', 'ngMockE2E', 'umbraco.mocks']); + + function initBackEnd($httpBackend, contentMocks, treeMocks, userMocks, contentTypeMocks, sectionMocks) { + console.log("httpBackend inited"); + //Register mocked http responses contentMocks.register(); sectionMocks.register(); @@ -10,14 +12,14 @@ function initBackEnd($httpBackend, contentMocks, treeMocks, userMocks, contentTy userMocks.register(); - contentTypeMocks.register(); - - $httpBackend.whenGET(/^views\//).passThrough(); - $httpBackend.whenGET(/^js\//).passThrough(); - $httpBackend.whenGET(/^lib\//).passThrough(); - $httpBackend.whenGET(/^assets\//).passThrough(); -} - - - -umbracoAppDev.run(initBackEnd); + contentTypeMocks.register(); + + $httpBackend.whenGET(/^views\//).passThrough(); + $httpBackend.whenGET(/^js\//).passThrough(); + $httpBackend.whenGET(/^lib\//).passThrough(); + $httpBackend.whenGET(/^assets\//).passThrough(); +} + + + +umbracoAppDev.run(initBackEnd); diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js index 544afd4b17..9ab49814a8 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js @@ -35,14 +35,10 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) { var deferred = $q.defer(); - - + //go and get the data $http.get(getContentUrl(id)). success(function (data, status, headers, config) { - - console.log("getting by id success"); - //set the first tab to active _.each(data.tabs, function (item) { item.active = false; @@ -54,7 +50,6 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) { deferred.resolve(data); }). error(function (data, status, headers, config) { - console.log("getting by id - error"); deferred.reject('Failed to retreive data for content id ' + id); }); diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js index 4e1a917c2b..b9baa4655d 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/contenttype.resource.js @@ -43,23 +43,14 @@ function contentTypeResource($q, $http) { //return all types allowed under given document getAllowedTypes: function (contentId) { - - var deferred = $q.defer(); - - //go and get the tree data - $http.get(getChildContentTypesUrl(contentId)). - success(function (data, status, headers, config) { - - console.log("success"); - + $http.get(getChildContentTypesUrl(contentId)) + .success(function (data, status, headers, config) { deferred.resolve(data); }). error(function (data, status, headers, config) { - console.log("wrong"); deferred.reject('Failed to retreive data for content id ' + contentId); }); - return deferred.promise; } diff --git a/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js b/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js index 33a3ea85c2..a1c8228c4a 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js @@ -8,8 +8,8 @@ angular.module('umbraco.services') } var scope = options.scope || $rootScope.$new(), - animationClass = options.animation || "slide", - modalClass = options.modalClass || "", + animationClass = options.animation || "fade", + modalClass = options.modalClass || "umb-modalcolumn", templateUrl = options.template || "views/common/notfound.html"; var callback = options.callback; @@ -43,7 +43,7 @@ angular.module('umbraco.services') }; scope.hide = function() { - $modal.modal('hide'); + $modal.modal('hide'); $('body').remove($modal); }; 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 a96be3dbc9..7cf382db79 100644 --- a/src/Umbraco.Web.UI.Client/test/config/karma.conf.js +++ b/src/Umbraco.Web.UI.Client/test/config/karma.conf.js @@ -45,7 +45,7 @@ module.exports = function(karma) { // level of logging // possible values: karma.LOG_DISABLE || karma.LOG_ERROR || karma.LOG_WARN || karma.LOG_INFO || karma.LOG_DEBUG // CLI --log-level debug - logLevel: karma.LOG_DEBUG, + logLevel: karma.LOG_INFO, // enable / disable watching file and executing tests whenever any file changes // CLI --auto-watch --no-auto-watch diff --git a/src/Umbraco.Web.UI.Client/test/unit/common/services/contentFactory.spec.js b/src/Umbraco.Web.UI.Client/test/unit/common/services/contentFactory.spec.js index bb5da902fa..4eb229b1d2 100644 --- a/src/Umbraco.Web.UI.Client/test/unit/common/services/contentFactory.spec.js +++ b/src/Umbraco.Web.UI.Client/test/unit/common/services/contentFactory.spec.js @@ -1,44 +1,39 @@ describe('content factory tests', function () { - var $rootScope, $httpBackend, contentFactory; + var $rootScope, $httpBackend, contentFactory, mocks, $http; beforeEach(module('umbraco.services')); beforeEach(module('umbraco.resources')); beforeEach(module('umbraco.httpbackend')); beforeEach(inject(function ($injector) { - $rootScope = $injector.get('$rootScope'); + $rootScope = $injector.get('$rootScope'); $httpBackend = $injector.get('$httpBackend'); + mocks = $injector.get("contentMocks"); + mocks.register(); contentFactory = $injector.get('contentResource'); })); - afterEach(function () { - $httpBackend.verifyNoOutstandingExpectation(); - $httpBackend.verifyNoOutstandingRequest(); + + afterEach(function () { + $httpBackend.verifyNoOutstandingExpectation(); + $httpBackend.verifyNoOutstandingRequest(); }); describe('global content factory crud', function () { - it('should return a content object, given an id', function () { - var doc = "meh"; - contentFactory.getById(1234).then(function (result) { - doc = result; - }); - - console.log("doc:", doc); - $rootScope.$root.$digest(); - - - //$scope.$apply(); - - //.then(function (doc1) { - console.log("doc:", doc); - - expect(doc).toNotBe(undefined); - expect(doc.id).toBe(1234); - //}); - + it('should return a content object, given an id', function () { + var doc; + contentFactory.getById(1234).then(function(result){ + doc = result; + }); + + $rootScope.$digest(); + + expect(doc).toNotBe(undefined); + expect(doc.id).toBe(1234); }); + it('should return a content children collection given an id', function () { var collection = contentFactory.getChildren(1234, undefined); expect(collection.resultSet.length).toBe(10); diff --git a/src/Umbraco.Web.UI.Client/test/unit/common/services/contenttypeFactory.spec.js b/src/Umbraco.Web.UI.Client/test/unit/common/services/contenttypeFactory.spec.js index 4057238d53..2af946c46c 100644 --- a/src/Umbraco.Web.UI.Client/test/unit/common/services/contenttypeFactory.spec.js +++ b/src/Umbraco.Web.UI.Client/test/unit/common/services/contenttypeFactory.spec.js @@ -1,34 +1,50 @@ describe('content type factory tests', function () { - var $rootScope, contentTypeResource; + var $rootScope, $httpBackend, contentTypeResource, m; + beforeEach(module('ngMockE2E')); beforeEach(module('umbraco.resources')); beforeEach(module('umbraco.httpbackend')); - beforeEach(inject(function ($injector) { - $rootScope = $injector.get('$rootScope'); + beforeEach(inject(function ($injector, contentTypeMocks) { + $rootScope = $injector.get('$rootScope'); + $httpBackend = $injector.get('$httpBackend'); + m = contentTypeMocks; + m.register(); + contentTypeResource = $injector.get('contentTypeResource'); })); + describe('global content type factory crud', function () { it('should return a content type object, given an id', function () { - var ct1 = contentTypeResource.getContentType(1234); - - $rootScope.$digest(); - + + var ct1; + contentTypeResource.getContentType(1234).then(function(result){ + ct1 = result; + }); + + $rootScope.$digest(); + $rootScope.$apply(); + console.log("ct1:", ct1); expect(ct1).toNotBe(undefined); expect(ct1.id).toBe(1234); }); - - it('should return a allowed content type collection given a document id', function(){ - // var collection = contentTypeResource.getAllowedTypes(1234); - // $rootScope.$apply(); - // console.log("running test", angular.toJson(collection)); - // expect(collection.length).toBe(3); + m.expectAllowedChildren(); + + var collection; + contentTypeResource.getAllowedTypes(1234).then(function(result){ + collection = result; + }); + + + $rootScope.$digest(); + $rootScope.$apply(); + expect(collection.length).toBe(3); }); }); }); \ No newline at end of file diff --git a/src/Umbraco.Web.UI/umbraco/index.html b/src/Umbraco.Web.UI/umbraco/index.html index cd60633009..d715deb792 100644 --- a/src/Umbraco.Web.UI/umbraco/index.html +++ b/src/Umbraco.Web.UI/umbraco/index.html @@ -1,30 +1,30 @@ - - - - - - - - Umbraco - - - - -
- - - -
-
-
-
-
-
- - - - - - - - + + + + + + + + Umbraco + + + + +
+ + + +
+
+
+
+
+
+ + + + + + + +