We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Right now computed enum values don't work. This bug is not too problematic since it doesn't break the tests.
I found out that enums can have computed values... and we don't support them, we assign 0 to the property if the value is computed.
describe('for enum with computed properties', () => { describe('using inline calculations', () => { enum Computed1 { A = 1 + 5, B } interface IntComputed1 { en: Computed1; } it('should mock the correct values', () => { const properties: IntComputed1 = createMock<IntComputed1>(); expect(properties.en).toEqual(Computed1.A); }); }); describe('using local function', () => { function compute(): number { return 4; } enum Computed2 { A = compute(), B = 4 } interface IntComputed2 { en: Computed2; } it('should mock the correct values', () => { const properties: IntComputed2 = createMock<IntComputed2>(); expect(properties.en).toEqual(Computed2.A); }); }); describe('using imported function', () => { enum Computed3 { A = computed(), // function imported `computed = () => 4` B = 4 } interface IntComputed3 { en: Computed3; } it('should mock the correct values', () => { const properties: IntComputed3 = createMock<IntComputed3>(); expect(properties.en).toEqual(Computed3.A); }); }); });
All these tests will fail because the property generated will have 0 as value.
0
Generated mocked property have the correct computed value
Generated mocked property value is 0
The text was updated successfully, but these errors were encountered:
I love it :) we always learn new things from typescript :)
Sorry, something went wrong.
Half of this is solved by #526
No branches or pull requests
Subject of the issue
Right now computed enum values don't work. This bug is not too problematic since it doesn't break the tests.
Your environment
Steps to reproduce
I found out that enums can have computed values... and we don't support them, we assign 0 to the property if the value is computed.
All these tests will fail because the property generated will have
0
as value.Expected behavior
Generated mocked property have the correct computed value
Actual behavior
Generated mocked property value is 0
The text was updated successfully, but these errors were encountered: