'use strict';

var _regenerator = require('babel-runtime/regenerator');

var _regenerator2 = _interopRequireDefault(_regenerator);

var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');

var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);

require('source-map-support/register');

var _mocha = require('mocha');

var _assert = require('assert');

var _assert2 = _interopRequireDefault(_assert);

var _gtmGithubResults = require('../../../src/serverless/gtmGithubResults/gtmGithubResults.js');

var _gtmGithubResults2 = _interopRequireDefault(_gtmGithubResults);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

(0, _mocha.describe)('gtmGithubResults', function () {
    (0, _mocha.describe)('handle', function () {
        (0, _mocha.it)('should fire callback', (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
            var expected, actual;
            return _regenerator2.default.wrap(function _callee$(_context) {
                while (1) {
                    switch (_context.prev = _context.next) {
                        case 0:
                            expected = {
                                statusCode: 401,
                                headers: { 'Content-Type': 'text/plain' }
                            };
                            actual = void 0;
                            _context.prev = 2;
                            _context.next = 5;
                            return _gtmGithubResults2.default.handle({}, null, function () {
                                return expected;
                            });

                        case 5:
                            actual = _context.sent;
                            _context.next = 11;
                            break;

                        case 8:
                            _context.prev = 8;
                            _context.t0 = _context['catch'](2);

                            console.log(_context.t0.message);

                        case 11:
                            _assert2.default.equal(actual.statusCode, expected.statusCode);

                        case 12:
                        case 'end':
                            return _context.stop();
                    }
                }
            }, _callee, this, [[2, 8]]);
        })));
    });

    (0, _mocha.describe)('getQueue', function () {
        (0, _mocha.it)('should throw without config', (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
            return _regenerator2.default.wrap(function _callee2$(_context2) {
                while (1) {
                    switch (_context2.prev = _context2.next) {
                        case 0:
                            _context2.prev = 0;
                            _context2.next = 3;
                            return _gtmGithubResults2.default.getQueue();

                        case 3:
                            _context2.next = 8;
                            break;

                        case 5:
                            _context2.prev = 5;
                            _context2.t0 = _context2['catch'](0);

                            _assert2.default.equal('Missing SQS consumer option [queueUrl].', _context2.t0.message);

                        case 8:
                        case 'end':
                            return _context2.stop();
                    }
                }
            }, _callee2, this, [[0, 5]]);
        })));
    });
});