Skip to content

Commit 74efffa

Browse files
committed
fix linting errors
1 parent 686d09c commit 74efffa

File tree

1 file changed

+54
-57
lines changed

1 file changed

+54
-57
lines changed

packages/tracing/test/hub.test.ts

Lines changed: 54 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/unbound-method */
12
import { BrowserClient } from '@sentry/browser';
23
import * as hubModuleRaw from '@sentry/hub'; // for mocking
34
import { getMainCarrier, Hub } from '@sentry/hub';
@@ -15,7 +16,7 @@ import { addExtensionMethods } from '../src/hubextensions';
1516
// (This doesn't affect the utils module because it uses `export * from './myModule' syntax rather than `export
1617
// {<individually named methods>} from './myModule'` syntax in its index.ts. Only *named* exports seem to trigger the
1718
// problem.)
18-
const hubModule = { ...hubModuleRaw}
19+
const hubModule = { ...hubModuleRaw };
1920

2021
addExtensionMethods();
2122

@@ -36,29 +37,26 @@ describe('Hub', () => {
3637
});
3738

3839
describe('getTransaction()', () => {
39-
4040
it('should find a transaction which has been set on the scope', () => {
4141
const hub = new Hub(new BrowserClient({ tracesSampleRate: 1 }));
4242
const transaction = hub.startTransaction({ name: 'dogpark' });
4343
hub.configureScope(scope => {
4444
scope.setSpan(transaction);
4545
});
4646

47-
expect(hub.getScope()?.getTransaction()).toBe(transaction)
48-
47+
expect(hub.getScope()?.getTransaction()).toBe(transaction);
4948
});
5049

5150
it("should not find an open transaction if it's not on the scope", () => {
5251
const hub = new Hub(new BrowserClient({ tracesSampleRate: 1 }));
5352
hub.startTransaction({ name: 'dogpark' });
5453

55-
expect(hub.getScope()?.getTransaction()).toBeUndefined()
54+
expect(hub.getScope()?.getTransaction()).toBeUndefined();
5655
});
5756
}); // end describe('getTransaction()')
5857

