var chai = require('chai'),
  expect = chai.expect;

var dummyMessage = 'message';
var dummyConfig = {
  apiKey: '123'
};
var dummyRegistrationIds = ['123'];

describe('GCM Test', function() {
  var gcmTest;

  before(function() {
    gcmTest = require('../index');
  });

  it('should be define', function() {
    expect(gcmTest).to.not.be.undefined();
  });
});

describe('validations', function() {
  var gcmTest = require('../index');

  it('should throw api key not available error', function() {
    expect(gcmTest).to.throw(/api key is not available/);
  });

  it('should throw message not available error', function() {
    expect(function(){
      return gcmTest(null, null, dummyConfig);
    }).to.throw(/message is not available/);
  });

  it('should throw registration ids is empty', function() {
    expect(function() {
      return gcmTest(dummyMessage, null, dummyConfig);
    }).to.throw(/no registration ids found/);
  });
});

describe('properties on node gcm', function() {
  var proxyquire =  require('proxyquire'),
    nodeGcm = {};

  describe('check config data', function() {
    var gcmTest,
      apiKey = dummyConfig.apiKey;

    it('should be able to get api key', function() {
      nodeGcm = {
        Sender: function(x) {
          expect(x).to.equal(apiKey);
        }
      }

      gcmTest = proxyquire('../lib/gcmTest', {
        'gcm': nodeGcm
      });

      gcmTest(dummyMessage, dummyRegistrationIds, dummyConfig);
    });
  });

  describe('check gcm message data', function() {
    it('expect message object to be the same', function() {
      nodeGcm = {
        Message: function(x) {
          expect(x.data.message).to.equal(dummyMessage);
        }
      }

      gcmTest = proxyquire('../lib/gcmTest', {
        'gcm': nodeGcm
      });

      gcmTest(dummyMessage, dummyRegistrationIds, dummyConfig);
    });
  });
});
@@ -1849,22 +1849,351 @@
 ig);%0A    %7D);
+%0A%0A    it('expect message to accept message as object', function() %7B%0A      var message = %7B%0A        message: 'value',%0A        path: 'path'%0A      %7D;%0A      nodeGcm = %7B%0A        Message: function(x) %7B%0A          expect(x.data).to.deep.equal(message);%0A        %7D%0A      %7D%0A%0A      gcmTest(message, dummyRegistrationIds, dummyConfig);%0A    %7D);
 %0A  %7D);%0A%7D);

test message to accept object