Skip to content

Commit

Permalink
remove fork(domain) usage
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandrHoroshih committed Oct 12, 2023
1 parent 4dd3e19 commit 821deb6
Show file tree
Hide file tree
Showing 16 changed files with 64 additions and 64 deletions.
8 changes: 4 additions & 4 deletions src/combine-events/combine-events.fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test('works in forked scope', async () => {
const $store = app
.createStore({ e1: '', e2: '', e3: '' })
.on(result, (_, payload) => payload);
const scope = fork(app);
const scope = fork();
await Promise.all([
allSettled(e2, { scope, params: 'hi2' }),
allSettled(e1, { scope, params: 'hi1' }),
Expand All @@ -39,7 +39,7 @@ test('do not affects original store state', async () => {
const $store = app
.createStore({ e1: '', e2: '', e3: '' })
.on(result, (_, payload) => payload);
const scope = fork(app);
const scope = fork();
await Promise.all([
allSettled(e2, { scope, params: 'hi2' }),
allSettled(e1, { scope, params: 'hi1' }),
Expand Down Expand Up @@ -73,8 +73,8 @@ test('do not affects another scope', async () => {
.createStore({ e1: '', e2: '', e3: '' })
.on(result, (_, payload) => payload);

const scope1 = fork(app);
const scope2 = fork(app);
const scope1 = fork();
const scope2 = fork();

await Promise.all([
allSettled(e2, { scope: scope1, params: '1hi2' }),
Expand Down
8 changes: 4 additions & 4 deletions src/condition/condition.fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test('condition works in forked scope', async () => {
else: $else,
});

const scope = fork(app);
const scope = fork();

await allSettled(source, {
scope,
Expand Down Expand Up @@ -49,9 +49,9 @@ test('do not affect another forks', async () => {
else: $else,
});

const scope1 = fork(app);
const scope2 = fork(app);
const scope3 = fork(app);
const scope1 = fork();
const scope2 = fork();
const scope3 = fork();

const promise1 = allSettled(source, {
scope: scope1,
Expand Down
12 changes: 6 additions & 6 deletions src/debounce/debounce.fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test('debounce works in forked scope', async () => {

$counter.on(debounced, (value) => value + 1);

const scope = fork(app);
const scope = fork();

await allSettled(trigger, {
scope,
Expand All @@ -45,8 +45,8 @@ test('debounce do not affect another forks', async () => {

$counter.on(debounced, (value, payload) => value + payload);

const scopeA = fork(app);
const scopeB = fork(app);
const scopeA = fork();
const scopeB = fork();

await allSettled(trigger, {
scope: scopeA,
Expand Down Expand Up @@ -86,7 +86,7 @@ test('debounce do not affect original store value', async () => {

$counter.on(debounced, (value, payload) => value + payload);

const scope = fork(app);
const scope = fork();

await allSettled(trigger, {
scope,
Expand Down Expand Up @@ -116,8 +116,8 @@ test('debounce does not break parallel scopes', async () => {

$counter.on(debounced, (value, payload) => value + payload);

const scopeA = fork(app);
const scopeB = fork(app);
const scopeA = fork();
const scopeB = fork();

allSettled(trigger, {
scope: scopeA,
Expand Down
2 changes: 1 addition & 1 deletion src/debug/debug.fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test('works in forked scope', async () => {
.on(event, (counter, payload) => counter + payload)
.on(effect.done, (counter) => counter * 100);
debug($store, event, effect);
const scope = fork(app);
const scope = fork();

await allSettled(event, { scope, params: 5 });
expect(stringArguments(fn)).toMatchInlineSnapshot(`
Expand Down
10 changes: 5 additions & 5 deletions src/delay/delay.fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test('throttle works in forked scope', async () => {

$counter.on(throttled, (value) => value + 1);

const scope = fork(app);
const scope = fork();

await allSettled(source, {
scope,
Expand All @@ -38,7 +38,7 @@ test('throttle works in forked scope with target', async () => {

$counter.on(target, (value) => value + 1);

const scope = fork(app);
const scope = fork();

await allSettled(source, {
scope,
Expand All @@ -62,8 +62,8 @@ test('throttle do not affect another forks', async () => {

$counter.on(throttled, (value, payload) => value + payload);

const scopeA = fork(app);
const scopeB = fork(app);
const scopeA = fork();
const scopeB = fork();

await allSettled(trigger, {
scope: scopeA,
Expand Down Expand Up @@ -107,7 +107,7 @@ test('throttle do not affect original store value', async () => {

$counter.on(throttled, (value, payload) => value + payload);

const scope = fork(app);
const scope = fork();

await allSettled(trigger, {
scope,
Expand Down
8 changes: 4 additions & 4 deletions src/every/every.fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test('every works in forked scope', async () => {

const _$result = every({ predicate: 1, stores: [$first, $second, $third] });

const scope = fork(app);
const scope = fork();

await allSettled(change, {
scope,
Expand All @@ -45,8 +45,8 @@ test('every do not affect another forks', async () => {
stores: [$first, $second, $third],
});

const scopeA = fork(app);
const scopeB = fork(app);
const scopeA = fork();
const scopeB = fork();

await allSettled(change, {
scope: scopeA,
Expand Down Expand Up @@ -92,7 +92,7 @@ test('every do not affect original store value', async () => {
stores: [$first, $second, $third],
});

const scope = fork(app);
const scope = fork();

await allSettled(change, {
scope,
Expand Down
8 changes: 4 additions & 4 deletions src/format/format.fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test('format works in forked scope', async () => {

const $result = format`My name is ${$name}`;

const scope = fork(app);
const scope = fork();

await allSettled(changeName, { scope });

Expand Down Expand Up @@ -59,8 +59,8 @@ test('format do not affect another forks', async () => {

const $result = format`That ${$name} is a ${$age}`;

const firstScope = fork(app);
const secondScope = fork(app);
const firstScope = fork();
const secondScope = fork();

await allSettled(changeName, {
scope: firstScope,
Expand Down Expand Up @@ -107,7 +107,7 @@ test('format do not affect original store value', async () => {

const $result = format`My name is ${$name}`;

const scope = fork(app);
const scope = fork();

await allSettled(changeName, { scope });

Expand Down
8 changes: 4 additions & 4 deletions src/in-flight/in-flight.fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('effects', () => {
handler: () => new Promise((resolve) => setTimeout(resolve, 1)),
});
const $count = inFlight({ effects: [effect1, effect2] });
const scope = fork(app);
const scope = fork();

const finish = allSettled(effect1, { scope });
expect(scope.getState($count)).toMatchInlineSnapshot(`1`);
Expand All @@ -33,7 +33,7 @@ describe('effects', () => {
const run = app.createEvent();
sample({ clock: run, target: [effect1, effect2] });

const scope = fork(app);
const scope = fork();
expect(scope.getState($count)).toMatchInlineSnapshot(`0`);

const finish = allSettled(run, { scope });
Expand All @@ -54,7 +54,7 @@ describe('domain', () => {
handler: () => new Promise((resolve) => setTimeout(resolve, 1)),
});
const $count = inFlight({ domain });
const scope = fork(domain);
const scope = fork();

const finish = allSettled(effect1, { scope });
expect(scope.getState($count)).toMatchInlineSnapshot(`1`);
Expand All @@ -75,7 +75,7 @@ describe('domain', () => {
const run = domain.createEvent();
sample({ clock: run, target: [effect1, effect2] });

const scope = fork(domain);
const scope = fork();
expect(scope.getState($count)).toMatchInlineSnapshot(`0`);

const finish = allSettled(run, { scope });
Expand Down
6 changes: 3 additions & 3 deletions src/pending/pending.fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test('works in forked scope with domain', async () => {
handler: () => new Promise((resolve) => setTimeout(resolve, 1)),
});
const $pending = pending({ domain: app });
const scope = fork(app);
const scope = fork();

const finish = allSettled(effect1, { scope });
expect(scope.getState($pending)).toMatchInlineSnapshot(`true`);
Expand All @@ -52,7 +52,7 @@ test('concurrent run of different effects', async () => {
const run = app.createEvent();
sample({ clock: run, target: [effect1, effect2] });

const scope = fork(app);
const scope = fork();
expect(scope.getState($pending)).toMatchInlineSnapshot(`false`);

const finish = allSettled(run, { scope });
Expand All @@ -74,7 +74,7 @@ test('concurrent run of different effects with domain', async () => {
const run = app.createEvent();
sample({ clock: run, target: [effect1, effect2] });

const scope = fork(app);
const scope = fork();
expect(scope.getState($pending)).toMatchInlineSnapshot(`false`);

const finish = allSettled(run, { scope });
Expand Down
8 changes: 4 additions & 4 deletions src/reshape/reshape.fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test('works in forked scope', () => {
hasSpace: (original) => original.includes(' '),
},
});
const scope = fork(app);
const scope = fork();

expect(scope.getState(shape.length)).toBe(15);
expect(scope.getState(shape.uppercase)).toBe('SOME LONG VALUE');
Expand All @@ -35,8 +35,8 @@ test('do not affects another scope', async () => {
},
});
$original.on(change, (_, value) => value);
const scope1 = fork(app);
const scope2 = fork(app);
const scope1 = fork();
const scope2 = fork();

await Promise.all([
allSettled(change, { scope: scope1, params: 'hello world' }),
Expand Down Expand Up @@ -66,7 +66,7 @@ test('do not affects original store state', async () => {
},
});
$original.on(change, (_, value) => value);
const scope = fork(app);
const scope = fork();
await allSettled(change, { scope, params: 'demo' });

expect(scope.getState(shape.length)).toBe(4);
Expand Down
10 changes: 5 additions & 5 deletions src/snapshot/snapshot.fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ test('does not affects another scope', async () => {
clock: copy,
});

const scope1 = fork(app);
const scope2 = fork(app);
const scope1 = fork();
const scope2 = fork();

expect(scope1.getState($copy)).toBe(1);
expect(scope2.getState($copy)).toBe(1);
Expand All @@ -63,7 +63,7 @@ test('does not affect original store state', async () => {
clock: copy,
});

const scope = fork(app);
const scope = fork();

expect(scope.getState($copy)).toBe(1);
expect($copy.getState()).toBe(1);
Expand Down Expand Up @@ -93,8 +93,8 @@ test('store clock from one scope does not affect another', async () => {

const $copy = snapshot({ source: $original, clock: $trigger });

const scope1 = fork(app);
const scope2 = fork(app);
const scope1 = fork();
const scope2 = fork();

expect(scope1.getState($copy)).toBe('first');
expect(scope2.getState($copy)).toBe('first');
Expand Down
8 changes: 4 additions & 4 deletions src/some/some.fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test('throttle works in forked scope', async () => {

const _$result = some({ predicate: 1, stores: [$first, $second, $third] });

const scope = fork(app);
const scope = fork();

await allSettled(change, {
scope,
Expand All @@ -45,8 +45,8 @@ test('throttle do not affect another forks', async () => {
stores: [$first, $second, $third],
});

const scopeA = fork(app);
const scopeB = fork(app);
const scopeA = fork();
const scopeB = fork();

await allSettled(change, {
scope: scopeA,
Expand Down Expand Up @@ -92,7 +92,7 @@ test('throttle do not affect original store value', async () => {
stores: [$first, $second, $third],
});

const scope = fork(app);
const scope = fork();

await allSettled(change, {
scope,
Expand Down
8 changes: 4 additions & 4 deletions src/split-map/split-map.fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test('works in forked scope', async () => {
.on(out.first, (state, payload) => state + payload)
.on(out.__, (state, payload) => (payload ? -state : 0));

const scope = fork(app);
const scope = fork();

await allSettled(source, {
scope,
Expand Down Expand Up @@ -58,8 +58,8 @@ test('do not affect another fork', async () => {
.on(out.first, (state, payload) => state + payload)
.on(out.__, (state, payload) => (payload ? -state : 0));

const scopeA = fork(app);
const scopeB = fork(app);
const scopeA = fork();
const scopeB = fork();

await allSettled(source, {
scope: scopeA,
Expand Down Expand Up @@ -98,7 +98,7 @@ test('do not affect original store value', async () => {
.on(out.first, (state, payload) => state + payload)
.on(out.__, (state, payload) => (payload ? -state : 0));

const scope = fork(app);
const scope = fork();

await allSettled(source, {
scope,
Expand Down
Loading

0 comments on commit 821deb6

Please sign in to comment.