5958
describe('transaction sampling', () => {
6059
describe('options', () => {
61-
6260
it("should call tracesSampler if it's defined", () => {
6361
const tracesSampler = jest.fn();
6462
const hub = new Hub(new BrowserClient({ tracesSampler }));
@@ -74,11 +72,9 @@ describe('Hub', () => {
7472

7573
expect(tracesSampler).toHaveBeenCalled();
7674
});
77-
7875
}); // end describe('options')
7976

8077
describe('default sample context', () => {
81-
8278
it('should extract request data for default sampling context when in node', () => {
8379
// make sure we look like we're in node
8480
(isNodeEnv as jest.Mock).mockReturnValue(true);
@@ -115,15 +111,17 @@ describe('Hub', () => {
115111
hub.startTransaction({ name: 'dogpark' });
116112

117113
// post-normalization request object
118-
expect(tracesSampler).toHaveBeenCalledWith(expect.objectContaining({
119-
request: {
120-
headers: { ears: 'furry', nose: 'wet', tongue: 'panting', cookie: 'favorite=zukes' },
121-
method: 'wagging',
122-
url: 'http://the.dog.park/by/the/trees/?chase=me&please=thankyou',
123-
cookies: { favorite: 'zukes' },
124-
query_string: 'chase=me&please=thankyou',
125-
},
126-
}));
114+
expect(tracesSampler).toHaveBeenCalledWith(
115+
expect.objectContaining({
116+
request: {
117+
headers: { ears: 'furry', nose: 'wet', tongue: 'panting', cookie: 'favorite=zukes' },
118+
method: 'wagging',
119+
url: 'http://the.dog.park/by/the/trees/?chase=me&please=thankyou',
120+
cookies: { favorite: 'zukes' },
121+
query_string: 'chase=me&please=thankyou',
122+
},
123+
}),
124+
);
127125
});
128126

129127
it('should extract window.location/self.location for default sampling context when in browser/service worker', () => {
@@ -153,7 +151,6 @@ describe('Hub', () => {
153151
}); // end describe('defaultSampleContext')
154152

155153
describe('while sampling', () => {
156-
157154
it('should not sample transactions when tracing is disabled', () => {
158155
// neither tracesSampleRate nor tracesSampler is defined -> tracing disabled
159156
const hub = new Hub(new BrowserClient({}));
@@ -176,51 +173,51 @@ describe('Hub', () => {
176173
expect(transaction.sampled).toBe(true);
177174
});
178175

179-
it("should reject tracesSampleRates which aren't numbers", () => {
180-
const hub = new Hub(new BrowserClient({ tracesSampleRate: 'dogs!' as any }));
181-
hub.startTransaction({ name: 'dogpark' });
176+
it("should reject tracesSampleRates which aren't numbers", () => {
177+
const hub = new Hub(new BrowserClient({ tracesSampleRate: 'dogs!' as any }));
178+
hub.startTransaction({ name: 'dogpark' });
182179

183-
expect(logger.warn).toHaveBeenCalledWith(expect.stringContaining('Sample rate must be a number'));
184-
});
180+
expect(logger.warn).toHaveBeenCalledWith(expect.stringContaining('Sample rate must be a number'));
181+
});
185182

186-
it('should reject tracesSampleRates less than 0', () => {
187-
const hub = new Hub(new BrowserClient({ tracesSampleRate: -26 }));
188-
hub.startTransaction({ name: 'dogpark' });
183+
it('should reject tracesSampleRates less than 0', () => {
184+
const hub = new Hub(new BrowserClient({ tracesSampleRate: -26 }));
185+
hub.startTransaction({ name: 'dogpark' });
189186

190-
expect(logger.warn).toHaveBeenCalledWith(expect.stringContaining('Sample rate must be between 0 and 1'));
191-
});
187+
expect(logger.warn).toHaveBeenCalledWith(expect.stringContaining('Sample rate must be between 0 and 1'));
188+
});
192189

193-
it('should reject tracesSampleRates greater than 1', () => {
194-
const hub = new Hub(new BrowserClient({ tracesSampleRate: 26 }));
195-
hub.startTransaction({ name: 'dogpark' });
190+
it('should reject tracesSampleRates greater than 1', () => {
191+
const hub = new Hub(new BrowserClient({ tracesSampleRate: 26 }));
192+
hub.startTransaction({ name: 'dogpark' });
196193

197-
expect(logger.warn).toHaveBeenCalledWith(expect.stringContaining('Sample rate must be between 0 and 1'));
198-
});
194+
expect(logger.warn).toHaveBeenCalledWith(expect.stringContaining('Sample rate must be between 0 and 1'));
195+
});
199196

200-
it("should reject tracesSampler return values which aren't numbers", () => {
201-
const tracesSampler = jest.fn().mockReturnValue("dogs!")
202-
const hub = new Hub(new BrowserClient({ tracesSampler }));
203-
hub.startTransaction({ name: 'dogpark' });
197+
it("should reject tracesSampler return values which aren't numbers", () => {
198+
const tracesSampler = jest.fn().mockReturnValue('dogs!');
199+
const hub = new Hub(new BrowserClient({ tracesSampler }));
200+
hub.startTransaction({ name: 'dogpark' });
204201

205-
expect(logger.warn).toHaveBeenCalledWith(expect.stringContaining('Sample rate must be a number'));
206-
});
202+
expect(logger.warn).toHaveBeenCalledWith(expect.stringContaining('Sample rate must be a number'));
203+
});
207204

208-
it('should reject tracesSampler return values less than 0', () => {
209-
const tracesSampler = jest.fn().mockReturnValue(-12)
210-
const hub = new Hub(new BrowserClient({ tracesSampler }));
211-
hub.startTransaction({ name: 'dogpark' });
205+
it('should reject tracesSampler return values less than 0', () => {
206+
const tracesSampler = jest.fn().mockReturnValue(-12);
207+
const hub = new Hub(new BrowserClient({ tracesSampler }));
208+
hub.startTransaction({ name: 'dogpark' });
212209

213-
expect(logger.warn).toHaveBeenCalledWith(expect.stringContaining('Sample rate must be between 0 and 1'));
214-
});
210+
expect(logger.warn).toHaveBeenCalledWith(expect.stringContaining('Sample rate must be between 0 and 1'));
211+
});
215212

216-
it('should reject tracesSampler return values greater than 1', () => {
217-
const tracesSampler = jest.fn().mockReturnValue(31)
218-
const hub = new Hub(new BrowserClient({ tracesSampler }));
219-
hub.startTransaction({ name: 'dogpark' });
213+
it('should reject tracesSampler return values greater than 1', () => {
214+
const tracesSampler = jest.fn().mockReturnValue(31);
215+
const hub = new Hub(new BrowserClient({ tracesSampler }));
216+
hub.startTransaction({ name: 'dogpark' });
220217

221-
expect(logger.warn).toHaveBeenCalledWith(expect.stringContaining('Sample rate must be between 0 and 1'));
222-
});
223-
}); // end describe('while sampling')
218+
expect(logger.warn).toHaveBeenCalledWith(expect.stringContaining('Sample rate must be between 0 and 1'));
219+
});
220+
}); // end describe('while sampling')
224221

225222
it('should propagate sampling decision to child spans', () => {
226223
const hub = new Hub(new BrowserClient({ tracesSampleRate: 0 }));
@@ -231,18 +228,18 @@ describe('Hub', () => {
231228
});
232229

233230
it('should drop transactions with sampled = false', () => {
234-
const client = new BrowserClient({ tracesSampleRate: 0 })
235-
jest.spyOn(client, 'captureEvent')
231+
const client = new BrowserClient({ tracesSampleRate: 0 });
232+
jest.spyOn(client, 'captureEvent');
236233

237234
const hub = new Hub(client);
238235
const transaction = hub.startTransaction({ name: 'dogpark' });
239236

240-
jest.spyOn(transaction, 'finish')
241-
transaction.finish()
237+
jest.spyOn(transaction, 'finish');
238+
transaction.finish();
242239

243240
expect(transaction.sampled).toBe(false);
244241
expect(transaction.finish).toReturnWith(undefined);
245-
expect(client.captureEvent).not.toBeCalled()
242+
expect(client.captureEvent).not.toBeCalled();
246243
});
247244
}); // end describe('transaction sampling')
248245
}); // end describe('Hub')

0 commit comments

Comments
 (0)