Fixes failing tests
Adds a seperate unit test app loader, removes e2e backend from tests adds scope.digest and httpbackend.flush to tests
This commit is contained in:
@@ -103,11 +103,10 @@ angular.module('umbraco.mocks').
|
||||
.whenGET(mocksUtills.urlRegex('/umbraco/UmbracoApi/Content/GetById'))
|
||||
.respond(returnNodebyId);
|
||||
|
||||
|
||||
$httpBackend
|
||||
.whenGET(mocksUtills.urlRegex('/umbraco/UmbracoApi/Content/GetEmpty'))
|
||||
.respond(returnEmptyNode);
|
||||
|
||||
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ yepnope({
|
||||
'lib/umbraco/Extensions.js',
|
||||
|
||||
'js/umbraco.servervariables.js',
|
||||
'js/app_dev.js',
|
||||
'js/app.dev.js',
|
||||
'js/umbraco.httpbackend.js',
|
||||
'js/umbraco.testing.js',
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
var app = angular.module('umbraco', [
|
||||
'umbraco.filters',
|
||||
'umbraco.directives',
|
||||
'umbraco.resources',
|
||||
'umbraco.services',
|
||||
'umbraco.mocks',
|
||||
'umbraco.security'
|
||||
]);
|
||||
@@ -12,13 +12,16 @@ module.exports = function(karma) {
|
||||
'lib/underscore/underscore.js',
|
||||
'test/lib/angular/angular-mocks.js',
|
||||
'lib/umbraco/Extensions.js',
|
||||
'src/app_dev.js',
|
||||
|
||||
'test/config/app.unit.js',
|
||||
'src/common/mocks/umbraco.servervariables.js',
|
||||
|
||||
'src/common/directives/*.js',
|
||||
'src/common/filters/*.js',
|
||||
'src/common/services/*.js',
|
||||
'src/common/security/*.js',
|
||||
'src/common/resources/*.js',
|
||||
'src/common/mocks/**/*.js',
|
||||
'src/common/mocks/resources/*.js',
|
||||
'src/views/**/*.controller.js',
|
||||
'test/unit/**/*.spec.js'
|
||||
],
|
||||
|
||||
@@ -4,10 +4,15 @@ describe('edit content controller tests', function () {
|
||||
|
||||
beforeEach(module('umbraco'));
|
||||
|
||||
beforeEach(inject(function ($rootScope, $controller, angularHelper, $httpBackend) {
|
||||
//inject the contentMocks service
|
||||
beforeEach(inject(function ($rootScope, $controller, angularHelper, $httpBackend, contentMocks) {
|
||||
httpBackend = $httpBackend;
|
||||
scope = $rootScope.$new();
|
||||
|
||||
//have the contentMocks register its expect urls on the httpbackend
|
||||
//see /mocks/content.mocks.js for how its setup
|
||||
contentMocks.register();
|
||||
|
||||
//this controller requires an angular form controller applied to it
|
||||
scope.contentForm = angularHelper.getNullForm("contentForm");
|
||||
|
||||
@@ -15,6 +20,15 @@ describe('edit content controller tests', function () {
|
||||
$scope: scope,
|
||||
$routeParams: routeParams
|
||||
});
|
||||
|
||||
//For controller tests its easiest to have the digest and flush happen here
|
||||
//since its intially always the same $http calls made
|
||||
|
||||
//scope.$digest resolves the promise against the httpbackend
|
||||
scope.$digest();
|
||||
//httpbackend.flush() resolves all request against the httpbackend
|
||||
//to fake a async response, (which is what happens on a real setup)
|
||||
httpBackend.flush();
|
||||
}));
|
||||
|
||||
describe('content edit controller save and publish', function () {
|
||||
@@ -35,52 +49,45 @@ describe('edit content controller tests', function () {
|
||||
expect(scope.files[0].file).toBe("testFile2");
|
||||
});
|
||||
|
||||
//it('it should have an content object', function() {
|
||||
it('it should have an content object', function() {
|
||||
|
||||
/*
|
||||
NOTE: I cannot figure out how to make this work... I've followed along with a few sources like:
|
||||
http://stackoverflow.com/questions/15833462/angularjs-need-help-to-unit-test-a-factory-with-promise
|
||||
http://www.benlesh.com/2013/05/angularjs-unit-testing-controllers.html
|
||||
//controller should have a content object
|
||||
expect(scope.content).toNotBe(undefined);
|
||||
|
||||
But it tells me that there is no pending request to flush, so dunno what is going on there?
|
||||
*/
|
||||
//if should be the same as the routeParams defined one
|
||||
expect(scope.content.id).toBe(1234);
|
||||
});
|
||||
|
||||
// httpBackend.flush();
|
||||
it('it should have a tabs collection', function () {
|
||||
expect(scope.content.tabs.length).toBe(5);
|
||||
});
|
||||
|
||||
// rootScope.$apply();
|
||||
it('it should have a properties collection on each tab', function () {
|
||||
$(scope.content.tabs).each(function(i, tab){
|
||||
expect(tab.properties.length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
// expect(scope.content).toNotBe(undefined);
|
||||
// //expect(scope.content.id).toBe(1234);
|
||||
//});
|
||||
it('it should change updateDate on save', function () {
|
||||
var currentUpdateDate = scope.content.updateDate;
|
||||
|
||||
//it('it should have a tabs collection', function () {
|
||||
// expect(scope.content.tabs.length).toBe(5);
|
||||
//});
|
||||
setTimeout(function(){
|
||||
scope.save(scope.content);
|
||||
expect(scope.content.updateDate).toBeGreaterThan(currentUpdateDate);
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
//it('it should have a properties collection on each tab', function () {
|
||||
// $(scope.content.tabs).each(function(i, tab){
|
||||
// expect(tab.properties.length).toBeGreaterThan(0);
|
||||
// });
|
||||
//});
|
||||
it('it should change publishDate on publish', function () {
|
||||
var currentPublishDate = scope.content.publishDate;
|
||||
|
||||
//it('it should change updateDate on save', function () {
|
||||
// var currentUpdateDate = scope.content.updateDate;
|
||||
|
||||
// setTimeout(function(){
|
||||
// scope.save(scope.content);
|
||||
// expect(scope.content.updateDate).toBeGreaterThan(currentUpdateDate);
|
||||
// }, 1000);
|
||||
// });
|
||||
|
||||
//it('it should change publishDate on publish', function () {
|
||||
// var currentPublishDate = scope.content.publishDate;
|
||||
|
||||
// //wait a sec before you publish
|
||||
// setTimeout(function(){
|
||||
// scope.saveAndPublish(scope.content);
|
||||
// expect(scope.content.publishDate).toBeGreaterThan(currentPublishDate);
|
||||
// }, 1000);
|
||||
//});
|
||||
//wait a sec before you publish
|
||||
setTimeout(function(){
|
||||
scope.saveAndPublish(scope.content);
|
||||
|
||||
expect(scope.content.publishDate).toBeGreaterThan(currentPublishDate);
|
||||
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<base href="/belle/" />
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Umbraco</title>
|
||||
<link rel="stylesheet" href="assets/css/umbraco.css" />
|
||||
</head>
|
||||
<body ng-controller="MainController" id="umbracoMainPageBody">
|
||||
|
||||
<div ng-hide="!authenticated" ng-cloak ng-animate="'fade'" id="Div1" class="clearfix" ng-click="closeDialogs($event)">
|
||||
|
||||
<umb-left-column></umb-left-column>
|
||||
|
||||
<section id="contentwrapper">
|
||||
<div id="contentcolumn">
|
||||
<div ng-view></div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<umb-notifications></umb-notifications>
|
||||
|
||||
|
||||
<script src="lib/yepnope/yepnope.min.js"></script>
|
||||
<script src="js/loader.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<base href="/belle/" />
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Umbraco</title>
|
||||
<link rel="stylesheet" href="assets/css/umbraco.css" />
|
||||
</head>
|
||||
<body ng-controller="MainController" id="umbracoMainPageBody">
|
||||
|
||||
<div ng-hide="!authenticated" ng-cloak ng-animate="'fade'" id="Div1" class="clearfix" ng-click="closeDialogs($event)">
|
||||
|
||||
<umb-left-column></umb-left-column>
|
||||
|
||||
<section id="contentwrapper">
|
||||
<div id="contentcolumn">
|
||||
<div ng-view></div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<umb-notifications></umb-notifications>
|
||||
|
||||
|
||||
<script src="lib/yepnope/yepnope.min.js"></script>
|
||||
<script src="js/loader.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
var app = angular.module('umbraco', [
|
||||
'umbraco.filters',
|
||||
'umbraco.directives',
|
||||
'umbraco.resources',
|
||||
'umbraco.services',
|
||||
'umbraco.httpbackend',
|
||||
'umbraco.security'
|
||||
]);
|
||||
@@ -10,7 +10,7 @@ yepnope({
|
||||
'lib/umbraco/Extensions.js',
|
||||
|
||||
'js/umbraco.servervariables.js',
|
||||
'js/app_dev.js',
|
||||
'js/app.dev.js',
|
||||
'js/umbraco.httpbackend.js',
|
||||
'js/umbraco.testing.js',
|
||||
|
||||
|
||||
Reference in New Issue
Block a user