Skip to content

Commit 6d09997

Browse files
committed
Allow act/upsert during subscribe() call
1 parent e7fd412 commit 6d09997

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

packages/core-graph/src/private/Graph2.subscribe.spec.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ scenario('Graph.subscribe()', bdd => {
9191
const graph = new Graph(() => () => request => request);
9292
const subscriber = fn(() => {
9393
// Should throw.
94-
graph.act(() => {
95-
// Intentionally left blank.
94+
graph.act(({ upsert }) => {
95+
upsert({ '@id': '_:b2' });
9696
});
9797
});
9898

@@ -111,11 +111,14 @@ scenario('Graph.subscribe()', bdd => {
111111

112112
return undefined;
113113
})
114-
.then('should throw', (_, error) => {
115-
expect(() => {
116-
if (error) {
117-
throw error;
118-
}
119-
}).toThrow('Another transaction is ongoing');
120-
});
114+
.then('getState() should return both nodes', ({ graph }) =>
115+
expect(graph.getState()).toEqual(
116+
new Map(
117+
Object.entries({
118+
'_:b1': { '@id': '_:b1', name: 'John Doe' },
119+
'_:b2': { '@id': '_:b2', name: 'Mary Doe' }
120+
})
121+
)
122+
)
123+
);
121124
});

0 commit comments

Comments
 (0)