close
Skip to content

Add basic tests for decodeArrayStream#44

Merged
sergeyzenchenko merged 2 commits intomsgpack:masterfrom
sergeyzenchenko:master
May 30, 2019
Merged

Add basic tests for decodeArrayStream#44
sergeyzenchenko merged 2 commits intomsgpack:masterfrom
sergeyzenchenko:master

Conversation

@sergeyzenchenko
Copy link
Copy Markdown
Collaborator

@gfx just few of basic tests for decodeArrayStream #42

@codecov-io
Copy link
Copy Markdown

codecov-io commented May 30, 2019

Codecov Report

Merging #44 into master will increase coverage by 2.13%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #44      +/-   ##
==========================================
+ Coverage   91.46%   93.59%   +2.13%     
==========================================
  Files          14       15       +1     
  Lines         808      828      +20     
  Branches      170      173       +3     
==========================================
+ Hits          739      775      +36     
+ Misses         49       28      -21     
- Partials       20       25       +5
Impacted Files Coverage Δ
src/index.ts 100% <0%> (ø) ⬆️
src/utils/stream.ts 26.66% <0%> (ø)
src/Decoder.ts 96.42% <0%> (+7.46%) ⬆️
src/decodeAsync.ts 100% <0%> (+33.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0e3f706...1bc03a7. Read the comment docs.

Comment thread test/decodeArrayStream.test.ts Outdated
error = e;
}

assert.notStrictEqual(error, null);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use assert.rejects() https://nodejs.org/api/assert.html#assert_assert_rejects_asyncfn_error_message

You can find its usage in this repo.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@gfx
Copy link
Copy Markdown
Member

gfx commented May 30, 2019

Thanks!

BTW you can just return AsyncIterable from decodeAsync() like this:

diff --git a/src/decodeAsync.ts b/src/decodeAsync.ts
index d4bea9e..1773eb4 100644
--- a/src/decodeAsync.ts
+++ b/src/decodeAsync.ts
@@ -19,10 +19,10 @@ export async function decodeAsync(
   return decoder.decodeOneAsync(stream);
 }
 
-export async function* decodeArrayStream(
+export function decodeArrayStream(
   stream: AsyncIterable<Uint8Array | ArrayLike<number>>,
   options: DecodeAsyncOptions = defaultDecodeOptions,
-) {
+): AsyncIterable<unknown> {
   const decoder = new Decoder(
     options.extensionCodec,
     options.maxStrLength,
@@ -32,7 +32,5 @@ export async function* decodeArrayStream(
     options.maxExtLength,
   );
 
-  for await (let item of decoder.decodeArrayStream(stream)) {
-    yield item;
-  }
+  return decoder.decodeArrayStream(stream);
 }

@sergeyzenchenko
Copy link
Copy Markdown
Collaborator Author

@gfx duh :) I will fix it in PR for decodeStream #46

Copy link
Copy Markdown
Member

@gfx gfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay! Approved.

@gfx gfx mentioned this pull request May 30, 2019
@sergeyzenchenko sergeyzenchenko merged commit 9fd6111 into msgpack:master May 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants