'use strict';

var grunt = require('grunt');

/*
  ======== A Handy Little Nodeunit Reference ========
  https://github.com/caolan/nodeunit

  Test methods:
    test.expect(numAssertions)
    test.done()
  Test assertions:
    test.ok(value, [message])
    test.equal(actual, expected, [message])
    test.notEqual(actual, expected, [message])
    test.deepEqual(actual, expected, [message])
    test.notDeepEqual(actual, expected, [message])
    test.strictEqual(actual, expected, [message])
    test.notStrictEqual(actual, expected, [message])
    test.throws(block, [error], [message])
    test.doesNotThrow(block, [error], [message])
    test.ifError(value)
*/

exports.userscript_meta = {
  setUp: function (done) {
    done();
  },
  test_files: function (test) {
    var tests = grunt.file.expand('test/fixtures/*_package.json');
    test.expect(tests.length);

    tests.forEach(function (pkg) {
      var testName = pkg.replace(/^test\/fixtures\/|_package\.json$/g, '');
      var actual = grunt.file.read('tmp/' + testName + '_meta.js');
      var expected = grunt.file.read('test/expected/' + testName +
        '_meta.js');
      test.equal(actual, expected, testName);
    });
    test.done();
  }
};

'use strict';

var grunt = require('grunt');

/*
  ======== A Handy Little Nodeunit Reference ========
  https://github.com/caolan/nodeunit

  Test methods:
    test.expect(numAssertions)
    test.done()
  Test assertions:
    test.ok(value, [message])
    test.equal(actual, expected, [message])
    test.notEqual(actual, expected, [message])
    test.deepEqual(actual, expected, [message])
    test.notDeepEqual(actual, expected, [message])
    test.strictEqual(actual, expected, [message])
    test.notStrictEqual(actual, expected, [message])
    test.throws(block, [error], [message])
    test.doesNotThrow(block, [error], [message])
    test.ifError(value)
*/

exports.userscript_meta = {
  setUp: function (done) {
    done();
  },
  test_files: function (test) {
    var tests = grunt.file.expand('test/fixtures/*_package.json');
    test.expect(tests.length);

    tests.forEach(function (pkg) {
      var testName = pkg.replace(/^test\/fixtures\/|_package\.json$/g, '');
      var actual = grunt.file.read('tmp/' + testName + '_meta.js');
      var expected = grunt.file.read('test/expected/' + testName +
        '_meta.js');
      expected = expected.replace(/\r?\n/g, '\n');
      actual = actual.replace(/\r?\n/g, '\n');
      test.equal(actual, expected, testName);
    });
    test.done();
  }
};

Fix CRLF breaking tests