Skip to content

Commit bd31fce

Browse files
author
Febbraro
committed
add tests for masthead
1 parent e13330b commit bd31fce

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

angular/projects/spark-angular/src/lib/components/sprk-masthead/sprk-masthead.component.spec.ts

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,4 +280,86 @@ describe('SprkMastheadComponent', () => {
280280
);
281281
expect(narrowNavLink.getAttribute('href')).toEqual('/alert-router');
282282
});
283+
284+
it('should set the href link of the footer link in selector when using routerLink', () => {
285+
const mySelector = {
286+
trigger: {
287+
text: 'Select One',
288+
},
289+
choices: [
290+
{
291+
content: {
292+
title: 'Choice Title 1',
293+
infoLine1: 'Information about this choice',
294+
infoLine2: 'More Information',
295+
},
296+
value: 'Choice Title 1',
297+
active: false,
298+
},
299+
],
300+
footer: {
301+
analyticsString: 'Go Elsewhere Link',
302+
text: 'Go Elsewhere',
303+
routerLink: '/footer-test',
304+
},
305+
};
306+
component.narrowSelector = mySelector;
307+
component.narrowNavLinks = [
308+
{ text: 'Item 1', routerLink: '/footer-router' },
309+
];
310+
fixture.detectChanges();
311+
hamburgerIcon.click();
312+
fixture.detectChanges();
313+
const selectorTrigger = fixture.nativeElement.querySelector(
314+
'.sprk-c-Dropdown__trigger',
315+
);
316+
selectorTrigger.click();
317+
fixture.detectChanges();
318+
const footerLink = fixture.nativeElement.querySelector(
319+
'.sprk-c-Dropdown__footer a',
320+
);
321+
expect(footerLink.getAttribute('href')).toEqual('/footer-test');
322+
});
323+
324+
it('should set the href link of the footer link in selector when using href', () => {
325+
const mySelector = {
326+
trigger: {
327+
text: 'Select One',
328+
},
329+
choices: [
330+
{
331+
content: {
332+
title: 'Choice Title 1',
333+
infoLine1: 'Information about this choice',
334+
infoLine2: 'More Information',
335+
},
336+
value: 'Choice Title 1',
337+
active: false,
338+
},
339+
],
340+
footer: {
341+
analyticsString: 'Go Elsewhere Link',
342+
text: 'Go Elsewhere',
343+
href: 'https://www.sparkdesignsystem.com',
344+
},
345+
};
346+
component.narrowSelector = mySelector;
347+
component.narrowNavLinks = [
348+
{ text: 'Item 1', routerLink: '/footer-router' },
349+
];
350+
fixture.detectChanges();
351+
hamburgerIcon.click();
352+
fixture.detectChanges();
353+
const selectorTrigger = fixture.nativeElement.querySelector(
354+
'.sprk-c-Dropdown__trigger',
355+
);
356+
selectorTrigger.click();
357+
fixture.detectChanges();
358+
const footerLink = fixture.nativeElement.querySelector(
359+
'.sprk-c-Dropdown__footer a',
360+
);
361+
expect(footerLink.getAttribute('href')).toEqual(
362+
'https://www.sparkdesignsystem.com',
363+
);
364+
});
283365
});

0 commit comments

Comments
 (0)