-
Notifications
You must be signed in to change notification settings - Fork 229
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
refactor(notifier)!: no initial state for makePublishKit #5742
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
const subAll = await Promise.all([ | ||
subscriber.subscribeAfter(), | ||
subscriber.subscribeAfter(expectedInitialCount - 1n), | ||
subscriber.subscribeAfter(0n), | ||
]); | ||
const [subFirst] = subAll; | ||
t.like(subFirst, { | ||
head: { done: false }, | ||
publishCount: expectedInitialCount, | ||
publishCount: 1n, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is assuming too much about the implementation details of makePublishKit
rather than its external interface. We should just drop the subscribeAfter
argument and publishCount
assertion.
const subAll = await Promise.all([ | |
subscriber.subscribeAfter(), | |
subscriber.subscribeAfter(expectedInitialCount - 1n), | |
subscriber.subscribeAfter(0n), | |
]); | |
const [subFirst] = subAll; | |
t.like(subFirst, { | |
head: { done: false }, | |
publishCount: expectedInitialCount, | |
publishCount: 1n, | |
}); | |
const subAll = await Promise.all([ | |
subscriber.subscribeAfter(), | |
subscriber.subscribeAfter(), | |
]); | |
const [subFirst] = subAll; | |
t.like(subFirst, { | |
head: { done: false }, | |
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is assuming too much about the implementation details
You mean the publicCount: 1n
part? (The 0n
argument is legit.)
I agree the interface doesn't guarantee that the next value will be one greater. Because there is a publish()
it does guarantee that it will be greater though, right?
When I read this test in master I thought it was about the counts after publish but the first test in the file checks those. This seems to really be testing publishing particular values (of the initialValues
) loop. Since there is no "initial value" anymore, and I trust there are already tests for .publish()
, I'll just remove this test.
@gibson042 PTAAL
542bbe2
to
1938583
Compare
Looking at the CI output I saw a number of floating promise warnings. Tacking on c2271c9 to resolve those and will merge by |
await makePublishKit(undefined).subscriber.subscribeAfter() | ||
).publishCount; | ||
t.true(expectedInitialCount > 0n); | ||
const initialValues = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this eliminates coverage that arbitrary values can be published, but that coverage probably is of little value.
void Promise.resolve(sub1.subscribeAfter()).then(result => | ||
sub1FirstAll.push(result), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might as well be consistent here.
void Promise.resolve(sub1.subscribeAfter()).then(result => | |
sub1FirstAll.push(result), | |
); | |
Promise.resolve(sub1.subscribeAfter()) | |
.then(result => sub1FirstAll.push(result)) | |
.catch(t.fail); |
void Promise.resolve(sub1.subscribeAfter(0n)).then(result => | ||
sub1FirstAll.push(result), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void Promise.resolve(sub1.subscribeAfter(0n)).then(result => | |
sub1FirstAll.push(result), | |
); | |
Promise.resolve(sub1.subscribeAfter(0n)) | |
.then(result => sub1FirstAll.push(result)) | |
.catch(t.fail); |
c2271c9
to
e05b6da
Compare
* refactor(notifier)!: no initial state for makePublishKit * chore: handle floating promises Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Extracted from #5704
Description
All publishing kits start empty: #5621
So
makePublishKit
shouldn't take an initial value and there's no need to have a separatemakeEmptyPublishKit
.Security Considerations
--
Documentation Considerations
--
Testing Considerations
Updated