Skip to content

Commit 59e78af

Browse files
fix tests due to refactor
1 parent 66e5616 commit 59e78af

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

spec/ClearSubstitute.spec.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import test from 'ava'
22

33
import { Substitute, SubstituteOf } from '../src'
4-
import { SubstituteBase } from '../src/SubstituteBase'
54
import { SubstituteNode } from '../src/SubstituteNode'
65

76
interface Calculator {
@@ -12,7 +11,7 @@ interface Calculator {
1211
}
1312

1413
type InstanceReturningSubstitute<T> = SubstituteOf<T> & {
15-
[SubstituteBase.instance]: Substitute
14+
[SubstituteNode.instance]: SubstituteNode
1615
}
1716

1817
test('clears everything on a substitute', t => {
@@ -21,8 +20,8 @@ test('clears everything on a substitute', t => {
2120
calculator.received().add(1, 1)
2221
calculator.clearSubstitute()
2322

24-
t.is(calculator[Substitute.instance].recorder.records.size, 0)
25-
t.is(calculator[Substitute.instance].recorder.indexedRecords.size, 0)
23+
t.is(calculator[SubstituteNode.instance].recorder.records.size, 0)
24+
t.is(calculator[SubstituteNode.instance].recorder.indexedRecords.size, 0)
2625

2726
t.throws(() => calculator.received().add(1, 1))
2827

@@ -31,8 +30,8 @@ test('clears everything on a substitute', t => {
3130
calculator.received().add(1, 1)
3231
calculator.clearSubstitute('all')
3332

34-
t.is(calculator[Substitute.instance].recorder.records.size, 0)
35-
t.is(calculator[Substitute.instance].recorder.indexedRecords.size, 0)
33+
t.is(calculator[SubstituteNode.instance].recorder.records.size, 0)
34+
t.is(calculator[SubstituteNode.instance].recorder.indexedRecords.size, 0)
3635

3736
t.throws(() => calculator.received().add(1, 1))
3837
})
@@ -43,8 +42,8 @@ test('clears received calls on a substitute', t => {
4342
calculator.add(1, 1).returns(2)
4443
calculator.clearSubstitute('receivedCalls')
4544

46-
t.is(calculator[Substitute.instance].recorder.records.size, 2)
47-
t.is(calculator[Substitute.instance].recorder.indexedRecords.size, 2)
45+
t.is(calculator[SubstituteNode.instance].recorder.records.size, 2)
46+
t.is(calculator[SubstituteNode.instance].recorder.indexedRecords.size, 2)
4847

4948
t.throws(() => calculator.received().add(1, 1))
5049
t.is(calculator.add(1, 1), 2)
@@ -56,10 +55,10 @@ test('clears return values on a substitute', t => {
5655
calculator.add(1, 1).returns(2)
5756
calculator.clearSubstitute('substituteValues')
5857

59-
t.is(calculator[Substitute.instance].recorder.records.size, 2)
60-
t.is(calculator[Substitute.instance].recorder.indexedRecords.size, 2)
58+
t.is(calculator[SubstituteNode.instance].recorder.records.size, 2)
59+
t.is(calculator[SubstituteNode.instance].recorder.indexedRecords.size, 2)
6160

6261
t.notThrows(() => calculator.received().add(1, 1))
6362
// @ts-expect-error
64-
t.true(calculator.add(1, 1)[SubstituteBase.instance] instanceof SubstituteNode)
63+
t.true(calculator.add(1, 1)[SubstituteNode.instance] instanceof SubstituteNode)
6564
})

spec/Recorder.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const otherNode = nodeFactory('otherNode')
1616
const otherNodeDifferentInstance = nodeFactory('otherNode')
1717

1818
test('adds all records once only', t => {
19-
const recorder = new Recorder()
19+
const recorder = Recorder.withIdentityProperty<SubstituteNodeBase>('key')
2020
recorder.addRecord(node)
2121
recorder.addRecord(node)
2222
recorder.addRecord(otherNode)
@@ -28,7 +28,7 @@ test('adds all records once only', t => {
2828
})
2929

3030
test('indexes all records correctly', t => {
31-
const recorder = new Recorder()
31+
const recorder = Recorder.withIdentityProperty<SubstituteNodeBase>('key')
3232
recorder.addIndexedRecord(node)
3333
recorder.addIndexedRecord(node)
3434
recorder.addIndexedRecord(otherNode)
@@ -48,7 +48,7 @@ test('indexes all records correctly', t => {
4848
})
4949

5050
test('returns all sibling nodes', t => {
51-
const recorder = new Recorder()
51+
const recorder = Recorder.withIdentityProperty<SubstituteNodeBase>('key')
5252
recorder.addIndexedRecord(node)
5353
recorder.addIndexedRecord(otherNode)
5454
recorder.addIndexedRecord(otherNodeDifferentInstance)
@@ -64,7 +64,7 @@ test('returns all sibling nodes', t => {
6464
})
6565

6666
test('clears recorded nodes by a given filter function', t => {
67-
const recorder = new Recorder()
67+
const recorder = Recorder.withIdentityProperty<SubstituteNodeBase>('key')
6868
recorder.addIndexedRecord(node)
6969
recorder.addIndexedRecord(otherNode)
7070
recorder.addIndexedRecord(otherNodeDifferentInstance)

spec/regression/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class Example {
3939
}
4040

4141
let instance: Example
42-
let substitute: ObjectSubstitute<OmitProxyMethods<Example>, Example>
42+
let substitute: ObjectSubstitute<Example>
4343

4444
function initialize() {
4545
instance = new Example()

0 commit comments

Comments
 (0)