Skip to content

Commit 38ba68b

Browse files
committed
refactor: remove duplicate code in the tests
1 parent 7343b3e commit 38ba68b

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

packages/core/src/test/awsService/ec2/prompter.test.ts

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,40 +47,32 @@ describe('Ec2Prompter', async function () {
4747
describe('asQuickPickItem', async function () {
4848
let prompter: MockEc2Prompter
4949

50+
const testQuickPick = (instance: SafeEc2Instance) => {
51+
const result = prompter.testAsQuickPickItem(testInstance)
52+
assert.deepStrictEqual(result, {
53+
label: Ec2Prompter.getLabel(testInstance),
54+
detail: testInstance.InstanceId,
55+
data: testInstance.InstanceId,
56+
})
57+
}
58+
5059
before(function () {
5160
prompter = new MockEc2Prompter()
5261
})
5362

5463
it('returns QuickPickItem for named instances', function () {
55-
const testInstance = {
64+
testQuickPick({
5665
Name: 'testName',
5766
InstanceId: 'testInstanceId',
5867
LastSeenStatus: 'running',
59-
} as SafeEc2Instance
60-
61-
const result = prompter.testAsQuickPickItem(testInstance)
62-
const expected = {
63-
label: Ec2Prompter.getLabel(testInstance),
64-
detail: testInstance.InstanceId,
65-
data: testInstance.InstanceId,
66-
}
67-
assert.deepStrictEqual(result, expected)
68+
})
6869
})
6970

7071
it('returns QuickPickItem for non-named instances', function () {
71-
const testInstance = {
72+
testQuickPick({
7273
InstanceId: 'testInstanceId',
7374
LastSeenStatus: 'running',
74-
} as SafeEc2Instance
75-
76-
const result = prompter.testAsQuickPickItem(testInstance)
77-
const expected = {
78-
label: Ec2Prompter.getLabel(testInstance),
79-
detail: testInstance.InstanceId,
80-
data: testInstance.InstanceId,
81-
}
82-
83-
assert.deepStrictEqual(result, expected)
75+
})
8476
})
8577
})
8678

0 commit comments

Comments
 (0)