Skip to content

Commit b6e4bc5

Browse files
committed
tests: fix tests to match new external products
1 parent 5d27675 commit b6e4bc5

3 files changed

Lines changed: 18 additions & 9 deletions

File tree

angular/src/app/search/filters/filters.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe("FiltersComponent", () => {
5555
it("onSuccess", () => {
5656
component.onSuccess(searchResult);
5757
// Basic assertions adapted to minimal fixture
58-
expect(component.keywords).toContain("Advanced Functional Materials");
58+
expect(component.keywords).toContain("advanced functional materials");
5959
expect(component.keywords.length).toBeGreaterThanOrEqual(1);
6060
expect(component.themesWithCount[0].label.startsWith("Nanotechnology")).toBeTruthy();
6161
expect(component.resourceTypesWithCount[0].label.startsWith("Public Data Resource")).toBeTruthy();

angular/src/app/shared/search-service/search-service.service.real.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,10 +514,23 @@ export class RealSearchService implements SearchService {
514514
item.languages
515515
);
516516
const contactName =
517+
(item.contactPoint && (item.contactPoint.fn || item.contactPoint.name)) ||
517518
(item.contact && (item.contact.fn || item.contact.name)) ||
518519
item.organization ||
519520
item.contact?.email ||
520521
"";
522+
const rawContactPoint =
523+
item.contactPoint ||
524+
item.contact ||
525+
(contactName ? { fn: contactName } : {});
526+
const contactPoint =
527+
contactName &&
528+
rawContactPoint &&
529+
typeof rawContactPoint === "object" &&
530+
!Array.isArray(rawContactPoint) &&
531+
!rawContactPoint.fn
532+
? { ...rawContactPoint, fn: contactName }
533+
: rawContactPoint;
521534
const typeArray = this.normalizeCodeTypes(item["@type"], item.vcs);
522535
const topic = Array.isArray(item.topic) ? item.topic : [];
523536
return {
@@ -542,10 +555,7 @@ export class RealSearchService implements SearchService {
542555
item.dates.updated ||
543556
item.dates.lastModified)) ||
544557
null,
545-
contactPoint:
546-
item.contactPoint ||
547-
item.contact ||
548-
(contactName ? { fn: contactName } : {}),
558+
contactPoint,
549559
};
550560
}
551561

angular/src/app/shared/search-service/search-service.service.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ describe('SearchService', () => {
4141
const sub = service.watchExternalProducts().subscribe((v) => {
4242
seen.push(v);
4343
if (seen.length === 2) {
44-
expect(seen[0]).toBeFalse();
45-
expect(seen[1]).toBeTrue();
44+
expect(seen[0]).toBe(false);
45+
expect(seen[1]).toBe(true);
4646
sub.unsubscribe();
4747
done();
4848
}
@@ -67,11 +67,10 @@ describe('SearchService', () => {
6767
expect(merged.total).toBe(2);
6868
expect(merged.ResultData.length).toBe(2);
6969
const external = merged.ResultData[1];
70-
expect(external.external).toBeTrue();
70+
expect(external.external).toBe(true);
7171
expect(external.title).toBe('RepoOne');
7272
expect(external['@type']).toContain('CodeRepository');
7373
expect(external.keyword).toContain('science');
74-
expect(external.keyword).toContain('Python');
7574
expect(external.contactPoint.fn).toBe('NIST DevOps');
7675
// Keywords are normalized to lowercase
7776
expect(external.keyword).toContain('python');

0 commit comments

Comments
 (0)