const MIDIFile = require('../../src/midi/file');
const assert = require('assert');

describe('MIDIFile.write()', () => {
  it('parses pitch classes', () => {
    const json = {
      "header": {
        "format": 0,
        "ntracks": 1,
        "division": 960
      },
      "tracks": [
        [
          {
            "time": 0,
            "type": "note",
            "pitch": 60,
            "velocity": 94,
            "duration": 1,
            "release": 64,
            "channel": 1
          },
          {
            "time": 1,
            "type": "note",
            "pitch": 62,
            "velocity": 107,
            "duration": 0.5,
            "release": 64,
            "channel": 1
          },
          {
            "time": 2,
            "type": "note",
            "pitch": 64,
            "velocity": 112,
            "duration": 1.5,
            "release": 64,
            "channel": 1
          },
          {
            "time": 2.5,
            "type": "note",
            "pitch": 67,
            "velocity": 51,
            "duration": 0.625,
            "release": 64,
            "channel": 1
          },
          {
            "time": 3.5,
            "type": "track-end"
          }
        ]
      ]
    };
    const midiFile = new MIDIFile(`${__dirname}/../../tmp/write-test.mid`);
    return midiFile.write(json)
      .then(() => midiFile.read())
      .then(reloadedJson => assert.deepEqual(reloadedJson, json));
  });
});

@@ -75,16 +75,42 @@
 ssert');
+%0Aconst fs = require('fs');
 %0A%0Adescri
@@ -140,16 +140,140 @@
 () =%3E %7B%0A
+%0A  const tmpFolder = %60$%7B__dirname%7D/../../tmp%60;%0A%0A  before(() =%3E fs.existsSync(tmpFolder) ? null : fs.mkdirSync(tmpFolder));%0A%0A
   it('pa
@@ -1429,36 +1429,26 @@
 File(%60$%7B
-__dirname%7D/../../tmp
+tmpFolder%7D
 /write-t

make file-write-test create its tmp folder if needed