Skip to content

Commit 85f39ce

Browse files
prefer-optional-chain & await-thenable issues fix (#1450)
1 parent cbb1d19 commit 85f39ce

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

eslint-suppressions.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,6 @@
5858
"count": 5
5959
}
6060
},
61-
"src/server/tests/banners/bannerSelection.test.ts": {
62-
"@typescript-eslint/prefer-optional-chain": {
63-
"count": 8
64-
},
65-
"@typescript-eslint/await-thenable": {
66-
"count": 4
67-
}
68-
},
6961
"src/server/tests/banners/bannerSelection.ts": {
7062
"@typescript-eslint/no-unnecessary-condition": {
7163
"count": 3

src/server/tests/banners/bannerSelection.test.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ describe('selectBannerTest', () => {
110110
undefined,
111111
now,
112112
);
113-
expect(result && result.test.name).toBe('test');
113+
expect(result?.test.name).toBe('test');
114114
});
115115

116116
it('returns test if regionTargeting (country code) matches country code from payload (targeting)', () => {
@@ -134,7 +134,7 @@ describe('selectBannerTest', () => {
134134
undefined,
135135
now,
136136
);
137-
expect(result && result.test.name).toBe('test');
137+
expect(result?.test.name).toBe('test');
138138
});
139139

140140
it('returns test if regionTargeting (country group) matches country code from payload (targeting)', () => {
@@ -158,7 +158,7 @@ describe('selectBannerTest', () => {
158158
undefined,
159159
now,
160160
);
161-
expect(result && result.test.name).toBe('test');
161+
expect(result?.test.name).toBe('test');
162162
});
163163

164164
it('returns null if regionTargeting does not match country code from payload (targeting)', () => {
@@ -200,7 +200,7 @@ describe('selectBannerTest', () => {
200200
undefined,
201201
now,
202202
);
203-
expect(result && result.test.name).toBe(null);
203+
expect(result?.test.name).toBeUndefined();
204204
});
205205

206206
it('returns null if not enough article views', () => {
@@ -241,7 +241,7 @@ describe('selectBannerTest', () => {
241241
undefined,
242242
now,
243243
);
244-
expect(result && result.test.name).toBe('test');
244+
expect(result?.test.name).toBe('test');
245245
});
246246

247247
it('returns null if opted out', () => {
@@ -359,7 +359,7 @@ describe('selectBannerTest', () => {
359359
undefined,
360360
now,
361361
);
362-
expect(result && result.test.name).toBe('test');
362+
expect(result?.test.name).toBe('test');
363363
});
364364

365365
it('returns null if not enough article views', () => {
@@ -400,7 +400,7 @@ describe('selectBannerTest', () => {
400400
undefined,
401401
now,
402402
);
403-
expect(result && result.test.name).toBe('test');
403+
expect(result?.test.name).toBe('test');
404404
});
405405
});
406406

@@ -480,26 +480,26 @@ describe('selectBannerTest', () => {
480480
);
481481
};
482482

483-
it('It should return a test matching a contribution from a new user', async () => {
484-
const result = await runSelection({
483+
it('It should return a test matching a contribution from a new user', () => {
484+
const result = runSelection({
485485
...baseTargeting,
486486
purchaseInfo: { product: 'Contribution', userType: 'new' },
487487
});
488488

489489
expect(result?.test.name).toEqual('banner-new-contribution');
490490
});
491491

492-
it('It should return a test matching a subscription from an existing user', async () => {
493-
const result = await runSelection({
492+
it('It should return a test matching a subscription from an existing user', () => {
493+
const result = runSelection({
494494
...baseTargeting,
495495
purchaseInfo: { product: 'SupporterPlus', userType: 'current' },
496496
});
497497

498498
expect(result?.test.name).toEqual('banner-existing-subscriber');
499499
});
500500

501-
it('It should ignore purchase information if user is signed in', async () => {
502-
const result = await runSelection({
501+
it('It should ignore purchase information if user is signed in', () => {
502+
const result = runSelection({
503503
...baseTargeting,
504504
purchaseInfo: { product: 'Contribution', userType: 'new' },
505505
isSignedIn: true,
@@ -508,8 +508,8 @@ describe('selectBannerTest', () => {
508508
expect(result).toBeNull();
509509
});
510510

511-
it('It should ignore purchase information if sign in banner has previously been closed', async () => {
512-
const result = await runSelection({
511+
it('It should ignore purchase information if sign in banner has previously been closed', () => {
512+
const result = runSelection({
513513
...baseTargeting,
514514
purchaseInfo: { product: 'Contribution', userType: 'new' },
515515
signInBannerLastClosedAt: new Date().toISOString(),
@@ -596,7 +596,7 @@ describe('selectBannerTest', () => {
596596
undefined,
597597
now,
598598
);
599-
expect(result && result.test.name).toBe('abandonedBasket');
599+
expect(result?.test.name).toBe('abandonedBasket');
600600
});
601601

602602
it('returns null when abandoned basket property present and recently closed', () => {

0 commit comments

Comments
 (0)