|
1 | | -import type { Attachment, Breadcrumb } from '@sentry/types'; |
| 1 | +import type { Attachment, Breadcrumb, Client } from '@sentry/types'; |
2 | 2 | import { applyScopeDataToEvent } from '../../src'; |
3 | 3 | import { Scope, getGlobalScope, setGlobalScope } from '../../src/scope'; |
4 | 4 |
|
5 | | -describe('Unit | Scope', () => { |
| 5 | +describe('Scope', () => { |
6 | 6 | beforeEach(() => { |
7 | 7 | setGlobalScope(undefined); |
8 | 8 | }); |
@@ -187,4 +187,29 @@ describe('Unit | Scope', () => { |
187 | 187 | }); |
188 | 188 | /* eslint-enable deprecation/deprecation */ |
189 | 189 | }); |
| 190 | + |
| 191 | + describe('setClient() and getClient()', () => { |
| 192 | + it('allows storing and retrieving client objects', () => { |
| 193 | + const fakeClient = {} as Client; |
| 194 | + const scope = new Scope(); |
| 195 | + scope.setClient(fakeClient); |
| 196 | + expect(scope.getClient()).toBe(fakeClient); |
| 197 | + }); |
| 198 | + |
| 199 | + it('defaults to not having a client', () => { |
| 200 | + const scope = new Scope(); |
| 201 | + expect(scope.getClient()).toBeUndefined(); |
| 202 | + }); |
| 203 | + }); |
| 204 | + |
| 205 | + describe('.clone()', () => { |
| 206 | + it('will clone a client on the scope', () => { |
| 207 | + const fakeClient = {} as Client; |
| 208 | + const scope = new Scope(); |
| 209 | + scope.setClient(fakeClient); |
| 210 | + |
| 211 | + const clonedScope = scope.clone(); |
| 212 | + expect(clonedScope.getClient()).toBe(fakeClient); |
| 213 | + }); |
| 214 | + }); |
190 | 215 | }); |
0 commit comments