Skip to content

Commit b9b59df

Browse files
committed
add unit test for not initialized and remove redundant stub restore
1 parent a3dfeb9 commit b9b59df

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

packages/core/src/test/shared/extensionUtilities.test.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ describe('isCn', function () {
147147
sandbox.restore()
148148
})
149149

150-
it('returns false when compute region is not initialized', async function () {
150+
it('returns false when compute region is not defined', async function () {
151151
// Reset the compute region to undefined first
152152
const utils = require('../../shared/extensionUtilities')
153153
Object.defineProperty(utils, 'computeRegion', {
@@ -157,7 +157,20 @@ describe('isCn', function () {
157157

158158
const result = isCn()
159159

160-
assert.strictEqual(result, false, 'isCn() should return false when compute region is not initialized')
160+
assert.strictEqual(result, false, 'isCn() should return false when compute region is undefined')
161+
})
162+
163+
it('returns false when compute region is not initialized', async function () {
164+
// Set the compute region to "notInitialized"
165+
const utils = require('../../shared/extensionUtilities')
166+
Object.defineProperty(utils, 'computeRegion', {
167+
value: 'notInitialized',
168+
configurable: true,
169+
})
170+
171+
const result = isCn()
172+
173+
assert.strictEqual(result, false, 'isCn() should return false when compute region is notInitialized')
161174
})
162175

163176
it('returns true for CN regions', async function () {
@@ -181,11 +194,6 @@ describe('isCn', function () {
181194
it('returns false when an error occurs', async function () {
182195
const utils = require('../../shared/extensionUtilities')
183196

184-
// Restore original getComputeRegion if it was stubbed
185-
if (utils.getComputeRegion.restore) {
186-
utils.getComputeRegion.restore()
187-
}
188-
189197
sandbox.stub(utils, 'getComputeRegion').throws(new Error('Test error'))
190198

191199
const result = isCn()

0 commit comments

Comments
 (0)