Skip to content

Commit

Permalink
refactor: move destroy tests into sub-suite
Browse files Browse the repository at this point in the history
  • Loading branch information
rainerhahnekamp committed Dec 2, 2024
1 parent 559979e commit 80809bf
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions modules/signals/spec/signal-method.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,29 @@ describe('signalMethod', () => {
expect(() => signalMethod<void>(() => void true)).toThrowError();
});

it('stops signal tracking, when signalMethod gets destroyed', () => {
let a = 1;
const summand = signal(1);
const adder = createAdder((value) => (a += value));
adder(summand);
describe('destroying signalMethod', () => {
it('stops signal tracking, when signalMethod gets destroyed', () => {
let a = 1;
const summand = signal(1);
const adder = createAdder((value) => (a += value));
adder(summand);

summand.set(2);
TestBed.flushEffects();
expect(a).toBe(3);
summand.set(2);
TestBed.flushEffects();
expect(a).toBe(3);

adder.destroy();
adder.destroy();

summand.set(2);
TestBed.flushEffects();
expect(a).toBe(3);
});
summand.set(2);
TestBed.flushEffects();
expect(a).toBe(3);
});

it('can also destroy a signalMethod that processes non-signal inputs', () => {
const adder = createAdder(() => void true);
expect(() => adder(1).destroy()).not.toThrowError();
});
it('can also destroy a signalMethod that processes non-signal inputs', () => {
const adder = createAdder(() => void true);
expect(() => adder(1).destroy()).not.toThrowError();
});

describe('destroying signalMethod', () => {
it('stops tracking all signals on signalMethod destroy', () => {
let a = 1;
const summand1 = signal(1);
Expand Down

0 comments on commit 80809bf

Please sign in to comment.