@@ -17,7 +17,7 @@ import {
1717} from '../../../../remote-data.utils' ;
1818import { ComcolMetadataComponent } from './comcol-metadata.component' ;
1919
20- describe ( 'ComColMetadataComponent' , ( ) => {
20+ fdescribe ( 'ComColMetadataComponent' , ( ) => {
2121 let comp : ComcolMetadataComponent < any > ;
2222 let fixture : ComponentFixture < ComcolMetadataComponent < any > > ;
2323 let dsoDataService ;
@@ -29,8 +29,6 @@ describe('ComColMetadataComponent', () => {
2929 let routerStub ;
3030 let routeStub ;
3131
32- const logoEndpoint = 'rest/api/logo/endpoint' ;
33-
3432 function initializeVars ( ) {
3533 community = Object . assign ( new Community ( ) , {
3634 uuid : 'a20da287-e174-466a-9926-f66b9300d347' ,
@@ -51,7 +49,6 @@ describe('ComColMetadataComponent', () => {
5149 communityDataServiceStub = {
5250 update : ( com , uuid ?) => createSuccessfulRemoteDataObject$ ( newCommunity ) ,
5351 patch : ( ) => null ,
54- getLogoEndpoint : ( ) => observableOf ( logoEndpoint )
5552 } ;
5653
5754 routerStub = {
@@ -118,7 +115,6 @@ describe('ComColMetadataComponent', () => {
118115 }
119116 /* eslint-enable no-empty,@typescript-eslint/no-empty-function */
120117 } ,
121- deleteLogo : false ,
122118 } ;
123119 spyOn ( router , 'navigate' ) ;
124120 } ) ;
@@ -150,48 +146,84 @@ describe('ComColMetadataComponent', () => {
150146 } ) ;
151147 } ) ;
152148
153- describe ( 'with at least one item in the uploader\'s queue ' , ( ) => {
149+ describe ( 'with an empty operations array ' , ( ) => {
154150 beforeEach ( ( ) => {
155151 data = {
156- dso : Object . assign ( new Community ( ) , {
157- metadata : [ {
158- key : 'dc.title' ,
159- value : 'test'
160- } ]
161- } ) ,
152+ operations : [ ] ,
153+ dso : new Community ( ) ,
162154 uploader : {
163155 options : {
164156 url : ''
165157 } ,
166- queue : [
167- { }
168- ] ,
158+ queue : [ ] ,
169159 /* eslint-disable no-empty,@typescript-eslint/no-empty-function */
170160 uploadAll : ( ) => {
171161 }
172- /* eslint-enable no-empty, @typescript-eslint/no-empty-function */
173- }
162+ /* eslint-enable no-empty,@typescript-eslint/no-empty-function */
163+ } ,
174164 } ;
165+ spyOn ( router , 'navigate' ) ;
175166 } ) ;
176167
177- it ( 'should not navigate' , ( ) => {
178- spyOn ( router , 'navigate' ) ;
168+ it ( 'should navigate' , ( ) => {
179169 comp . onSubmit ( data ) ;
180170 fixture . detectChanges ( ) ;
181- expect ( router . navigate ) . not . toHaveBeenCalled ( ) ;
171+ expect ( router . navigate ) . toHaveBeenCalled ( ) ;
182172 } ) ;
173+ } ) ;
183174
184- it ( 'should set the uploader\'s url to the logo\'s endpoint' , ( ) => {
185- comp . onSubmit ( data ) ;
186- fixture . detectChanges ( ) ;
187- expect ( data . uploader . options . url ) . toEqual ( logoEndpoint ) ;
175+ describe ( 'with a not empty operations array' , ( ) => {
176+ beforeEach ( ( ) => {
177+ data = {
178+ operations : [
179+ {
180+ op : 'replace' ,
181+ path : '/metadata/dc.title' ,
182+ value : {
183+ value : 'test' ,
184+ language : null ,
185+ } ,
186+ } ,
187+ ] ,
188+ dso : new Community ( ) ,
189+ uploader : {
190+ options : {
191+ url : ''
192+ } ,
193+ queue : [ ] ,
194+ /* eslint-disable no-empty,@typescript-eslint/no-empty-function */
195+ uploadAll : ( ) => {
196+ }
197+ /* eslint-enable no-empty,@typescript-eslint/no-empty-function */
198+ } ,
199+ } ;
200+ spyOn ( router , 'navigate' ) ;
188201 } ) ;
189202
190- it ( 'should call the uploader\'s uploadAll' , ( ) => {
191- spyOn ( data . uploader , 'uploadAll' ) ;
192- comp . onSubmit ( data ) ;
193- fixture . detectChanges ( ) ;
194- expect ( data . uploader . uploadAll ) . toHaveBeenCalled ( ) ;
203+ describe ( 'when successful' , ( ) => {
204+
205+ beforeEach ( ( ) => {
206+ spyOn ( dsoDataService , 'patch' ) . and . returnValue ( createSuccessfulRemoteDataObject$ ( { } ) ) ;
207+ } ) ;
208+
209+ it ( 'should navigate' , ( ) => {
210+ comp . onSubmit ( data ) ;
211+ fixture . detectChanges ( ) ;
212+ expect ( router . navigate ) . toHaveBeenCalled ( ) ;
213+ } ) ;
214+ } ) ;
215+
216+ describe ( 'on failure' , ( ) => {
217+
218+ beforeEach ( ( ) => {
219+ spyOn ( dsoDataService , 'patch' ) . and . returnValue ( createFailedRemoteDataObject$ ( 'Error' , 500 ) ) ;
220+ } ) ;
221+
222+ it ( 'should not navigate' , ( ) => {
223+ comp . onSubmit ( data ) ;
224+ fixture . detectChanges ( ) ;
225+ expect ( router . navigate ) . not . toHaveBeenCalled ( ) ;
226+ } ) ;
195227 } ) ;
196228 } ) ;
197229 } ) ;
0 commit comments