text: 'use strict';
  
  var _ = require('lodash');
  var Holodeck = require('../../../../holodeck');
  var Request = require('../../../../../../lib/http/request');
  var Response = require('../../../../../../lib/http/response');
  var Twilio = require('../../../../../../lib');
  
  
  var client;
  var holodeck;
  
  describe('Workflow', function() {
    beforeEach(function() {
      holodeck = new Holodeck();
      client = new Twilio('ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'AUTHTOKEN', holodeck);
    });
    it('should generate valid fetch request',
      function() {
        holodeck.mock(new Response(500, ''));
  
        var promise = client.taskrouter.v1.workspaces('WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                                          .workflows('WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa').fetch();
        promise = promise.then(function() {
          throw new Error('failed');
        }, function(error) {
          expect(error.constructor).toBe(Error.prototype.constructor);
        });
        promise.done();
  
        var solution = {
          workspaceSid: 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
          sid: 'WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
        };
        var url = _.template('https://taskrouter.twilio.com/v1/Workspaces/<%= workspaceSid %>/Workflows/<%= sid %>')(solution);
  
        holodeck.assertHasRequest(new Request({
          method: 'GET',
          url: url
        }));
      }
    );
    it('should generate valid fetch response',
      function() {
        var body = JSON.stringify({
            'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
            'assignment_callback_url': 'http://example.com',
            'configuration': 'task-routing:\\n  - filter: \\n      - 1 == 1\\n    target:\\n      - queue: WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\n        set-priority: 0\\n',
            'date_created': '2014-05-14T10:50:02Z',
            'date_updated': '2014-05-14T23:26:06Z',
            'document_content_type': 'application/json',
            'fallback_assignment_callback_url': null,
            'friendly_name': 'Default Fifo Workflow',
            'sid': 'WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
            'task_reservation_timeout': 120,
            'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
            'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
        });
  
        holodeck.mock(new Response(200, body));
  
        var promise = client.taskrouter.v1.workspaces('WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                                          .workflows('WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa').fetch();
        promise = promise.then(function(response) {
          expect(response).toBeDefined();
        }, function() {
          throw new Error('failed');
        });
  
        promise.done();
      }
    );
    it('should generate valid update request',
      function() {
        holodeck.mock(new Response(500, ''));
  
        var promise = client.taskrouter.v1.workspaces('WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                                          .workflows('WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa').update();
        promise = promise.then(function() {
          throw new Error('failed');
        }, function(error) {
          expect(error.constructor).toBe(Error.prototype.constructor);
        });
        promise.done();
  
        var solution = {
          workspaceSid: 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
          sid: 'WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
        };
        var url = _.template('https://taskrouter.twilio.com/v1/Workspaces/<%= workspaceSid %>/Workflows/<%= sid %>')(solution);
  
        holodeck.assertHasRequest(new Request({
          method: 'POST',
          url: url
        }));
      }
    );
    it('should generate valid update response',
      function() {
        var body = JSON.stringify({
            'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
            'assignment_callback_url': 'http://example.com',
            'configuration': 'task-routing:\\n  - filter: \\n      - 1 == 1\\n    target:\\n      - queue: WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\n        set-priority: 0\\n',
            'date_created': '2014-05-14T10:50:02Z',
            'date_updated': '2014-05-14T23:26:06Z',
            'document_content_type': 'application/json',
            'fallback_assignment_callback_url': null,
            'friendly_name': 'Default Fifo Workflow',
            'sid': 'WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
            'task_reservation_timeout': 120,
            'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
            'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
        });
  
        holodeck.mock(new Response(200, body));
  
        var promise = client.taskrouter.v1.workspaces('WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                                          .workflows('WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa').update();
        promise = promise.then(function(response) {
          expect(response).toBeDefined();
        }, function() {
          throw new Error('failed');
        });
  
        promise.done();
      }
    );
    it('should generate valid remove request',
      function() {
        holodeck.mock(new Response(500, ''));
  
        var promise = client.taskrouter.v1.workspaces('WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                                          .workflows('WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa').remove();
        promise = promise.then(function() {
          throw new Error('failed');
        }, function(error) {
          expect(error.constructor).toBe(Error.prototype.constructor);
        });
        promise.done();
  
        var solution = {
          workspaceSid: 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
          sid: 'WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
        };
        var url = _.template('https://taskrouter.twilio.com/v1/Workspaces/<%= workspaceSid %>/Workflows/<%= sid %>')(solution);
  
        holodeck.assertHasRequest(new Request({
          method: 'DELETE',
          url: url
        }));
      }
    );
    it('should generate valid delete response',
      function() {
        var body = JSON.stringify(null);
  
        holodeck.mock(new Response(204, body));
  
        var promise = client.taskrouter.v1.workspaces('WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                                          .workflows('WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa').remove();
        promise = promise.then(function(response) {
          expect(response).toBe(true);
        }, function() {
          throw new Error('failed');
        });
  
        promise.done();
      }
    );
    it('should generate valid list request',
      function() {
        holodeck.mock(new Response(500, ''));
  
        var promise = client.taskrouter.v1.workspaces('WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                                          .workflows.list();
        promise = promise.then(function() {
          throw new Error('failed');
        }, function(error) {
          expect(error.constructor).toBe(Error.prototype.constructor);
        });
        promise.done();
  
        var solution = {
          workspaceSid: 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
        };
        var url = _.template('https://taskrouter.twilio.com/v1/Workspaces/<%= workspaceSid %>/Workflows')(solution);
  
        holodeck.assertHasRequest(new Request({
          method: 'GET',
          url: url
        }));
      }
    );
    it('should generate valid read_full response',
      function() {
        var body = JSON.stringify({
            'meta': {
                'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows?PageSize=50&Page=0',
                'key': 'workflows',
                'last_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows?PageSize=50&Page=0',
                'next_page_url': null,
                'page': 0,
                'page_size': 50,
                'previous_page_url': null,
                'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows?PageSize=50&Page=0'
            },
            'workflows': [
                {
                    'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
                    'assignment_callback_url': 'http://example.com',
                    'configuration': 'task-routing:\\n  - filter: \\n      - 1 == 1\\n    target:\\n      - queue: WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\n        set-priority: 0\\n',
                    'date_created': '2014-05-14T10:50:02Z',
                    'date_updated': '2014-05-15T16:47:51Z',
                    'document_content_type': 'application/json',
                    'fallback_assignment_callback_url': null,
                    'friendly_name': 'Default Fifo Workflow',
                    'sid': 'WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
                    'task_reservation_timeout': 120,
                    'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
                    'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
                }
            ]
        });
  
        holodeck.mock(new Response(200, body));
  
        var promise = client.taskrouter.v1.workspaces('WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                                          .workflows.list();
        promise = promise.then(function(response) {
          expect(response).toBeDefined();
        }, function() {
          throw new Error('failed');
        });
  
        promise.done();
      }
    );
    it('should generate valid read_empty response',
      function() {
        var body = JSON.stringify({
            'meta': {
                'first_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows?PageSize=50&Page=0',
                'key': 'workflows',
                'last_page_url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows?PageSize=50&Page=0',
                'next_page_url': null,
                'page': 0,
                'page_size': 50,
                'previous_page_url': null,
                'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows?PageSize=50&Page=0'
            },
            'workflows': []
        });
  
        holodeck.mock(new Response(200, body));
  
        var promise = client.taskrouter.v1.workspaces('WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                                          .workflows.list();
        promise = promise.then(function(response) {
          expect(response).toBeDefined();
        }, function() {
          throw new Error('failed');
        });
  
        promise.done();
      }
    );
    it('should generate valid create request',
      function() {
        holodeck.mock(new Response(500, ''));
  
        var opts = {
          friendlyName: 'friendlyName',
          configuration: 'configuration',
          assignmentCallbackUrl: '/example'
        };
        var promise = client.taskrouter.v1.workspaces('WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                                          .workflows.create(opts);
        promise = promise.then(function() {
          throw new Error('failed');
        }, function(error) {
          expect(error.constructor).toBe(Error.prototype.constructor);
        });
        promise.done();
  
        var solution = {
          workspaceSid: 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
        };
        var url = _.template('https://taskrouter.twilio.com/v1/Workspaces/<%= workspaceSid %>/Workflows')(solution);
  
        var values = {
          FriendlyName: 'friendlyName',
          Configuration: 'configuration',
          AssignmentCallbackUrl: '/example',
        };
        holodeck.assertHasRequest(new Request({
            method: 'POST',
            url: url,
            data: values
        }));
      }
    );
    it('should generate valid create response',
      function() {
        var body = JSON.stringify({
            'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
            'assignment_callback_url': 'http://example.com',
            'configuration': 'task-routing:\\n  - filter: \\n      - 1 == 1\\n    target:\\n      - queue: WQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\n        set-priority: 0\\n',
            'date_created': '2014-05-14T10:50:02Z',
            'date_updated': '2014-05-14T23:26:06Z',
            'document_content_type': 'application/json',
            'fallback_assignment_callback_url': null,
            'friendly_name': 'Default Fifo Workflow',
            'sid': 'WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
            'task_reservation_timeout': 120,
            'url': 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workflows/WFaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
            'workspace_sid': 'WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
        });
  
        holodeck.mock(new Response(200, body));
  
        var opts = {
          friendlyName: 'friendlyName',
          configuration: 'configuration',
          assignmentCallbackUrl: '/example'
        };
        var promise = client.taskrouter.v1.workspaces('WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                                          .workflows.create(opts);
        promise = promise.then(function(response) {
          expect(response).toBeDefined();
        }, function() {
          throw new Error('failed');
        });
  
        promise.done();
      }
    );
  });
  
  