From 59e78afc16419e44d6e60f964b6da59d651034a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20P=C3=B6hlmann?= Date: Fri, 7 Oct 2022 21:01:55 +0200 Subject: [PATCH] fix tests due to refactor --- spec/ClearSubstitute.spec.ts | 21 ++++++++++----------- spec/Recorder.spec.ts | 8 ++++---- spec/regression/index.test.ts | 2 +- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/spec/ClearSubstitute.spec.ts b/spec/ClearSubstitute.spec.ts index b587d4c..722c0ca 100644 --- a/spec/ClearSubstitute.spec.ts +++ b/spec/ClearSubstitute.spec.ts @@ -1,7 +1,6 @@ import test from 'ava' import { Substitute, SubstituteOf } from '../src' -import { SubstituteBase } from '../src/SubstituteBase' import { SubstituteNode } from '../src/SubstituteNode' interface Calculator { @@ -12,7 +11,7 @@ interface Calculator { } type InstanceReturningSubstitute = SubstituteOf & { - [SubstituteBase.instance]: Substitute + [SubstituteNode.instance]: SubstituteNode } test('clears everything on a substitute', t => { @@ -21,8 +20,8 @@ test('clears everything on a substitute', t => { calculator.received().add(1, 1) calculator.clearSubstitute() - t.is(calculator[Substitute.instance].recorder.records.size, 0) - t.is(calculator[Substitute.instance].recorder.indexedRecords.size, 0) + t.is(calculator[SubstituteNode.instance].recorder.records.size, 0) + t.is(calculator[SubstituteNode.instance].recorder.indexedRecords.size, 0) t.throws(() => calculator.received().add(1, 1)) @@ -31,8 +30,8 @@ test('clears everything on a substitute', t => { calculator.received().add(1, 1) calculator.clearSubstitute('all') - t.is(calculator[Substitute.instance].recorder.records.size, 0) - t.is(calculator[Substitute.instance].recorder.indexedRecords.size, 0) + t.is(calculator[SubstituteNode.instance].recorder.records.size, 0) + t.is(calculator[SubstituteNode.instance].recorder.indexedRecords.size, 0) t.throws(() => calculator.received().add(1, 1)) }) @@ -43,8 +42,8 @@ test('clears received calls on a substitute', t => { calculator.add(1, 1).returns(2) calculator.clearSubstitute('receivedCalls') - t.is(calculator[Substitute.instance].recorder.records.size, 2) - t.is(calculator[Substitute.instance].recorder.indexedRecords.size, 2) + t.is(calculator[SubstituteNode.instance].recorder.records.size, 2) + t.is(calculator[SubstituteNode.instance].recorder.indexedRecords.size, 2) t.throws(() => calculator.received().add(1, 1)) t.is(calculator.add(1, 1), 2) @@ -56,10 +55,10 @@ test('clears return values on a substitute', t => { calculator.add(1, 1).returns(2) calculator.clearSubstitute('substituteValues') - t.is(calculator[Substitute.instance].recorder.records.size, 2) - t.is(calculator[Substitute.instance].recorder.indexedRecords.size, 2) + t.is(calculator[SubstituteNode.instance].recorder.records.size, 2) + t.is(calculator[SubstituteNode.instance].recorder.indexedRecords.size, 2) t.notThrows(() => calculator.received().add(1, 1)) // @ts-expect-error - t.true(calculator.add(1, 1)[SubstituteBase.instance] instanceof SubstituteNode) + t.true(calculator.add(1, 1)[SubstituteNode.instance] instanceof SubstituteNode) }) \ No newline at end of file diff --git a/spec/Recorder.spec.ts b/spec/Recorder.spec.ts index 0526185..c57622e 100644 --- a/spec/Recorder.spec.ts +++ b/spec/Recorder.spec.ts @@ -16,7 +16,7 @@ const otherNode = nodeFactory('otherNode') const otherNodeDifferentInstance = nodeFactory('otherNode') test('adds all records once only', t => { - const recorder = new Recorder() + const recorder = Recorder.withIdentityProperty('key') recorder.addRecord(node) recorder.addRecord(node) recorder.addRecord(otherNode) @@ -28,7 +28,7 @@ test('adds all records once only', t => { }) test('indexes all records correctly', t => { - const recorder = new Recorder() + const recorder = Recorder.withIdentityProperty('key') recorder.addIndexedRecord(node) recorder.addIndexedRecord(node) recorder.addIndexedRecord(otherNode) @@ -48,7 +48,7 @@ test('indexes all records correctly', t => { }) test('returns all sibling nodes', t => { - const recorder = new Recorder() + const recorder = Recorder.withIdentityProperty('key') recorder.addIndexedRecord(node) recorder.addIndexedRecord(otherNode) recorder.addIndexedRecord(otherNodeDifferentInstance) @@ -64,7 +64,7 @@ test('returns all sibling nodes', t => { }) test('clears recorded nodes by a given filter function', t => { - const recorder = new Recorder() + const recorder = Recorder.withIdentityProperty('key') recorder.addIndexedRecord(node) recorder.addIndexedRecord(otherNode) recorder.addIndexedRecord(otherNodeDifferentInstance) diff --git a/spec/regression/index.test.ts b/spec/regression/index.test.ts index 1ea0105..6bbd1c0 100644 --- a/spec/regression/index.test.ts +++ b/spec/regression/index.test.ts @@ -39,7 +39,7 @@ export class Example { } let instance: Example -let substitute: ObjectSubstitute, Example> +let substitute: ObjectSubstitute function initialize() { instance = new Example()