import Kinesis from 'aws-sdk/clients/kinesis'

import StreamQueue from '../StreamQueue'

export const numRecords = (stream) => {
  return 1
}

export const fakeKinesisConfigCreator = (config = null) => {
  return {
    client: fakeKinesisClientCreator(),
    streamConfigs: [fakeStreamConfigCreator()]
  }
}

export const fakeKinesisClientCreator = (config = null) => {
  const kinesisConfig = config || {
    apiVersion: '2013-12-02',
    region: 'us-west-2',
    endpoint: 'kinesis.docker' }

  return new Kinesis(kinesisConfig)
}

export const fakeStreamConfigCreator = (config = {}) => {
  return {
    eventTypes: { EVENT: () => {} },
    maxPageSize: 5, // max number events sent at once
    sendRecordsTimeout: 1000, // in milliseconds
    stream: 'KinesisResponsesStreamName',
    whiny: true
  }
}

export const fakeStreamQueueCreator = (
  kinesis = fakeKinesisClientCreator(),
  config = fakeStreamConfigCreator()
) => {
  return new StreamQueue({ config, kinesis })
}
