Skip to content

Commit

Permalink
test(opentelemetry-plugin-xml-http-request): ignored urls
Browse files Browse the repository at this point in the history
added test for when request url is an ignored url from plugin config
  • Loading branch information
thgao committed Jun 18, 2020
1 parent 595ee85 commit 0898236
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,7 @@ describe('xhr', () => {
spyEntries.restore();
};

prepareData = (
done: any,
fileUrl: string,
propagateTraceHeaderCorsUrls?: any
) => {
prepareData = (done: any, fileUrl: string, config?: any) => {
sandbox = sinon.createSandbox();
const fakeXhr = sandbox.useFakeXMLHttpRequest();
fakeXhr.onCreate = function (xhr: any) {
Expand All @@ -179,9 +175,7 @@ describe('xhr', () => {

spyEntries = sandbox.stub(performance, 'getEntriesByType');
spyEntries.withArgs('resource').returns(resources);
xmlHttpRequestPlugin = new XMLHttpRequestPlugin(
propagateTraceHeaderCorsUrls
);
xmlHttpRequestPlugin = new XMLHttpRequestPlugin(config);
webTracerProviderWithZone = new WebTracerProvider({
logLevel: LogLevel.ERROR,
plugins: [xmlHttpRequestPlugin],
Expand Down Expand Up @@ -460,6 +454,25 @@ describe('xhr', () => {
);
});

describe('when url is ignored', () => {
beforeEach(done => {
clearData();
const propagateTraceHeaderCorsUrls = url;
prepareData(done, url, {
propagateTraceHeaderCorsUrls,
ignoreUrls: [propagateTraceHeaderCorsUrls],
});
});

it('should NOT create any span', () => {
assert.strictEqual(
exportSpy.args.length,
0,
"span shouldn't be exported"
);
});
});

describe('AND origin match with window.location', () => {
beforeEach(done => {
clearData();
Expand Down

0 comments on commit 0898236

Please sign in to comment.