@@ -18,67 +18,99 @@ describe('MetadataContactComponent', () => {
1818 beforeEach ( ( ) => {
1919 fixture = TestBed . createComponent ( MetadataContactComponent )
2020 component = fixture . componentInstance
21- component . metadata = {
22- kind : 'dataset' ,
23- ownerOrganization : {
24- name : 'Worldcorp' ,
25- website : new URL ( 'https://john.world.co' ) ,
26- } ,
27- contactsForResource : [
28- {
29- name : 'john' ,
30- organization : 'Worldcorp' ,
31- email : 'john@world.co' ,
32- website : 'https://john.world.co' ,
33- } ,
34- {
35- name : 'billy' ,
36- organization : 'small corp' ,
37- email : 'billy@small.co' ,
38- website : 'https://billy.small.co' ,
39- } ,
40- ] ,
41- } as any
42- fixture . detectChanges ( )
4321 } )
4422
4523 it ( 'should create' , ( ) => {
4624 expect ( component ) . toBeTruthy ( )
4725 } )
48- describe ( 'on contact click ' , ( ) => {
26+ describe ( 'kind dataset ' , ( ) => {
4927 beforeEach ( ( ) => {
50- jest . resetAllMocks ( )
51- jest . spyOn ( component . organizationClick , 'emit' )
28+ component . metadata = {
29+ kind : 'dataset' ,
30+ ownerOrganization : {
31+ name : 'Worldcorp' ,
32+ website : new URL ( 'https://john.world.co' ) ,
33+ } ,
34+ contactsForResource : [
35+ {
36+ firstName : 'john' ,
37+ lastName : 'doe' ,
38+ organization : 'Worldcorp' ,
39+ email : 'john@world.co' ,
40+ website : 'https://john.world.co' ,
41+ } ,
42+ {
43+ firstName : 'billy' ,
44+ lastName : 'smith' ,
45+ organization : 'small corp' ,
46+ email : 'billy@small.co' ,
47+ website : 'https://billy.small.co' ,
48+ } ,
49+ ] ,
50+ } as any
51+ fixture . detectChanges ( )
5252 } )
53- it ( 'emit contact click with contact name' , ( ) => {
54- const el = fixture . debugElement . query (
55- By . css ( '[data-cy="organization-name-link"]' )
56- ) . nativeElement
57- el . click ( )
58- expect ( component . organizationClick . emit ) . toHaveBeenCalledWith ( {
59- name : 'Worldcorp' ,
60- website : new URL ( 'https://john.world.co' ) ,
53+ describe ( 'on organization click' , ( ) => {
54+ beforeEach ( ( ) => {
55+ jest . resetAllMocks ( )
56+ jest . spyOn ( component . organizationClick , 'emit' )
57+ } )
58+ it ( 'emit organization click with organization name' , ( ) => {
59+ const el = fixture . debugElement . query (
60+ By . css ( '[data-cy="organization-name-link"]' )
61+ ) . nativeElement
62+ el . click ( )
63+ expect ( component . organizationClick . emit ) . toHaveBeenCalledWith ( {
64+ name : 'Worldcorp' ,
65+ website : new URL ( 'https://john.world.co' ) ,
66+ } )
67+ } )
68+ } )
69+ describe ( 'content' , ( ) => {
70+ let email
71+ beforeEach ( ( ) => {
72+ email = fixture . debugElement . queryAll ( By . css ( 'a' ) ) [ 1 ]
73+ } )
74+ it ( 'displays the organization name' , ( ) => {
75+ const el = fixture . debugElement . query (
76+ By . css ( '[data-cy="organization-name-link"]' )
77+ ) . nativeElement
78+ expect ( el . innerHTML ) . toBe ( ' Worldcorp ' )
79+ } )
80+ it ( 'displays the contact email' , ( ) => {
81+ expect ( email . attributes . href ) . toBe ( 'mailto:john@world.co' )
82+ } )
83+ it ( 'displays a link to the contact website' , ( ) => {
84+ const a = fixture . debugElement . query ( By . css ( '.contact-website' ) )
85+ expect ( a . attributes . href ) . toBe ( 'https://john.world.co/' )
86+ expect ( a . attributes . target ) . toBe ( '_blank' )
6187 } )
6288 } )
6389 } )
64- describe ( 'content' , ( ) => {
65- let email
90+
91+ describe ( 'kind service' , ( ) => {
6692 beforeEach ( ( ) => {
67- email = fixture . debugElement . queryAll ( By . css ( 'a' ) ) [ 1 ]
68- } )
69- it ( 'displays the contact name' , ( ) => {
70- const el = fixture . debugElement . query (
71- By . css ( '[data-cy="organization-name-link"]' )
72- ) . nativeElement
73- expect ( el . innerHTML ) . toBe ( ' Worldcorp ' )
74- } )
75- it ( 'displays the contact email' , ( ) => {
76- expect ( email . attributes . href ) . toBe ( 'mailto:john@world.co' )
93+ component . metadata = {
94+ kind : 'service' ,
95+ ownerOrganization : {
96+ name : 'Service Corp' ,
97+ } ,
98+ contacts : [
99+ {
100+ firstName : 'samantha' ,
101+ lastName : 'smith' ,
102+ } ,
103+ ] ,
104+ } as any
105+ fixture . detectChanges ( )
77106 } )
78- it ( 'displays a link to the contact website' , ( ) => {
79- const a = fixture . debugElement . query ( By . css ( '.contact-website' ) )
80- expect ( a . attributes . href ) . toBe ( 'https://john.world.co/' )
81- expect ( a . attributes . target ) . toBe ( '_blank' )
107+ describe ( 'content' , ( ) => {
108+ it ( 'displays the contact name' , ( ) => {
109+ const el = fixture . debugElement . query (
110+ By . css ( '[data-cy="contact-full-name"] > p' )
111+ ) . nativeElement
112+ expect ( el . innerHTML ) . toBe ( ' samantha smith ' )
113+ } )
82114 } )
83115 } )
84116} )
0 commit comments