Skip to content

Commit

Permalink
[event-hubs] cleanup rollup config (Azure#10228)
Browse files Browse the repository at this point in the history
* [event-hubs] remove EventEmitter named export from rollup config

* fix issue where karma still runs in background after appearing to exit

* update test to no longer reference os to clean up rollup config

* remove more shims

* only shim dotenv for tests
  • Loading branch information
chradek authored Jul 24, 2020
1 parent 2c7ef65 commit b00069c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion sdk/eventhub/event-hubs/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ module.exports = function(config) {

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
singleRun: true,

// Concurrency level
// how many browser should be started simultaneous
Expand Down
22 changes: 8 additions & 14 deletions sdk/eventhub/event-hubs/rollup.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,27 +107,21 @@ export function browserConfig(test = false) {
"if (isNode)": "if (false)"
}
),

// dotenv, path, and os don't work in the browser, so replace it with a no-op function
shim({
fs: `export default {}`,
dotenv: `export function config() { }`,
os: `
export function arch() { return "javascript" }
export function type() { return "Browser" }
export function release() { return typeof navigator === 'undefined' ? '' : navigator.appVersion }
`,
path: `export default {}`
}),

...(!test
? []
: [
shim({
// dotenv doesn't work in the browser, so replace it with a no-op function
dotenv: `export function config() { }`
})
]),
nodeResolve({
mainFields: ["module", "browser"],
preferBuiltins: false
}),

cjs({
namedExports: {
events: ["EventEmitter"],
"@opentelemetry/api": ["CanonicalCode", "SpanKind", "TraceFlags"]
}
}),
Expand Down
8 changes: 5 additions & 3 deletions sdk/eventhub/event-hubs/test/client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT license.

import chai from "chai";
import * as os from "os";
const should = chai.should();
import chaiAsPromised from "chai-as-promised";
chai.use(chaiAsPromised);
Expand All @@ -20,6 +19,7 @@ import { packageJsonInfo } from "../src/util/constants";
import { EnvVarKeys, getEnvVars, isNode } from "./utils/testUtils";
import { MessagingError } from "@azure/core-amqp";
import { ConnectionContext } from "../src/connectionContext";
import { getRuntimeInfo } from "../src/util/runtimeInfo";
const env = getEnvVars();

describe("Create EventHubConsumerClient", function(): void {
Expand Down Expand Up @@ -516,15 +516,17 @@ describe("EventHubProducerClient User Agent String", function(): void {
function testUserAgentString(context: ConnectionContext, customValue?: string) {
const packageVersion = packageJsonInfo.version;
const properties = context.connection.options.properties;
properties!["user-agent"].should.startWith(`azsdk-js-azureeventhubs/${packageVersion}`);
properties!["user-agent"].should.startWith(
`azsdk-js-azureeventhubs/${packageVersion} (${getRuntimeInfo()})`
);
should.equal(properties!.product, "MSJSClient");
should.equal(properties!.version, packageVersion);
if (isNode) {
should.equal(properties!.framework, `Node/${process.version}`);
} else {
should.equal(properties!.framework.startsWith("Browser/"), true);
}
should.equal(properties!.platform, `(${os.arch()}-${os.type()}-${os.release()})`);
should.exist(properties!.platform);
if (customValue) {
properties!["user-agent"].should.endWith(customValue);
}
Expand Down

0 comments on commit b00069c

Please sign in to comment.