<commit_before>// var AWS = require('aws-sdk');
// var lib = require('../index.js');
// var dynamo = {};
// var apiHelper = require('../api.js');
//
// var dynamoconfig = {
//   endpoint: 'http://localhost:8000',
//   region: 'someregion',
//   accessKeyId: 'test',
//   secretAccessKey: 'test'
// };
//
// dynamo = new lib.dynamo(dynamoconfig);
// dynamo.tableName = 'test';
//
// var api = apiHelper('test', dynamo);
//
//
// describe('stock api', function () {
//   beforeEach(function () {
//
//   });
//
//   it('that creates a table', function (done) {
//     var params = {
//       TableName: dynamo.tableName,
//       AttributeDefinitions: [
//       { 'AttributeName': 'id', 'AttributeType': 'S' },
//       ],
//       KeySchema: [
//       { 'AttributeName': 'id', 'KeyType': 'HASH' },
//       ],
//       ProvisionedThroughput: {
//         ReadCapacityUnits: 1,
//         WriteCapacityUnits: 1
//       },
//     };
//
//     var response = lib.createTable(params, dynamo);
//
//     response.then(function (response) {
//       expect(response).toBeDefined();
//       done();
//     });
//   });
//
//   describe('checks api functions', function () {
//     var lambdaContextSpy;
//
//     beforeEach(function () {
//       lambdaContextSpy = jasmine.createSpyObj('lambdaContext', ['done']);
//     });
//
//     describe('gets an object', function () {
//       api.proxyRouter({
//         requestContext: {
//           resourcePath: '/foo',
//           httpMethod: 'GET'
//         },
//         queryString: {
//           id: '1'
//         }
//       }, lambdaContextSpy);
//     });
//   });
//
//   it('deletes the table', function (done) {
//     var params = {
//       TableName: dynamo.tableName,
//     };
//     dynamo.raw.deleteTable(params, function(err, data) {
//       expect(err).toBeNull();
//       done();
//     });
//   });
// });<commit_msg>added basic test for api<commit_after>var ApiBuilder = require('claudia-api-builder');
var AWS = require('aws-sdk');
var lib = require('../index.js');
var dynamo = {};

var dynamoconfig = {
  endpoint: 'http://localhost:8000',
  region: 'someregion',
  accessKeyId: 'test',
  secretAccessKey: 'test'
};

var dynamo = new lib.dynamo(dynamoconfig);
dynamo.tableName = 'test';

var api = new ApiBuilder();
api = lib.api('foo', api, dynamo);


describe('stock api', function () {
  beforeAll(function () {
    var dynamoconfig = {
      endpoint: 'http://localhost:8000',
      region: 'someregion',
      accessKeyId: 'test',
      secretAccessKey: 'test'
    };

    var dynamo = new lib.dynamo(dynamoconfig);
    dynamo.tableName = 'test';

    var api = new ApiBuilder();
    api = lib.api('foo', api, dynamo);
  });

  beforeAll(function (done) {
    var params = {
      TableName: dynamo.tableName,
      AttributeDefinitions: [
      { 'AttributeName': 'id', 'AttributeType': 'S' },
      ],
      KeySchema: [
      { 'AttributeName': 'id', 'KeyType': 'HASH' },
      ],
      ProvisionedThroughput: {
        ReadCapacityUnits: 1,
        WriteCapacityUnits: 1
      },
    };

    var response = lib.createTable(params, dynamo);

    response.then(function (response) {
      done();
    });
  });

  afterAll(function (done) {
    var params = {
      TableName: dynamo.tableName,
    };
    dynamo.raw.deleteTable(params, function(err, data) {
      done();
    });
  });

  describe('checks api functions', function () {
    var lambdaContextSpy;

    beforeEach(function () {
      lambdaContextSpy = jasmine.createSpyObj('lambdaContext', ['done']);
    });

    it('posts an object', function (done) {
      api.proxyRouter({
        requestContext: {
          resourcePath: '/foo',
          httpMethod: 'POST'
        },
        body: {
          name: 'foo'
        }
      }, lambdaContextSpy)
      .then(function () {
        console.log(lambdaContextSpy.done);
        expect(lambdaContextSpy.done).toHaveBeenCalled();
        expect(lambdaContextSpy.done).toHaveBeenCalledWith(null, jasmine.objectContaining({statusCode:200}));
      })
      .then(done, done.fail);
    });

    it('gets an object', function (done) {
      api.proxyRouter({
        requestContext: {
          resourcePath: '/foo',
          httpMethod: 'GET'
        },
        queryString: {
          id: '1'
        }
      }, lambdaContextSpy)
      .then(function () {
        expect(lambdaContextSpy.done).toHaveBeenCalled();
        expect(lambdaContextSpy.done).toHaveBeenCalledWith(null, jasmine.objectContaining({statusCode:200}));
      })
      .then(done, done.fail);
    });
  });
});
{'fraction_non_alphanumeric': 0.1839632947345423, 'fraction_numerical': 0.005243609351103343, 'mean_word_length': 2.2171468728039354, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '758621', 'n_tokens_mistral': 1476, 'n_tokens_neox': 1446, 'n_words': 264}