Skip to content

Commit 0b136f7

Browse files
author
Andrea Barbasso
committed
[DSC-2635] fix lint
1 parent 66fb436 commit 0b136f7

12 files changed

Lines changed: 87 additions & 81 deletions

File tree

src/app/core/locale/locale.service.spec.ts

Lines changed: 59 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import {
88
TranslateModule,
99
TranslateService,
1010
} from '@ngx-translate/core';
11-
import { of } from 'rxjs';
11+
import {
12+
of as observableOf,
13+
of,
14+
} from 'rxjs';
1215
import { TestScheduler } from 'rxjs/testing';
13-
import { of as observableOf } from 'rxjs';
1416

1517
import { CookieServiceMock } from '../../shared/mocks/cookie.service.mock';
1618
import { TranslateLoaderMock } from '../../shared/mocks/translate-loader.mock';
@@ -97,83 +99,83 @@ describe('LocaleService test suite', () => {
9799
});
98100

99101
describe('getCurrentLanguageCode', () => {
100-
let testScheduler: TestScheduler;
102+
let testScheduler: TestScheduler;
101103

102-
beforeEach(() => {
103-
spyOn(translateService, 'getLangs').and.returnValue(langList);
104-
testScheduler = new TestScheduler((actual, expected) => {
104+
beforeEach(() => {
105+
spyOn(translateService, 'getLangs').and.returnValue(langList);
106+
testScheduler = new TestScheduler((actual, expected) => {
105107
// use jasmine to test equality
106-
expect(actual).toEqual(expected);
108+
expect(actual).toEqual(expected);
109+
});
110+
authService.isAuthenticated.and.returnValue(of(false));
111+
authService.isAuthenticationLoaded.and.returnValue(of(false));
107112
});
108-
authService.isAuthenticated.and.returnValue(of(false));
109-
authService.isAuthenticationLoaded.and.returnValue(of(false));
110-
});
111113

112-
it('should return the language saved on cookie if it\'s a valid & active language', () => {
114+
it('should return the language saved on cookie if it\'s a valid & active language', () => {
113115
spyOnGet.and.returnValue('de');
114-
testScheduler.run(({ expectObservable }) => {
115-
expectObservable(service.getCurrentLanguageCode()).toBe('(a|)', { a: 'de' });
116-
});
116+
testScheduler.run(({ expectObservable }) => {
117+
expectObservable(service.getCurrentLanguageCode()).toBe('(a|)', { a: 'de' });
118+
});
117119
});
118120

119-
it('should return the default language if the cookie language is disabled', () => {
120-
spyOnGet.and.returnValue('disabled');
121-
testScheduler.run(({ expectObservable }) => {
122-
expectObservable(service.getCurrentLanguageCode()).toBe('(a|)', { a: 'en' });
121+
it('should return the default language if the cookie language is disabled', () => {
122+
spyOnGet.and.returnValue('disabled');
123+
testScheduler.run(({ expectObservable }) => {
124+
expectObservable(service.getCurrentLanguageCode()).toBe('(a|)', { a: 'en' });
125+
});
123126
});
124-
});
125127

126-
it('should return the default language if the cookie language does not exist', () => {
127-
spyOnGet.and.returnValue('does-not-exist');
128-
testScheduler.run(({ expectObservable }) => {
129-
expectObservable(service.getCurrentLanguageCode()).toBe('(a|)', { a: 'en' });
130-
});
128+
it('should return the default language if the cookie language does not exist', () => {
129+
spyOnGet.and.returnValue('does-not-exist');
130+
testScheduler.run(({ expectObservable }) => {
131+
expectObservable(service.getCurrentLanguageCode()).toBe('(a|)', { a: 'en' });
131132
});
132-
133-
it('should return language from browser setting', () => {
134-
spyOn(service, 'getLanguageCodeList').and.returnValue(of(['xx', 'en']));
135-
testScheduler.run(({ expectObservable }) => {
136-
expectObservable(service.getCurrentLanguageCode()).toBe('(a|)', { a: 'xx' });
137133
});
134+
135+
it('should return language from browser setting', () => {
136+
spyOn(service, 'getLanguageCodeList').and.returnValue(of(['xx', 'en']));
137+
testScheduler.run(({ expectObservable }) => {
138+
expectObservable(service.getCurrentLanguageCode()).toBe('(a|)', { a: 'xx' });
138139
});
140+
});
139141

140-
it('should match language from browser setting case insensitive', () => {
141-
spyOn(service, 'getLanguageCodeList').and.returnValue(of(['DE', 'en']));
142-
testScheduler.run(({ expectObservable }) => {
143-
expectObservable(service.getCurrentLanguageCode()).toBe('(a|)', { a: 'DE' });
142+
it('should match language from browser setting case insensitive', () => {
143+
spyOn(service, 'getLanguageCodeList').and.returnValue(of(['DE', 'en']));
144+
testScheduler.run(({ expectObservable }) => {
145+
expectObservable(service.getCurrentLanguageCode()).toBe('(a|)', { a: 'DE' });
146+
});
144147
});
145148
});
146-
});
147149

148-
describe('getLanguageCodeList', () => {
149-
let testScheduler: TestScheduler;
150+
describe('getLanguageCodeList', () => {
151+
let testScheduler: TestScheduler;
150152

151-
beforeEach(() => {
152-
spyOn(translateService, 'getLangs').and.returnValue(langList);
153-
testScheduler = new TestScheduler((actual, expected) => {
153+
beforeEach(() => {
154+
spyOn(translateService, 'getLangs').and.returnValue(langList);
155+
testScheduler = new TestScheduler((actual, expected) => {
154156
// use jasmine to test equality
155-
expect(actual).toEqual(expected);
157+
expect(actual).toEqual(expected);
158+
});
156159
});
157-
});
158160

159-
it('should return default language list without user preferred language when no logged in user', () => {
160-
authService.isAuthenticated.and.returnValue(of(false));
161-
authService.isAuthenticationLoaded.and.returnValue(of(false));
162-
testScheduler.run(({ expectObservable }) => {
163-
expectObservable(service.getLanguageCodeList()).toBe('(a|)', { a: ['en-US;q=1', 'en;q=0.9'] });
161+
it('should return default language list without user preferred language when no logged in user', () => {
162+
authService.isAuthenticated.and.returnValue(of(false));
163+
authService.isAuthenticationLoaded.and.returnValue(of(false));
164+
testScheduler.run(({ expectObservable }) => {
165+
expectObservable(service.getLanguageCodeList()).toBe('(a|)', { a: ['en-US;q=1', 'en;q=0.9'] });
166+
});
164167
});
165-
});
166168

167-
it('should return default language list with user preferred language when user is logged in', () => {
168-
authService.isAuthenticated.and.returnValue(of(true));
169-
authService.isAuthenticationLoaded.and.returnValue(of(true));
170-
authService.getAuthenticatedUserFromStore.and.returnValue(of(EPersonMock2));
171-
testScheduler.run(({ expectObservable }) => {
172-
expectObservable(service.getLanguageCodeList()).toBe('(a|)', { a: ['fr;q=0.5', 'en-US;q=1', 'en;q=0.9'] });
169+
it('should return default language list with user preferred language when user is logged in', () => {
170+
authService.isAuthenticated.and.returnValue(of(true));
171+
authService.isAuthenticationLoaded.and.returnValue(of(true));
172+
authService.getAuthenticatedUserFromStore.and.returnValue(of(EPersonMock2));
173+
testScheduler.run(({ expectObservable }) => {
174+
expectObservable(service.getLanguageCodeList()).toBe('(a|)', { a: ['fr;q=0.5', 'en-US;q=1', 'en;q=0.9'] });
175+
});
173176
});
174-
});
175177

176-
});
178+
});
177179

178180

179181
describe('getLanguageCodeFromCookie', () => {
@@ -204,13 +206,13 @@ describe('LocaleService test suite', () => {
204206
});
205207

206208
it('should set the current language', () => {
207-
spyOn(service, 'getCurrentLanguageCode').and.returnValue(of('es'));
209+
spyOn(service, 'getCurrentLanguageCode').and.returnValue(of('es'));
208210
service.setCurrentLanguageCode();
209211
expect(translateService.use).toHaveBeenCalledWith('es');
210212
});
211213

212214
it('should set the current language on the html tag', () => {
213-
spyOn(service, 'getCurrentLanguageCode').and.returnValue(of('es'));
215+
spyOn(service, 'getCurrentLanguageCode').and.returnValue(of('es'));
214216
service.setCurrentLanguageCode();
215217
expect((service as any).document.documentElement.lang).toEqual('es');
216218
});

src/app/core/shared/metadata.utils.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const testMethod = (fn, resultKind, mapOrMaps, keyOrKeys, hitHighlights, expecte
5454
const keys = keyOrKeys instanceof Array ? keyOrKeys : [keyOrKeys];
5555
describe('and key' + (keys.length === 1 ? (' ' + keys[0]) : ('s ' + JSON.stringify(keys)))
5656
+ ' with ' + (isUndefined(filter) ? 'no filter' : 'filter ' + JSON.stringify(filter)), () => {
57-
const result = fn(mapOrMaps, keys, hitHighlights, filter, undefined, limit);
57+
const result = fn(mapOrMaps, keys, hitHighlights, filter, undefined, limit);
5858
let shouldReturn;
5959
if (resultKind === 'boolean') {
6060
shouldReturn = expected;

src/app/core/shared/metadata.utils.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,19 @@ export class Metadata {
7979
for (const mdKey of Metadata.resolveKeys(mdMap, keyOrKeys)) {
8080
if (mdMap[mdKey]) {
8181
for (const candidate of mdMap[mdKey]) {
82-
if (Metadata.valueMatches(candidate as MetadataValue, filter)) {
83-
if (escapeHTML) {
84-
matches.push(Object.assign(new MetadataValue(), candidate, {
85-
value: escape(candidate.value),
86-
}));
87-
} else {
88-
matches.push(candidate as MetadataValue);
89-
}
90-
if (hasValue(limit) && matches.length >= limit) {
91-
return matches;
82+
if (Metadata.valueMatches(candidate as MetadataValue, filter)) {
83+
if (escapeHTML) {
84+
matches.push(Object.assign(new MetadataValue(), candidate, {
85+
value: escape(candidate.value),
86+
}));
87+
} else {
88+
matches.push(candidate as MetadataValue);
89+
}
90+
if (hasValue(limit) && matches.length >= limit) {
91+
return matches;
92+
}
9293
}
9394
}
94-
}
9595
}
9696
}
9797
}

src/app/info/end-user-agreement/end-user-agreement-content/end-user-agreement-content.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ import {
1717
Observable,
1818
Subscription,
1919
} from 'rxjs';
20-
import { map, withLatestFrom } from 'rxjs/operators';
20+
import {
21+
map,
22+
withLatestFrom,
23+
} from 'rxjs/operators';
2124

2225
import { Root } from '../../../core/data/root.model';
2326
import { RootDataService } from '../../../core/data/root-data.service';

src/app/item-page/simple/item-types/shared/item.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ import { TruncatableService } from '../../../../shared/truncatable/truncatable.s
7070
import { TruncatePipe } from '../../../../shared/utils/truncate.pipe';
7171
import { ThemedThumbnailComponent } from '../../../../thumbnail/themed-thumbnail.component';
7272
import { GenericItemPageFieldComponent } from '../../field-components/specific-field/generic/generic-item-page-field.component';
73-
import { ItemPageOrcidFieldComponent } from '../../field-components/specific-field/orcid/item-page-orcid-field.component';
7473
import { ItemPageImgFieldComponent } from '../../field-components/specific-field/img/item-page-img-field.component';
74+
import { ItemPageOrcidFieldComponent } from '../../field-components/specific-field/orcid/item-page-orcid-field.component';
7575
import { ThemedItemPageTitleFieldComponent } from '../../field-components/specific-field/title/themed-item-page-field.component';
7676
import { ThemedMetadataRepresentationListComponent } from '../../metadata-representation-list/themed-metadata-representation-list.component';
7777
import { TabbedRelatedEntitiesSearchComponent } from '../../related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component';

src/app/shared/explore/section-component/text-section/text-section.component.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
waitForAsync,
55
} from '@angular/core/testing';
66
import { By } from '@angular/platform-browser';
7-
87
import { of } from 'rxjs';
98

109
import { LocaleService } from '../../../../core/locale/locale.service';

src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ import { Item } from '../../../../core/shared/item.model';
7171
import { WorkspaceItem } from '../../../../core/submission/models/workspaceitem.model';
7272
import { SubmissionObjectDataService } from '../../../../core/submission/submission-object-data.service';
7373
import { VocabularyOptions } from '../../../../core/submission/vocabularies/models/vocabulary-options.model';
74+
import { EditMetadataSecurityComponent } from '../../../../item-page/edit-item-page/edit-metadata-security/edit-metadata-security.component';
7475
import {
7576
SaveForLaterSubmissionFormErrorAction,
7677
SaveSubmissionFormErrorAction,
7778
SaveSubmissionFormSuccessAction,
7879
SaveSubmissionSectionFormErrorAction,
7980
SaveSubmissionSectionFormSuccessAction,
8081
} from '../../../../submission/objects/submission-objects.actions';
81-
import { EditMetadataSecurityComponent } from '../../../../item-page/edit-item-page/edit-metadata-security/edit-metadata-security.component';
8282
import { SubmissionService } from '../../../../submission/submission.service';
8383
import { LiveRegionService } from '../../../live-region/live-region.service';
8484
import { getLiveRegionServiceStub } from '../../../live-region/live-region.service.stub';

src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ import { EditMetadataSecurityComponent } from '../../../../item-page/edit-item-p
116116
import { paginatedRelationsToItems } from '../../../../item-page/simple/item-types/shared/item-relationships-utils';
117117
import { SubmissionObjectActionTypes } from '../../../../submission/objects/submission-objects.actions';
118118
import { SubmissionService } from '../../../../submission/submission.service';
119+
import { BtnDisabledDirective } from '../../../btn-disabled.directive';
119120
import {
120121
hasNoValue,
121122
hasValue,
@@ -143,7 +144,6 @@ import { DYNAMIC_FORM_CONTROL_TYPE_DSDATEPICKER } from './models/date-picker/dat
143144
import { DynamicConcatModel } from './models/ds-dynamic-concat.model';
144145
import { DynamicLinkModel } from './models/ds-dynamic-link.model';
145146
import { DsDynamicLookupRelationModalComponent } from './relation-lookup-modal/dynamic-lookup-relation-modal.component';
146-
import { BtnDisabledDirective } from '../../../btn-disabled.directive';
147147

148148
@Component({
149149
selector: 'ds-dynamic-form-control-container',

src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.component.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ import { provideMockActions } from '@ngrx/effects/testing';
3333
import { provideMockStore } from '@ngrx/store/testing';
3434
import { TranslateModule } from '@ngx-translate/core';
3535
import { MockComponent } from 'ng-mocks';
36-
import { of as observableOf } from 'rxjs';
37-
import { Observable } from 'rxjs';
36+
import {
37+
Observable,
38+
of as observableOf,
39+
} from 'rxjs';
3840
import {
3941
APP_CONFIG,
4042
APP_DATA_SERVICES_MAP,
@@ -48,11 +50,11 @@ import { Vocabulary } from '../../../../../../core/submission/vocabularies/model
4850
import { VocabularyService } from '../../../../../../core/submission/vocabularies/vocabulary.service';
4951
import { XSRFService } from '../../../../../../core/xsrf/xsrf.service';
5052
import { SubmissionService } from '../../../../../../submission/submission.service';
53+
import { LiveRegionService } from '../../../../../live-region/live-region.service';
54+
import { getLiveRegionServiceStub } from '../../../../../live-region/live-region.service.stub';
5155
import { ThemedLoadingComponent } from '../../../../../loading/themed-loading.component';
5256
import { createSuccessfulRemoteDataObject$ } from '../../../../../remote-data.utils';
5357
import { SubmissionServiceStub } from '../../../../../testing/submission-service.stub';
54-
import { LiveRegionService } from '../../../../../live-region/live-region.service';
55-
import { getLiveRegionServiceStub } from '../../../../../live-region/live-region.service.stub';
5658
import { createTestComponent } from '../../../../../testing/utils.test';
5759
import { VocabularyServiceStub } from '../../../../../testing/vocabulary-service.stub';
5860
import { ChipsComponent } from '../../../../chips/chips.component';

src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-inline-group/dynamic-relation-inline-group.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import {
2525
DynamicFormLayoutService,
2626
DynamicFormValidationService,
2727
} from '@ng-dynamic-forms/core';
28-
import { provideMockStore } from '@ngrx/store/testing';
2928
import { ScannedActionsSubject } from '@ngrx/store';
29+
import { provideMockStore } from '@ngrx/store/testing';
3030
import { TranslateModule } from '@ngx-translate/core';
3131
import { of as observableOf } from 'rxjs';
3232

0 commit comments

Comments
 (0)