Skip to content

Commit 98dea38

Browse files
committed
move NoopTransport test to Core Client tests
1 parent b182d20 commit 98dea38

File tree

7 files changed

+27
-14
lines changed

7 files changed

+27
-14
lines changed

packages/browser/src/client.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { FetchTransport, makeNewFetchTransport, makeNewXHRTransport, XHRTranspor
1414
*
1515
* @see BrowserOptions for documentation on configuration options.
1616
* @see SentryClient for usage documentation.
17-
* TODO: remove BrowserBackend
17+
* TODO(v7): remove BrowserBackend
1818
*/
1919
export class BrowserClient extends BaseClient<BrowserBackend, BrowserOptions> {
2020
/**
@@ -35,7 +35,7 @@ export class BrowserClient extends BaseClient<BrowserBackend, BrowserOptions> {
3535
version: SDK_VERSION,
3636
};
3737

38-
// TODO: remove BrowserBackend param
38+
// TODO(v7): remove BrowserBackend param
3939
super(BrowserBackend, options);
4040
}
4141

packages/browser/test/unit/backend.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { BrowserBackend } from '../../src/backend';
22

33
let backend: BrowserBackend;
44

5+
// TODO(v7): remove when deleting Backend
6+
57
describe('BrowserBackend', () => {
68
describe('sendEvent()', () => {
79
it('should use NoopTransport', () => {

packages/core/src/baseclient.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const ALREADY_SEEN_ERROR = "Not capturing exception because it's already been ca
4141
/**
4242
* Base implementation for all JavaScript SDK clients.
4343
*
44-
* TODO: refactor doc w.r.t. Backend
44+
* TODO(v7): refactor doc w.r.t. Backend
4545
*
4646
* Call the constructor with the corresponding backend constructor and options
4747
* specific to the client subclass. To access these options later, use
@@ -77,7 +77,7 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
7777
* The backend used to physically interact in the environment. Usually, this
7878
* will correspond to the client. When composing SDKs, however, the Backend
7979
* from the root SDK will be used.
80-
* TODO: DELETE
80+
* TODO(v7): DELETE
8181
*/
8282
protected readonly _backend: B;
8383

@@ -106,7 +106,7 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
106106
* @param options Options for the client.
107107
*/
108108
protected constructor(backendClass: BackendClass<B, O>, options: O) {
109-
// TODO: Delete
109+
// TODO(v7): Delete
110110
this._backend = new backendClass(options);
111111
this._options = options;
112112

@@ -149,7 +149,6 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
149149
public captureMessage(message: string, level?: Severity, hint?: EventHint, scope?: Scope): string | undefined {
150150
let eventId: string | undefined = hint && hint.event_id;
151151

152-
// TODO: refactor
153152
const promisedEvent = isPrimitive(message)
154153
? this.eventFromMessage(String(message), level, hint)
155154
: this.eventFromException(message, hint);
@@ -367,6 +366,7 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
367366
}
368367

369368
/** Deliver captured session to Sentry */
369+
// TODO(v7): should this be deleted?
370370
protected _sendSession(session: Session): void {
371371
this.sendSession(session);
372372
}
@@ -402,7 +402,7 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
402402
}
403403

404404
/** Returns the current backend.
405-
* TODO: DELETE
405+
* TODO(v7): DELETE
406406
*/
407407
protected _getBackend(): B {
408408
return this._backend;
@@ -576,7 +576,7 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
576576
* Tells the backend to send this event
577577
* @param event The Sentry event to send
578578
*/
579-
// TODO: refactor: get rid of method?
579+
// TODO(v7): refactor: get rid of method?
580580
protected _sendEvent(event: Event): void {
581581
this.sendEvent(event);
582582
}

packages/core/test/lib/base.test.ts

+11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Event, Span, Transport } from '@sentry/types';
33
import { dsnToString, logger, SentryError, SyncPromise } from '@sentry/utils';
44

55
import * as integrationModule from '../../src/integration';
6+
import { NoopTransport } from '../../src/transports/noop';
67
import { TestBackend } from '../mocks/backend';
78
import { TestClient } from '../mocks/client';
89
import { TestIntegration } from '../mocks/integration';
@@ -107,6 +108,16 @@ describe('BaseClient', () => {
107108
expect(client.getTransport()).toBeInstanceOf(FakeTransport);
108109
expect(TestClient.instance!.getTransport()).toBe(client.getTransport());
109110
});
111+
112+
test('retruns NoopTransport when no transport is passed', () => {
113+
expect.assertions(2);
114+
115+
const options = { dsn: PUBLIC_DSN };
116+
const client = new TestClient(options);
117+
118+
expect(client.getTransport()).toBeInstanceOf(NoopTransport);
119+
expect(TestClient.instance!.getTransport()).toBe(client.getTransport());
120+
});
110121
});
111122

112123
describe('getBreadcrumbs() / addBreadcrumb()', () => {

packages/core/test/mocks/client.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface TestOptions extends Options {
1010
enableSend?: boolean;
1111
}
1212

13-
// TODO: remove TestBackend
13+
// TODO(v7): remove TestBackend
1414
export class TestClient extends BaseClient<TestBackend, TestOptions> {
1515
public static instance?: TestClient;
1616
public static sendEventCalled?: (event: Event) => void;
@@ -19,7 +19,7 @@ export class TestClient extends BaseClient<TestBackend, TestOptions> {
1919
public session?: Session;
2020

2121
public constructor(options: TestOptions) {
22-
// TODO: remove TestBackend param
22+
// TODO(v7): remove TestBackend param
2323
super(TestBackend, options);
2424
TestClient.instance = this;
2525
}

packages/ember/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"ember-qunit": "~4.6.0",
6565
"ember-resolver": "~8.0.0",
6666
"ember-sinon-qunit": "~5.0.0",
67-
"ember-source": "~3.20.0",
67+
"ember-source": "https://s3.amazonaws.com/builds.emberjs.com/release/shas/e75bc645f3d3472e69515cd12e38e5f7f0fce5e9.tgz",
6868
"ember-source-channel-url": "~2.0.1",
6969
"ember-template-lint": "~2.9.1",
7070
"ember-test-selectors": "~5.5.0",
@@ -89,4 +89,4 @@
8989
"node": "14.15.4",
9090
"yarn": "1.22.5"
9191
}
92-
}
92+
}

packages/node/src/client.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { NodeOptions } from './types';
1515
* @see NodeOptions for documentation on configuration options.
1616
* @see SentryClient for usage documentation.
1717
*
18-
* TODO: remove NodeBackend
18+
* TODO(v7): remove NodeBackend
1919
*/
2020
export class NodeClient extends BaseClient<NodeBackend, NodeOptions> {
2121
protected _sessionFlusher: SessionFlusher | undefined;
@@ -37,7 +37,7 @@ export class NodeClient extends BaseClient<NodeBackend, NodeOptions> {
3737
version: SDK_VERSION,
3838
};
3939

40-
// TODO: remove NodeBackend param
40+
// TODO(v7): remove NodeBackend param
4141
super(NodeBackend, options);
4242
}
4343

0 commit comments

Comments
 (0)