Skip to content

Commit

Permalink
test: remove 2 unit tests that can't mock os anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Aug 1, 2023
1 parent 1adf294 commit 29afa2c
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"nyc": "^15.1.0",
"prettier": "^2.8.8",
"pretty-quick": "^3.1.0",
"sinon": "10.0.0",
"sinon": "^15.2.0",
"ts-node": "^10.0.0",
"typescript": "^4.9.5",
"wireit": "^0.10.0"
Expand Down
20 changes: 1 addition & 19 deletions test/unit/appInsights.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import * as os from 'os';
import { expect } from 'chai';
import * as sinon from 'sinon';
import { AppInsights, buildPropertiesAndMeasurements, getCpus, getPlatformVersion } from '../../src/appInsights';
import { AppInsights, buildPropertiesAndMeasurements } from '../../src/appInsights';
import set = Reflect.set;

describe('AppInsights', () => {
Expand All @@ -17,7 +16,6 @@ describe('AppInsights', () => {
let sandbox: sinon.SinonSandbox;
let trackStub: sinon.SinonStub;
let flushStub: sinon.SinonStub;
let osStub: sinon.SinonStub;

beforeEach(() => {
sandbox = sinon.createSandbox();
Expand Down Expand Up @@ -175,20 +173,4 @@ describe('AppInsights', () => {
expect(trackStub.calledOnce).to.be.true;
expect(flushStub.calledOnce).to.be.false;
});

it('should handle missing os.cpus value', () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
osStub = sandbox.stub(os, 'cpus').callsFake((() => undefined) as any);
const actual = getCpus();
expect(actual).to.equal('');
expect(osStub.calledOnce).to.be.true;
});

it('should handle missing os release value', () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
osStub = sandbox.stub(os, 'release').callsFake((() => undefined) as any);
const actual = getPlatformVersion();
expect(actual).to.equal('');
expect(osStub.calledOnce).to.be.true;
});
});
60 changes: 59 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,27 @@
dependencies:
type-detect "4.0.8"

"@sinonjs/commons@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-2.0.0.tgz#fd4ca5b063554307e8327b4564bd56d3b73924a3"
integrity sha512-uLa0j859mMrg2slwQYdO/AkrOfmH+X6LTVmNTS9CqexuE2IvVORIkSpJLqePAbEnKJ77aMmCwr1NUZ57120Xcg==
dependencies:
type-detect "4.0.8"

"@sinonjs/commons@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-3.0.0.tgz#beb434fe875d965265e04722ccfc21df7f755d72"
integrity sha512-jXBtWAF4vmdNmZgD5FoKsVLv3rPgDnLgPbU84LIJ3otV44vJlDRokVng5v8NFJdCf/da9legHcKaRuZs4L7faA==
dependencies:
type-detect "4.0.8"

"@sinonjs/fake-timers@^10.0.2", "@sinonjs/fake-timers@^10.3.0":
version "10.3.0"
resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz#55fdff1ecab9f354019129daf4df0dd4d923ea66"
integrity sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==
dependencies:
"@sinonjs/commons" "^3.0.0"

"@sinonjs/fake-timers@^6.0.0", "@sinonjs/fake-timers@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-6.0.1.tgz#293674fccb3262ac782c7aadfdeca86b10c75c40"
Expand Down Expand Up @@ -776,6 +797,15 @@
lodash.get "^4.4.2"
type-detect "^4.0.8"

"@sinonjs/samsam@^8.0.0":
version "8.0.0"
resolved "https://registry.yarnpkg.com/@sinonjs/samsam/-/samsam-8.0.0.tgz#0d488c91efb3fa1442e26abea81759dfc8b5ac60"
integrity sha512-Bp8KUVlLp8ibJZrnvq2foVhP0IVX2CIprMJPK0vqGqgrDa0OHVKeZyBykqskkrdxV6yKBPmGasO8LVjAKR3Gew==
dependencies:
"@sinonjs/commons" "^2.0.0"
lodash.get "^4.4.2"
type-detect "^4.0.8"

"@sinonjs/text-encoding@^0.7.1":
version "0.7.1"
resolved "https://registry.yarnpkg.com/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz#8da5c6530915653f3a1f38fd5f101d8c3f8079c5"
Expand Down Expand Up @@ -1938,6 +1968,11 @@ diff@^4.0.1, diff@^4.0.2:
resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d"
integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==

diff@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-5.1.0.tgz#bc52d298c5ea8df9194800224445ed43ffc87e40"
integrity sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==

dir-glob@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f"
Expand Down Expand Up @@ -3929,6 +3964,17 @@ nise@^4.1.0:
just-extend "^4.0.2"
path-to-regexp "^1.7.0"

nise@^5.1.4:
version "5.1.4"
resolved "https://registry.yarnpkg.com/nise/-/nise-5.1.4.tgz#491ce7e7307d4ec546f5a659b2efe94a18b4bbc0"
integrity sha512-8+Ib8rRJ4L0o3kfmyVCL7gzrohyDe0cMFTBa2d364yIrEGMEoetznKJx899YxjybU6bL9SQkYPSBBs1gyYs8Xg==
dependencies:
"@sinonjs/commons" "^2.0.0"
"@sinonjs/fake-timers" "^10.0.2"
"@sinonjs/text-encoding" "^0.7.1"
just-extend "^4.0.2"
path-to-regexp "^1.7.0"

no-case@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/no-case/-/no-case-3.0.4.tgz#d361fd5c9800f558551a8369fc0dcd4662b6124d"
Expand Down Expand Up @@ -4854,6 +4900,18 @@ [email protected]:
nise "^4.1.0"
supports-color "^7.1.0"

sinon@^15.2.0:
version "15.2.0"
resolved "https://registry.yarnpkg.com/sinon/-/sinon-15.2.0.tgz#5e44d4bc5a9b5d993871137fd3560bebfac27565"
integrity sha512-nPS85arNqwBXaIsFCkolHjGIkFo+Oxu9vbgmBJizLAhqe6P2o3Qmj3KCUoRkfhHtvgDhZdWD3risLHAUJ8npjw==
dependencies:
"@sinonjs/commons" "^3.0.0"
"@sinonjs/fake-timers" "^10.3.0"
"@sinonjs/samsam" "^8.0.0"
diff "^5.1.0"
nise "^5.1.4"
supports-color "^7.2.0"

sinon@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/sinon/-/sinon-5.1.1.tgz#19c59810ffb733ea6e76a28b94a71fc4c2f523b8"
Expand Down Expand Up @@ -5080,7 +5138,7 @@ supports-color@^5.3.0, supports-color@^5.4.0:
dependencies:
has-flag "^3.0.0"

supports-color@^7.1.0:
supports-color@^7.1.0, supports-color@^7.2.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da"
integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==
Expand Down

0 comments on commit 29afa2c

Please sign in to comment.