@@ -87,6 +87,39 @@ describe('personalNames', () => {
8787 assert . ok ( namePart2 )
8888 assert . strictEqual ( namePart2 . textContent , 'Jane Smith' )
8989 } )
90+
91+ it ( 'should add an email nameIdentifier for each personal name if local/facultyID is present' , async ( ) => {
92+ const inputXML = x ( `<local><courseInfo><faculty>John Doe, Jane Smith</faculty><facultyID>jdoe, jsmith</facultyID></courseInfo></local>` )
93+ const result = convertSyllabusXMLtoMODS ( inputXML )
94+ const nameElements = xpath . select ( '//mods/name[@type="personal"]' , result )
95+ assert . strictEqual ( nameElements . length , 2 )
96+ const nameIdentifiers = xpath . select ( '//mods/name[@type="personal"]/nameIdentifier' , result )
97+ assert . strictEqual ( nameIdentifiers . length , 2 )
98+ assert . ok ( nameIdentifiers [ 0 ] )
99+ assert . strictEqual ( nameIdentifiers [ 0 ] . textContent , 'jdoe@cca.edu' )
100+ assert . ok ( nameIdentifiers [ 1 ] )
101+ assert . strictEqual ( nameIdentifiers [ 1 ] . textContent , 'jsmith@cca.edu' )
102+ } )
103+
104+ it ( 'should not add email nameIdentifiers if local/facultyID is missing' , async ( ) => {
105+ const inputXML = x ( `<local><courseInfo><faculty>John Doe, Jane Smith</faculty></courseInfo></local>` )
106+ const result = convertSyllabusXMLtoMODS ( inputXML )
107+ const nameElements = xpath . select ( '//mods/name[@type="personal"]' , result )
108+ assert . strictEqual ( nameElements . length , 2 )
109+ const nameIdentifier1 = xpath . select1 ( 'nameIdentifier' , nameElements [ 0 ] )
110+ assert . ok ( ! nameIdentifier1 )
111+ const nameIdentifier2 = xpath . select1 ( 'nameIdentifier' , nameElements [ 1 ] )
112+ assert . ok ( ! nameIdentifier2 )
113+ } )
114+
115+ it ( 'should not add emails if they do not correspond with names' , async ( ) => {
116+ const inputXML = x ( `<local><courseInfo><faculty>John Doe</faculty><facultyID>jdoe, jsmith</facultyID></courseInfo></local>` )
117+ const result = convertSyllabusXMLtoMODS ( inputXML )
118+ const nameElements = xpath . select ( '//mods/name[@type="personal"]' , result )
119+ assert . strictEqual ( nameElements . length , 1 )
120+ const nameIdentifier1 = xpath . select1 ( 'nameIdentifier' , nameElements [ 0 ] )
121+ assert . ok ( ! nameIdentifier1 )
122+ } )
90123} )
91124
92125describe ( 'corporateName' , ( ) => {
0 commit comments