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

get_output don't handle promises #687

Closed
jcubic opened this issue Aug 31, 2021 · 2 comments
Closed

get_output don't handle promises #687

jcubic opened this issue Aug 31, 2021 · 2 comments
Labels
Bug resolved if issue is resolved, it will be open until merge with master

Comments

@jcubic
Copy link
Owner

jcubic commented Aug 31, 2021

Issue summary

If you echo promise and call get_output you get [object Promise]

Expected behavior

I should get the value the promise is resolved to

Actual behavior

It return string [object Promise]

Steps to reproduce

function render(text, delay) {
    return new Promise(resolve => {
        setTimeout(() => resolve(text), delay);
    });
}

term.echo(() => render('lorem', 10));
term.echo('foo');
term.echo(() => render('ipsum', 10));
term.echo('bar');
term.echo(() => render('dolor', 10));
term.echo('baz');
setTimeout(() => { term.echo(term.get_output()); }, 500);

Found while writing unit tests for async echo, was not able to use get_output() in 1415082

@jcubic
Copy link
Owner Author

jcubic commented Sep 8, 2021

The code now works like this, if any of the lines resolve to a promise then get_output() will return a promise of a string.

jcubic added a commit that referenced this issue Sep 8, 2021
@jcubic
Copy link
Owner Author

jcubic commented Sep 8, 2021

Ther is still an issue, get_output() should not render the output, but get what is already printed on the terminal.

jcubic added a commit that referenced this issue Sep 12, 2021
Introduce snapshot output in OutputLines class that contain
lines that are printed on terminal. So they can be just
returned to the user
jcubic added a commit that referenced this issue Sep 12, 2021
jcubic added a commit that referenced this issue Sep 12, 2021
@jcubic jcubic added the resolved if issue is resolved, it will be open until merge with master label Sep 12, 2021
@jcubic jcubic closed this as completed Sep 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug resolved if issue is resolved, it will be open until merge with master
Projects
None yet
Development

No branches or pull requests

1 participant