/* globals expect, beforeEach, module, describe, inject, it,console */
'use strict';

describe('EnterpriseDashboardApp.Encoder', function() {



	// load the service's module
	// beforeEach(angular.mock.module('EnterpriseDashboardApp.WSBackend'));
	beforeEach(angular.mock.module('EnterpriseDashboardApp.Encoder'));

	// instantiate service
	var Encoder;

	beforeEach(inject(function(_Encoder_) {
		Encoder = _Encoder_;
	}));


	it('should not be undefined', function() {
		expect(!!Encoder).to.be.eql(true);
	});

	describe('getEventNameByRequest', function() {

		it('Should work fine with a rest api call', function() {
			var result,
			request;

			request = {
				method: 'POST',
				url: 'https://dashboard.wonderflow.co/api/philips/products?rawQuery=%7B%22isVisibleInEnterpriseDashboardApp%22%3Atrue%7D',
				body: {
					name: 'random'
				}
			};
			result = Encoder.getEventNameByRequest(request);
			expect(result).to.be.eql('POST /api/philips/products');
		});

		it('Should work fine with a jobs api call', function() {
			var result,
			request;

			request = {
				method: 'POST',
				url: '/jobs/string-printer',
				body: {
					name: 'random'
				}
			};
			result = Encoder.getEventNameByRequest(request);
			expect(result).to.be.eql('POST /jobs/string-printer');
		});
	});

	it('should have getRestEventNamesByModelUrl(url) working fine', function() {
		var result,
			url;

		url = 'https://dashboard.wonderflow.co/api/philips/products?rawQuery=%7B%22isVisibleInEnterpriseDashboardApp%22%3Atrue%7D';

		result = Encoder.getRestEventNamesByModelUrl(url);

		expect(result).to.be.eql({
			POST: 'POST /api/philips/products',
			GET: 'GET /api/philips/products',
			PUT: 'PUT /api/philips/products',
			DELETE: 'DELETE /api/philips/products',
		});

	});


});