import { IXmlElement } from "../../../../src/Common/FileIO/Xml" ; import { MusicSheet } from "../../../../src/MusicalScore/MusicSheet" ; import { MusicSheetReader } from "../../../../src/MusicalScore/ScoreIO/MusicSheetReader" ; describe ( "Clef Converter MusicXML to VexFlow" , ( ) => { let reader ; let parser ; before ( ( ) : void => { reader = new MusicSheetReader ( ) ; parser = new DOMParser ( ) ; } ) ; it ( "reads treble key" , ( done ) => { getMusicSheetWithClef ( "G" ) . getStaffFromIndex ( 0 ) ; done ( ) ; } ) ; see https function getMusicSheetWithClef ( sign , line ? , clefOcatveChange ? , additional ? , size ? ) { const doc = parser . parseFromString ( getMusicXmlWithClef ( sign , line , clefOcatveChange , additional , size ) , "text/xml" ) ; chai . expect ( doc ) . to . not . be . undefined ; const score = new IXmlElement ( doc . getElementsByTagName ( "score-partwise" ) [ 0 ] ) ; chai . expect ( score ) . to . not . be . undefined ; return reader . createMusicSheet ( score , "template.xml" ) ; } function getMusicXmlWithClef ( sign , line ? , clefOcatveChange ? , additional ? , size ? ) { return `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
              <!DOCTYPE score-partwise PUBLIC
                  "-//Recordare//DTD MusicXML 3.0 Partwise//EN"
                  "http://www.musicxml.org/dtds/partwise.dtd">
              <score-partwise version="3.0">
                <part-list>
                  <score-part id="P1">
                    <part-name>Music</part-name>
                  </score-part>
                </part-list>
                <part id="P1">
                  <measure number="1">
                    <attributes>
                      <divisions>1</divisions>
                      <key>

                      </key>
                      <time>
                        <beats>4</beats>
                        <beat-type>4</beat-type>
                      </time>
                      <clef>
                        <sign>G</sign>
                        <line>2</line>
                      </clef>
                    </attributes>
                    <note>
                      <pitch>
                        <step>C</step>
                        <octave>4</octave>
                      </pitch>
                      <duration>4</duration>
                      <type>whole</type>
                    </note>
                  </measure>
                </part>
              </score-partwise>` ; } } ) ;