/**
 * VexFlow - Factory Tests
 * Copyright Mohit Muthanna 2010 <mohit@muthanna.com>
 */

Vex.Flow.Test.Factory = (function() {
  var Factory = {
    Start: function() {
      QUnit.module('Factory');
      var VFT = Vex.Flow.Test;

      QUnit.test('Defaults', VFT.Factory.defaults);
      VFT.runSVGTest('Draw', VFT.Factory.draw);
      VFT.runSVGTest('Draw Tab (repeat barlines must be aligned)', VFT.Factory.drawTab);
    },

    defaults: function(assert) {
      assert.throws(function() {
        return new VF.Factory({
          renderer: {
            width: 700,
            height: 500,
          },
        });
      });

      var vf = new VF.Factory({
        renderer: {
          elementId: null,
          width: 700,
          height: 500,
        },
      });

      var options = vf.getOptions();
      assert.equal(options.renderer.width, 700);
      assert.equal(options.renderer.height, 500);
      assert.equal(options.renderer.elementId, null);
      assert.equal(options.stave.space, 10);
    },

    draw: function(options) {
      var vf = VF.Factory.newFromElementId(options.elementId);
      vf.Stave().setClef('treble');
      vf.draw();
      expect(0);
    },

    drawTab: function(options) {
      var vf = VF.Test.makeFactory(options, 500, 400);

      var system = vf.System();

      var stave = vf.Stave()
        .setClef('treble')
        .setKeySignature('C#')
        .setBegBarType(Vex.Flow.Barline.type.REPEAT_BEGIN);

      var voice = new VF.Voice(VF.Test.TIME4_4);

      voice.addTickables([
        new VF.StaveNote({ keys: ['c/4'], duration: 'w' })
      ]);

      system.addStave({
        stave: stave,
        voices: [voice]
      });

      var tabStave = vf.TabStave()
        .setClef('tab')
        .setBegBarType(Vex.Flow.Barline.type.REPEAT_BEGIN);

      var tabVoice = new VF.Voice(VF.Test.TIME4_4);

      tabVoice.addTickables([
        new VF.TabNote({ positions: [{ str: 2, fret: 5 }], duration: 'w' })
      ]);

      system.addStave({
        stave: tabStave,
        voices: [tabVoice]
      });

      vf.draw();
      equal(stave.getModifiers()[0].getX(), tabStave.getModifiers()[0].getX());
      expect(1);
    },
  };

  return Factory;
})();

@@ -1477,54 +1477,32 @@
 oice
+s
  = 
-new VF.Voice(VF.Test.TIME4_4);%0A%0A
+%5B%0A  
       v
+f.V
 oice
+()
 .add
@@ -1525,41 +1525,24 @@
     
+ 
-new VF.StaveNote(%7B keys: %5B'c/4'%5D,
+ vf.GhostNote(%7B
  dur
@@ -1553,34 +1553,44 @@
 n: 'w' %7D)%0A      
+  %5D)%0A      
 %5D
-)
 ;%0A%0A      system.
@@ -1642,15 +1642,14 @@
 es: 
-%5B
 voice
-%5D
+s
 %0A   
@@ -1798,57 +1798,32 @@
 oice
+s
  = 
-new VF.Voice(VF.Test.TIME4_4);%0A%0A
+%5B%0A 
       
-tab
+ vf.
 Voice
+()
 .add
@@ -1846,58 +1846,24 @@
     
-new VF.TabNote(%7B positions: %5B%7B str: 2, fret: 5 %7D%5D,
+  vf.GhostNote(%7B
  dur
@@ -1882,18 +1882,28 @@
 )%0A      
+  %5D)%0A      
 %5D
-)
 ;%0A%0A     
@@ -1966,17 +1966,16 @@
 es: 
-%5B
 tabVoice
 %5D%0A  
@@ -1970,17 +1970,17 @@
 tabVoice
-%5D
+s
 %0A      %7D

Use factory methods