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 flush() method #115

Merged
merged 4 commits into from
Dec 9, 2024
Merged

Add flush() method #115

merged 4 commits into from
Dec 9, 2024

Conversation

nytamin
Copy link
Member

@nytamin nytamin commented Dec 5, 2024

Add a flush() method, as discussed in #106

@nytamin
Copy link
Member Author

nytamin commented Dec 5, 2024

Hey @loucadufault, could you give this PR a quick review to ensure that it fits with your use case (pay extra attention to the unit tests) ?

Copy link
Contributor

@loucadufault loucadufault left a comment

Choose a reason for hiding this comment

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

looks to cover the use case proposed in the issue well, thanks!

Comment on lines +25 to +27
.add(async () => {
await this.device.write(data)
})
Copy link
Contributor

Choose a reason for hiding this comment

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

small nit: you could directly return the promise here

Suggested change
.add(async () => {
await this.device.write(data)
})
.add(() => this.device.write(data))

Comment on lines +168 to +169
expect(mockWriteEnd).toBeCalledTimes(0) // Should not have been called yet

Copy link
Contributor

Choose a reason for hiding this comment

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

you could use jest fake timers instead, and advance the timers here by 10ms to make the test a bit more guaranteed

@nytamin nytamin merged commit 4f96cab into master Dec 9, 2024
12 checks passed
@nytamin nytamin deleted the feat/flush branch December 9, 2024 07:56
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.

2 participants