Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/base/test/node/id.test.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import assert from 'assert';
7
import { getMachineId, getSqmMachineId, getDevDeviceId } from '../../node/id.js';
8
import { getMac } from '../../node/macAddress.js';
9
import { flakySuite } from './testUtils.js';
10
import { ensureNoDisposablesAreLeakedInTestSuite } from '../common/utils.js';
11
12
flakySuite('ID', () => {
13
ensureNoDisposablesAreLeakedInTestSuite();
14
15
test('getMachineId', async function () {
16
const errors = [];
17
const id = await getMachineId(err => errors.push(err));
18
assert.ok(id);
19
assert.strictEqual(errors.length, 0);
20
});
21
22
test('getSqmId', async function () {
23
const errors = [];
24
const id = await getSqmMachineId(err => errors.push(err));
25
assert.ok(typeof id === 'string');
26
assert.strictEqual(errors.length, 0);
27
});
28
29
test('getDevDeviceId', async function () {
30
const errors = [];
31
const id = await getDevDeviceId(err => errors.push(err));
32
assert.ok(typeof id === 'string');
33
assert.strictEqual(errors.length, 0);
34
});
35
36
test('getMac', async () => {
37
const macAddress = getMac();
38
assert.ok(/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/.test(macAddress), `Expected a MAC address, got: ${macAddress}`);
39
});
40
});
41
42