|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +describe('docker-registry-frontend', function() { |
| 4 | + var $route, $location, $rootScope, $httpBackend; |
| 5 | + |
| 6 | + beforeEach(module('docker-registry-frontend')); |
| 7 | + beforeEach(inject(function(_$route_, _$location_, _$rootScope_, _$httpBackend_) { |
| 8 | + $route = _$route_; |
| 9 | + $location = _$location_; |
| 10 | + $rootScope = _$rootScope_; |
| 11 | + $httpBackend = _$httpBackend_; |
| 12 | + })); |
| 13 | + |
| 14 | + it('/home should display home page', function() { |
| 15 | + $httpBackend.expectGET('home.html').respond(200); |
| 16 | + $location.path('/home'); |
| 17 | + $rootScope.$digest(); |
| 18 | + expect($route.current.templateUrl).toBe('home.html'); |
| 19 | + expect($route.current.controller).toBe('HomeController'); |
| 20 | + }); |
| 21 | + |
| 22 | + it('/repositories should display repository list page', function() { |
| 23 | + $httpBackend.expectGET('repository/repository-list.html').respond(200); |
| 24 | + $location.path('/repositories'); |
| 25 | + $rootScope.$digest(); |
| 26 | + expect($route.current.templateUrl).toBe('repository/repository-list.html'); |
| 27 | + expect($route.current.controller).toBe('RepositoryListController'); |
| 28 | + }); |
| 29 | + |
| 30 | + it('/repositories/10 should display repository list page', function() { |
| 31 | + $httpBackend.expectGET('repository/repository-list.html').respond(200); |
| 32 | + $location.path('/repositories/10'); |
| 33 | + $rootScope.$digest(); |
| 34 | + expect($route.current.templateUrl).toBe('repository/repository-list.html'); |
| 35 | + expect($route.current.controller).toBe('RepositoryListController'); |
| 36 | + }); |
| 37 | + |
| 38 | + it('/repositories/20 should display repository list page', function() { |
| 39 | + $httpBackend.expectGET('repository/repository-list.html').respond(200); |
| 40 | + $location.path('/repositories/20'); |
| 41 | + $rootScope.$digest(); |
| 42 | + expect($route.current.templateUrl).toBe('repository/repository-list.html'); |
| 43 | + expect($route.current.controller).toBe('RepositoryListController'); |
| 44 | + }); |
| 45 | + |
| 46 | + it('URL with repositoryUser and repositoryName and no tagsPerPage should display repository detail page', function() { |
| 47 | + $httpBackend.expectGET('repository/repository-detail.html').respond(200); |
| 48 | + $location.path('/repository/owner/name'); |
| 49 | + $rootScope.$digest(); |
| 50 | + expect($route.current.templateUrl).toBe('repository/repository-detail.html'); |
| 51 | + expect($route.current.controller).toBe('RepositoryDetailController'); |
| 52 | + }); |
| 53 | + |
| 54 | + it('URL with repositoryUser and repositoryName and tagsPerPage should display repository detail page', function() { |
| 55 | + $httpBackend.expectGET('repository/repository-detail.html').respond(200); |
| 56 | + $location.path('/repository/owner/name/10'); |
| 57 | + $rootScope.$digest(); |
| 58 | + expect($route.current.templateUrl).toBe('repository/repository-detail.html'); |
| 59 | + expect($route.current.controller).toBe('RepositoryDetailController'); |
| 60 | + }); |
| 61 | + |
| 62 | + // This test currently fails; this URL is incorrectly routing to the home page |
| 63 | + // @todo @FIXME |
| 64 | + // |
| 65 | + // it('URL with repositoryName but no repositoryUser and no tagsPerPage should display repository detail page', function() { |
| 66 | + // $httpBackend.expectGET('repository/repository-detail.html').respond(200); |
| 67 | + // $location.path('/repository/cx'); |
| 68 | + // $rootScope.$digest(); |
| 69 | + // expect($route.current.templateUrl).toBe('repository/repository-detail.html'); |
| 70 | + // expect($route.current.controller).toBe('RepositoryDetailController'); |
| 71 | + // }); |
| 72 | + |
| 73 | + it('URL with repositoryName but no repositoryUser and tagsPerPage should display repository detail page', function() { |
| 74 | + $httpBackend.expectGET('repository/repository-detail.html').respond(200); |
| 75 | + $location.path('/repository/cx/10'); |
| 76 | + $rootScope.$digest(); |
| 77 | + expect($route.current.templateUrl).toBe('repository/repository-detail.html'); |
| 78 | + expect($route.current.controller).toBe('RepositoryDetailController'); |
| 79 | + }); |
| 80 | + |
| 81 | + it('/about should display about page', function() { |
| 82 | + $httpBackend.expectGET('about.html').respond(200); |
| 83 | + $location.path('/about'); |
| 84 | + $rootScope.$digest(); |
| 85 | + expect($route.current.templateUrl).toBe('about.html'); |
| 86 | + }); |
| 87 | + |
| 88 | + it('/tag/repositoryUser/repositoryName/latest should display tag detail page', function() { |
| 89 | + $httpBackend.expectGET('tag/tag-detail.html').respond(200); |
| 90 | + $location.path('/tag/repositoryUser/repositoryName/latest'); |
| 91 | + $rootScope.$digest(); |
| 92 | + expect($route.current.templateUrl).toBe('tag/tag-detail.html'); |
| 93 | + expect($route.current.controller).toBe('TagController'); |
| 94 | + }); |
| 95 | + |
| 96 | + // This test currently fails; this URL is incorrectly routing to the home page |
| 97 | + // @todo @FIXME |
| 98 | + // |
| 99 | + // it('/tag/repositoryName/latest should display tag detail page', function() { |
| 100 | + // $httpBackend.expectGET('tag/tag-detail.html').respond(200); |
| 101 | + // $location.path('/tag/repositoryName/latest'); |
| 102 | + // $rootScope.$digest(); |
| 103 | + // expect($route.current.templateUrl).toBe('tag/tag-detail.html'); |
| 104 | + // expect($route.current.controller).toBe('TagController'); |
| 105 | + // }); |
| 106 | + |
| 107 | + it('/image/88e37c7099fa should display image detail page', function() { |
| 108 | + $httpBackend.expectGET('tag/image-detail.html').respond(200); |
| 109 | + $location.path('/image/88e37c7099fa'); |
| 110 | + $rootScope.$digest(); |
| 111 | + expect($route.current.templateUrl).toBe('tag/image-detail.html'); |
| 112 | + expect($route.current.controller).toBe('ImageController'); |
| 113 | + }); |
| 114 | + |
| 115 | + it('/image/88e37c7099fa/tag should display create tag page', function() { |
| 116 | + $httpBackend.expectGET('tag/create-tag.html').respond(200); |
| 117 | + $location.path('/image/88e37c7099fa/tag'); |
| 118 | + $rootScope.$digest(); |
| 119 | + expect($route.current.templateUrl).toBe('tag/create-tag.html'); |
| 120 | + expect($route.current.controller).toBe('CreateTagController'); |
| 121 | + }); |
| 122 | + |
| 123 | + it('/unknown-url should display home page', function() { |
| 124 | + $httpBackend.expectGET('home.html').respond(200); |
| 125 | + $location.path('/unknown-url'); |
| 126 | + $rootScope.$digest(); |
| 127 | + expect($route.current.templateUrl).toBe('home.html'); |
| 128 | + expect($route.current.controller).toBe('HomeController'); |
| 129 | + }); |
| 130 | + |
| 131 | +}); |
0 commit comments