Skip to content

Commit

Permalink
fix tests using assert
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieDanielson committed Jan 8, 2024
1 parent c17af35 commit 7847db3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
15 changes: 7 additions & 8 deletions packages/opentelemetry-core/test/utils/callback.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import * as assert from 'assert';
import * as sinon from 'sinon';
import { BindOnceFuture } from '../../src/utils/callback.js';
import { assertRejects } from '../test-utils.js';

describe('callback', () => {
describe('BindOnceFuture', () => {
Expand All @@ -34,27 +33,27 @@ describe('callback', () => {
assert.deepStrictEqual(stub.firstCall.args, [1]);
assert.deepStrictEqual(stub.firstCall.thisValue, that);

assert(future.isCalled);
assert.ok(future.isCalled);
});

it('should handle thrown errors', async () => {
const stub = sinon.stub();
stub.throws(new Error('foo'));
const future = new BindOnceFuture(stub, undefined);

await assertRejects(future.call(), /foo/);
await assertRejects(future.call(), /foo/);
await assertRejects(future.promise, /foo/);
await assert.rejects(future.call(), /foo/);
await assert.rejects(future.call(), /foo/);
await assert.rejects(future.promise, /foo/);
});

it('should handle rejections', async () => {
const stub = sinon.stub();
stub.rejects(new Error('foo'));
const future = new BindOnceFuture(stub, undefined);

await assertRejects(future.call(), /foo/);
await assertRejects(future.call(), /foo/);
await assertRejects(future.promise, /foo/);
await assert.rejects(future.call(), /foo/);
await assert.rejects(future.call(), /foo/);
await assert.rejects(future.promise, /foo/);
});
});
});
3 changes: 1 addition & 2 deletions packages/opentelemetry-core/test/utils/promise.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import * as assert from 'assert';
import { Deferred } from '../../src/utils/promise.js';
import { assertRejects } from '../test-utils.js';

describe('promise', () => {
describe('Deferred', () => {
Expand All @@ -35,7 +34,7 @@ describe('promise', () => {
deferred.reject(new Error('foo'));
deferred.reject(new Error('bar'));

await assertRejects(deferred.promise, /foo/);
await assert.rejects(deferred.promise, /foo/);
});
});
});

0 comments on commit 7847db3

Please sign in to comment.