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

add failing test case. #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mxdubois
Copy link

Failing test case for #1

It looks like you weren't testing inheritance from the factory, previously. I'm not sure if you meant to support that use case or not, but I think it'd be nice.

Fwiw, I'm trying to use to-factory as a decorator before export, as below, so I can use the class as a factory throughout my codebase. I'm sure there are valid arguments against doing this, but I like it well enough for the codebase I'm working on.

@toFactory
export default class MyClass {
  // ...
}

const withoutNew = D('withoutNew')

t.equal(withNew.constructor, C, 'withNew has the correct constructor')
t.equal(withoutNew.constructor, C, 'withoutNew has the correct constructor')
Copy link
Author

Choose a reason for hiding this comment

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

It's debatable whether or not these should have constructor == C or constructor == D.

@timoxley
Copy link
Owner

I believe I left out the inheritance stuff because it doesn't/didn't work properly with native types e.g. Array/Promise.

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

Successfully merging this pull request may close these issues.

None yet

2 participants