Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve ndjson mock #8

Merged
merged 2 commits into from
Apr 17, 2020
Merged

Improve ndjson mock #8

merged 2 commits into from
Apr 17, 2020

Conversation

delvedor
Copy link
Member

With this pr, any request with content-type: application/x-ndjson is handled correctly and given to the user as an array of objects.
Example:

const mock = new Mock()
const client = new Client({
  node: 'http://localhost:9200',
  Connection: mock.getConnection()
})

mock.add({
  method: 'POST',
  path: '/_bulk'
}, params => {
  assert.deepStrictEqual(params.body, [
    { foo: 'bar' },
    { baz: 'fa\nz' }
  ])
  return { status: 'ok' }
})

const response = await client.bulk({
  body: [
    { foo: 'bar' },
    { baz: 'fa\nz' }
  ]
})
console.log(response)

@delvedor delvedor added the enhancement New feature or request label Apr 17, 2020
@delvedor delvedor merged commit b46d915 into master Apr 17, 2020
@delvedor delvedor deleted the improve-ndjson-mock branch April 17, 2020 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant