'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.configureFirebase = {
  setUp: function (done) {
    // setup here if necessary
    done();
  },
  defaultOptions: function (test) {
    test.expect(2);

    var actual = grunt.file.read('firebase.json');
    var expected = grunt.file.read('test/expected/default-options.json');
    test.equal(actual, expected, 'Should create firebase.json using default options');

    var actualrc = grunt.file.read('.firebaserc');
    var expectedrc = grunt.file.read('test/expected/.default-options-rc');
    test.equal(actualrc, expectedrc, 'Should create .firebaserc using default options');

    test.done();
  },
  customOptions: function (test) {
    test.expect(2);

    var actual = grunt.file.read('tmp/custom-options.json');
    var expected = grunt.file.read('test/expected/custom-options.json');
    test.equal(actual, expected,
      'Should create the firebase.json file using custom destination and public directory from options');

    var actualrc = grunt.file.read('tmp/.custom-options-rc');
    var expectedrc = grunt.file.read('test/expected/.custom-options-rc');
    test.equal(actualrc, expectedrc, 'Should create .firebaserc using custom options');

    test.done();
  }
};
