text: const assert = require('assert');
  const nock = require('nock');
  const extend = require('extend');
  const omit = require('object.omit');
  const { negativeHandler } = require('../../resources/test-helper');
  const deleteExample = require('../../../packages/assistant-v1/actions/delete-example');
  
  let credentials;
  let payload = {
    text: 'example_text',
    intent: 'example_intent',
    workspace_id: 'example_workspace_id',
    headers: {
      'User-Agent': 'openwhisk'
    }
  };
  
  before(() => {
    credentials = {
      username: 'username',
      password: 'password',
      version: 'version-date'
    };
    beforeEach(() => {
      nock('https://gateway.watsonplatform.net/assistant')
        .delete(`/api/v1/workspaces/${payload.workspace_id}`
                + `/intents/${payload.intent}`
                + `/examples/${payload.text}`)
        .query({
          version: credentials.version
        })
        .reply(200, {});
    });
    payload = extend({}, payload, credentials);
  });
  
  describe('delete-example', () => {
    it('should fail if credentials are missing', () => {
      const params = omit(payload, ['username', 'password']);
      return deleteExample
        .test(params)
        .then(() => {
          assert.fail('No failure on missing credentials');
        })
        .catch(err => negativeHandler(err));
    });
    it('should fail if version is missing', () => {
      const params = omit(payload, ['version']);
      return deleteExample
        .test(params)
        .then(() => {
          assert.fail('No failure on missing version');
        })
        .catch(err => negativeHandler(err));
    });
    it('should fail if workspace_id is missing', () => {
      const params = omit(payload, ['workspace_id']);
      return deleteExample
        .test(params)
        .then(() => {
          assert.fail('No failure on missing workspace_id');
        })
        .catch(err => negativeHandler(err));
    });
    it('should fail if text is missing', () => {
      const params = omit(payload, ['text']);
      return deleteExample
        .test(params)
        .then(() => {
          assert.fail('No failure on missing text');
        })
        .catch(err => negativeHandler(err));
    });
    it('should fail if intent is missing', () => {
      const params = omit(payload, ['intent']);
      return deleteExample
        .test(params)
        .then(() => {
          assert.fail('No failure on missing intent');
        })
        .catch(err => negativeHandler(err));
    });
    it('should generate a valid payload', () => {
      const params = payload;
      return deleteExample
        .test(params)
        .then(() => {
          assert.ok(true);
        })
        .catch(() => {
          assert.fail('Failure on valid payload');
        });
    });
    it('should succeed with __bx_creds as credential source', () => {
      const params = { __bx_creds: { conversation: payload } };
      return deleteExample
        .test(params)
        .then(() => {
          assert.ok(true);
        })
        .catch(() => {
          assert.fail('Failure on valid payload');
        });
    });
  });
  