-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Preserve zero input in Node API #2591
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,7 +98,7 @@ function transformArgs(opArgsList, newArgs) { | |
| * @param input | ||
| */ | ||
| function ensureIsDish(input) { | ||
| if (!input) { | ||
| if (!input && input !== 0) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vetrovk Is there a reason for this approach instead of the |
||
| return new NodeDish(); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,6 +97,11 @@ TestRegister.addApiTests([ | |
| assert(result instanceof NodeDish); | ||
| }), | ||
|
|
||
| it("should preserve numeric zero input", () => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't use "preserve" for the title of this test - I think "process" would make more sense here? |
||
| const result = chef.toHex(0); | ||
| assert.strictEqual(result.toString(), "30"); | ||
| }), | ||
|
|
||
| it("should coerce to a string as you expect", () => { | ||
| const result = chef.fromBase32(chef.toBase32("something")); | ||
| assert.equal(String(result), "something"); | ||
|
|
@@ -180,6 +185,11 @@ TestRegister.addApiTests([ | |
| assert.strictEqual(result.toString(), "ONXW2ZJANFXHA5LU"); | ||
| }), | ||
|
|
||
| it("chef.bake: should preserve numeric zero input", async () => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't use "preserve" for the title of this test - I think "process" would make more sense here? |
||
| const result = await chef.bake(0, "to hex"); | ||
| assert.strictEqual(result.toString(), "30"); | ||
| }), | ||
|
|
||
| it("chef.bake: should complain if recipe isnt a valid object", async () => { | ||
| await assert.rejects(() => chef.bake("some input", 3264), { | ||
| name: "TypeError", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,6 +59,13 @@ TestRegister.addApiTests([ | |
| assert.strictEqual(result.toString(), "7"); | ||
| }), | ||
|
|
||
| it("ADD: preserves numeric zero input", () => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't use "preserve" for the title of this test - I think "process" would make more sense here? |
||
| const result = chef.ADD(0, { | ||
| key: "4", | ||
| }); | ||
| assert.strictEqual(result.toString(), "4"); | ||
| }), | ||
|
|
||
| it("addLineNumbers: No arguments", () => { | ||
| const result = addLineNumbers("sample input"); | ||
| assert.equal(result.toString(), "1 sample input"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vetrovk Is there a reason for this approach instead of the
input === undefined || input === nullrecommended in the issue?