Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Handle object literal types #39

Merged
merged 6 commits into from
Mar 25, 2018
Merged

Conversation

MadaraUchiha
Copy link
Contributor

Fixes #19

Add support for object types inference.

#goodnessSquad

@MadaraUchiha MadaraUchiha requested a review from urish March 21, 2018 19:04
@coveralls
Copy link

coveralls commented Mar 21, 2018

Coverage Status

Coverage increased (+0.5%) to 86.123% when pulling 3f63cbb on MadaraUchiha:parse-object-type into 8e227d0 on urish:master.

@urish
Copy link
Collaborator

urish commented Mar 23, 2018

Thanks! Let's also add at least one integration test for this?

guywarburg and others added 2 commits March 24, 2018 14:06
- Add support for simple object literals
- Follows nesting rules of arrays
- Remove old object test, add several integration tests for objects.

Fixes mockdeep#19

Courtesy of #goodnessSquad
- Currently runs them through JSON.stringify(), might want to look at
  other solutions for folks who want single quotes
- Also add test for that.
So that things like yarn-error.log don't get committed by accident.
@@ -3,3 +3,4 @@ dist
node_modules
.idea
assets/typewiz.psd
*.log
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this a request for change?

Copy link
Collaborator

Choose a reason for hiding this comment

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

nope :)

}

return typeof value;
}

function getObjectTypes(obj: any, nest: number): string {
const keys = Object.keys(obj);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's sort the keys so we always get the same result for objects of the same shape.

e.g. given either of the following inputs:

Object.keys({ a: 1, b : 2 }) //  ["a", "b"]
Object.keys({ b: 1, a : 2 }) // ["b", "a"]

we'd like to get the same output (let's also add a test case covering this)

- Ensures more consistent results
- Modify unit test and integration tests to match.
@urish urish merged commit 3146da7 into mockdeep:master Mar 25, 2018
@urish
Copy link
Collaborator

urish commented Mar 25, 2018

Thanks!

@urish
Copy link
Collaborator

urish commented Mar 26, 2018

Released as part of 0.7.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants