Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: unit test
  • Loading branch information
nbbeeken committed Apr 12, 2023
commit 5901ba8246d8d3228ad052277d552dc7bfd718f2
20 changes: 16 additions & 4 deletions test/unit/cmap/handshake/client_metadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ describe('client metadata module', () => {
});
});

context('when globalThis indicates alternative runtime', () => {
context.only('when globalThis indicates alternative runtime', () => {
context('deno', () => {
afterEach(() => {
expect(delete globalThis.Deno, 'failed to delete Deno global').to.be.true;
Expand Down Expand Up @@ -353,19 +353,31 @@ describe('client metadata module', () => {
});

it('sets platform to Bun with driverInfo.platform', () => {
globalThis.Bun = { version: '1.2.3' };
globalThis.Bun = class {
static version = '1.2.3';
};
const metadata = makeClientMetadata({ driverInfo: { platform: 'myPlatform' } });
expect(metadata.platform).to.equal('Bun v1.2.3, LE|myPlatform');
});

it('ignores version if Bun.version is not a string', () => {
globalThis.Bun = { version: 1 };
globalThis.Bun = class {
static version = 1;
};
const metadata = makeClientMetadata({ driverInfo: {} });
expect(metadata.platform).to.equal('Bun v0.0.0, LE');
});

it('ignores version if Bun.version is not a string and sets driverInfo.platform', () => {
globalThis.Bun = { version: 1 };
globalThis.Bun = class {
static version = 1;
};
const metadata = makeClientMetadata({ driverInfo: { platform: 'myPlatform' } });
expect(metadata.platform).to.equal('Bun v0.0.0, LE|myPlatform');
});

it('ignores version if Bun is not a function', () => {
globalThis.Bun = { version: '1.2.3' };
const metadata = makeClientMetadata({ driverInfo: { platform: 'myPlatform' } });
expect(metadata.platform).to.equal('Bun v0.0.0, LE|myPlatform');
});
Expand Down