Skip to content

Commit

Permalink
fix: remove object case
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed Apr 12, 2023
1 parent 8dae68d commit 0d26183
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/cmap/handshake/client_metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ declare const Deno: { version?: { deno?: string } } | undefined;
* expect it to satisfy. In order to not ship code in the driver that would break
* future versions of this runtime assume all properties are nullish.
*/
declare const Bun: { version?: string } | undefined;
declare const Bun: { (): void; version?: string } | undefined;

/**
* @internal
Expand Down Expand Up @@ -278,7 +278,7 @@ function getRuntimeInfo(): string {
if ('Bun' in globalThis) {
const version =
Bun != null &&
(typeof Bun === 'function' || typeof Bun === 'object') &&
typeof Bun === 'function' &&
'version' in Bun &&
typeof Bun.version === 'string'
? Bun.version
Expand Down
16 changes: 4 additions & 12 deletions test/unit/cmap/handshake/client_metadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,18 +344,10 @@ describe('client metadata module', () => {
expect(delete globalThis.Bun, 'failed to delete Bun global').to.be.true;
});

it('sets platform to Bun if typeof is object', () => {
globalThis.Bun = { version: '1.2.3' };
const metadata = makeClientMetadata({ driverInfo: {} });
expect(metadata.platform).to.equal('Bun v1.2.3, LE');
});

it('sets platform to Bun if typeof is function', () => {
function Bun() {
return null;
}
Bun.version = '1.2.3';
globalThis.Bun = Bun;
it('sets platform to Bun', () => {
globalThis.Bun = class {
static version = '1.2.3';
};
const metadata = makeClientMetadata({ driverInfo: {} });
expect(metadata.platform).to.equal('Bun v1.2.3, LE');
});
Expand Down

0 comments on commit 0d26183

Please sign in to comment.