Skip to content

Commit 8db0ded

Browse files
feat(LdpContainer): initial push doesn't wait for debounce time
1 parent 1eb909a commit 8db0ded

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

core/src/ldp-container/LdpContainer.contains.spec.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,7 @@ describe("LDP container", () => {
122122
subscription.unsubscribe();
123123
});
124124

125-
it("pushes existing values immediately after debounce time", () => {
126-
// before debounce time is complete
127-
jest.advanceTimersByTime(100);
128-
expect(subscriber).toHaveBeenCalledTimes(0);
129-
130-
// after debounce time
131-
jest.advanceTimersByTime(150);
125+
it("pushes existing values immediately", () => {
132126
expect(subscriber).toHaveBeenCalledTimes(1);
133127
expect(subscriber.mock.calls).toEqual([
134128
[
@@ -144,9 +138,6 @@ describe("LDP container", () => {
144138

145139
it("pushes new values once per group of changes until unsubcribe, ignoring irrelevant changes", () => {
146140
const containsSpy = jest.spyOn(container, "contains");
147-
// wait for first push to settle
148-
jest.advanceTimersByTime(250);
149-
// then update container contents
150141
internalStore.removeDocument(sym("https://pod.test/container/"));
151142
internalStore.addAll([
152143
quad(
@@ -168,8 +159,9 @@ describe("LDP container", () => {
168159
),
169160
]);
170161
jest.advanceTimersByTime(255);
162+
// Note: subscriber counted initial push but containsSpy didn't
171163
expect(subscriber).toHaveBeenCalledTimes(2);
172-
expect(containsSpy).toHaveBeenCalledTimes(2);
164+
expect(containsSpy).toHaveBeenCalledTimes(1);
173165
expect(subscriber.mock.calls).toEqual([
174166
[
175167
[
@@ -202,7 +194,7 @@ describe("LDP container", () => {
202194
sym("https://pod.test/container/"),
203195
);
204196
expect(subscriber).toHaveBeenCalledTimes(2);
205-
expect(containsSpy).toHaveBeenCalledTimes(2);
197+
expect(containsSpy).toHaveBeenCalledTimes(1);
206198
});
207199
});
208200
});

core/src/ldp-container/LdpContainer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ export class LdpContainer extends Thing {
4646
quad.graph.value == this.uri &&
4747
quad.predicate.value == "http://www.w3.org/ns/ldp#contains",
4848
),
49-
startWith(this.contains()),
5049
debounceTime(250),
5150
map(() => this.contains()),
51+
startWith(this.contains()),
5252
);
5353
}
5454
}

0 commit comments

Comments
 (0)