Skip to content

Commit beec3af

Browse files
committed
Replace assert.ok with shorter plain assert as they are equivalent
1 parent aff3afe commit beec3af

7 files changed

Lines changed: 47 additions & 47 deletions

dotcom-rendering/src/lib/affiliateLinksUtils.node.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ void describe('buildXcustValueForAffiliateLink', () => {
7070
xcustComponentId: null,
7171
});
7272

73-
assert.ok(xcustResult.includes('|abTestParticipations|'));
74-
assert.ok(xcustResult.includes('existingTest:control'));
75-
assert.ok(xcustResult.includes('newTest:variantB'));
76-
assert.ok(xcustResult.includes('abTest1:oldVariant'));
77-
assert.ok(!xcustResult.includes('abTest1:variantA'));
73+
assert(xcustResult.includes('|abTestParticipations|'));
74+
assert(xcustResult.includes('existingTest:control'));
75+
assert(xcustResult.includes('newTest:variantB'));
76+
assert(xcustResult.includes('abTest1:oldVariant'));
77+
assert(!xcustResult.includes('abTest1:variantA'));
7878
});
7979

8080
void it('preserves existing AB participations when url already has xcust', () => {
@@ -88,11 +88,11 @@ void describe('buildXcustValueForAffiliateLink', () => {
8888
xcustComponentId: null,
8989
});
9090

91-
assert.ok(
91+
assert(
9292
xcustResult.includes('referrer|www.theguardian.com|accountId|1111'),
9393
);
94-
assert.ok(xcustResult.includes('newTest:newVariant'));
95-
assert.ok(xcustResult.includes('oldTest:oldVariant'));
94+
assert(xcustResult.includes('newTest:newVariant'));
95+
assert(xcustResult.includes('oldTest:oldVariant'));
9696
});
9797
});
9898

dotcom-rendering/src/lib/getFrontsAdPositions.node.test.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void describe('Mobile Ads', () => {
4343

4444
const mobileAdPositions = getMobileAdPositions(testCollections, 'uk');
4545

46-
assert.ok(!mobileAdPositions.includes(0));
46+
assert(!mobileAdPositions.includes(0));
4747
});
4848

4949
void it(`should not insert an ad in the merchandising-high position`, () => {
@@ -52,7 +52,7 @@ void describe('Mobile Ads', () => {
5252
{ ...testCollection, collectionType: 'news/most-popular' },
5353
] satisfies AdCandidate[];
5454
const mobileAdPositions = getMobileAdPositions(testCollections, 'uk');
55-
assert.ok(!mobileAdPositions.includes(3));
55+
assert(!mobileAdPositions.includes(3));
5656
});
5757

5858
void it('Should not insert ad before a thrasher container', () => {
@@ -68,8 +68,8 @@ void describe('Mobile Ads', () => {
6868

6969
const mobileAdPositions = getMobileAdPositions(testCollections, 'uk');
7070

71-
assert.ok(!mobileAdPositions.includes(6));
72-
assert.ok(!mobileAdPositions.includes(8));
71+
assert(!mobileAdPositions.includes(6));
72+
assert(!mobileAdPositions.includes(8));
7373
});
7474

7575
void it(`Should allow inserting an ad before a thrasher container if it's a filter page`, () => {
@@ -88,8 +88,8 @@ void describe('Mobile Ads', () => {
8888
'uk/thefilter',
8989
);
9090

91-
assert.ok(mobileAdPositions.includes(6));
92-
assert.ok(mobileAdPositions.includes(8));
91+
assert(mobileAdPositions.includes(6));
92+
assert(mobileAdPositions.includes(8));
9393
});
9494

9595
// We used https://www.theguardian.com/uk/commentisfree as a blueprint
@@ -429,8 +429,8 @@ void describe('inserting an ad after the first collection', () => {
429429
'uk',
430430
);
431431

432-
assert.ok(adPositions.includes(0));
433-
assert.ok(!adPositions.includes(1));
432+
assert(adPositions.includes(0));
433+
assert(!adPositions.includes(1));
434434
});
435435

436436
void it('inserts an ad after the first collection if it is a LARGE flexible special container', () => {
@@ -451,8 +451,8 @@ void describe('inserting an ad after the first collection', () => {
451451
'uk',
452452
);
453453

454-
assert.ok(adPositions.includes(0));
455-
assert.ok(!adPositions.includes(1));
454+
assert(adPositions.includes(0));
455+
assert(!adPositions.includes(1));
456456
});
457457

458458
void it('does NOT insert an ad after the first collection if it is a SMALL flexible general container', () => {
@@ -468,7 +468,7 @@ void describe('inserting an ad after the first collection', () => {
468468
'uk',
469469
);
470470

471-
assert.ok(!adPositions.includes(0));
471+
assert(!adPositions.includes(0));
472472
});
473473

474474
void it('does NOT insert an ad after the first collection if it is a SMALL flexible special container', () => {
@@ -484,7 +484,7 @@ void describe('inserting an ad after the first collection', () => {
484484
'uk',
485485
);
486486

487-
assert.ok(!adPositions.includes(0));
487+
assert(!adPositions.includes(0));
488488
});
489489
});
490490

@@ -507,8 +507,8 @@ void describe('inserting an ad after the first collection', () => {
507507
'uk',
508508
);
509509

510-
assert.ok(adPositions.includes(1));
511-
assert.ok(!adPositions.includes(2));
510+
assert(adPositions.includes(1));
511+
assert(!adPositions.includes(2));
512512
});
513513

514514
void it('inserts an ad before the second collection if it is preceded by a LARGE flexible special container', () => {
@@ -529,8 +529,8 @@ void describe('inserting an ad after the first collection', () => {
529529
'uk',
530530
);
531531

532-
assert.ok(adPositions.includes(1));
533-
assert.ok(!adPositions.includes(2));
532+
assert(adPositions.includes(1));
533+
assert(!adPositions.includes(2));
534534
});
535535

536536
void it('does NOT insert an ad before the second collection if it is preceded by a SMALL flexible general container', () => {
@@ -551,7 +551,7 @@ void describe('inserting an ad after the first collection', () => {
551551
'uk',
552552
);
553553

554-
assert.ok(!adPositions.includes(1));
554+
assert(!adPositions.includes(1));
555555
});
556556

557557
void it('does NOT insert an ad before the second collection if it is preceded by a SMALL flexible special container', () => {
@@ -572,7 +572,7 @@ void describe('inserting an ad after the first collection', () => {
572572
'uk',
573573
);
574574

575-
assert.ok(!adPositions.includes(1));
575+
assert(!adPositions.includes(1));
576576
});
577577
});
578578
});

dotcom-rendering/src/lib/getZIndex.node.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ import { getZIndex } from './getZIndex';
44

55
void describe('getZIndex', () => {
66
void it('gets the correct zindex for group and sibling', () => {
7-
assert.ok(getZIndex('sticky-video-button') > getZIndex('sticky-video'));
8-
assert.ok(
7+
assert(getZIndex('sticky-video-button') > getZIndex('sticky-video'));
8+
assert(
99
getZIndex('expanded-veggie-menu-wrapper') >
1010
getZIndex('expanded-veggie-menu'),
1111
);
12-
assert.ok(
12+
assert(
1313
getZIndex('stickyAdWrapperLabsHeader') >
1414
getZIndex('stickyAdWrapper'),
1515
);
16-
assert.ok(getZIndex('tableOfContents') > getZIndex('articleHeadline'));
17-
assert.ok(getZIndex('subNavBanner') > getZIndex('articleHeadline'));
18-
assert.ok(getZIndex('subNavBanner') > getZIndex('bodyArea'));
19-
assert.ok(getZIndex('card-nested-link') > getZIndex('card-link'));
16+
assert(getZIndex('tableOfContents') > getZIndex('articleHeadline'));
17+
assert(getZIndex('subNavBanner') > getZIndex('articleHeadline'));
18+
assert(getZIndex('subNavBanner') > getZIndex('bodyArea'));
19+
assert(getZIndex('card-nested-link') > getZIndex('card-link'));
2020
});
2121
});

dotcom-rendering/src/lib/liveblogAdSlots.node.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ void describe('shouldDisplayAd', () => {
157157
isMobile,
158158
);
159159

160-
assert.ok(!result);
160+
assert(!result);
161161
});
162162
}
163163
});
@@ -179,7 +179,7 @@ void describe('shouldDisplayAd', () => {
179179
isMobile,
180180
);
181181

182-
assert.ok(!result);
182+
assert(!result);
183183
});
184184
}
185185
});
@@ -201,7 +201,7 @@ void describe('shouldDisplayAd', () => {
201201
isMobile,
202202
);
203203

204-
assert.ok(result);
204+
assert(result);
205205
});
206206
}
207207
});
@@ -226,7 +226,7 @@ void describe('shouldDisplayAd', () => {
226226
isMobile,
227227
);
228228

229-
assert.ok(result);
229+
assert(result);
230230
});
231231
}
232232

@@ -249,7 +249,7 @@ void describe('shouldDisplayAd', () => {
249249
isMobile,
250250
);
251251

252-
assert.ok(!result);
252+
assert(!result);
253253
});
254254
}
255255
});

dotcom-rendering/src/model/enhance-ad-placeholders.node.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ void describe('enhanceAdPlaceholders', () => {
311311
)(input);
312312
const outputPlaceholders = output.filter(elementIsAdPlaceholder);
313313

314-
assert.ok(outputPlaceholders.length > 0);
314+
assert(outputPlaceholders.length > 0);
315315
});
316316
});
317317
});

dotcom-rendering/src/model/enhanceCommercialProperties.node.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ void describe('Enhance Branding', () => {
4646
.map((p) => p.branding?.logo.dimensions.width)
4747
.filter(isNumber);
4848

49-
assert.ok(Math.max(...dimensionsFail) > 140);
49+
assert(Math.max(...dimensionsFail) > 140);
5050

5151
const dimensionsPass = Object.values(
5252
enhanceCommercialProperties(commercialProperties),
5353
)
5454
.map((p) => p.branding?.logo.dimensions.width)
5555
.filter(isNumber);
5656

57-
assert.ok(Math.max(...dimensionsPass) <= 140);
57+
assert(Math.max(...dimensionsPass) <= 140);
5858
});
5959
});

dotcom-rendering/src/model/unwrapHtml.node.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ void describe('unwrapHtml', () => {
3434
unwrapHtml(pUnwrap);
3535

3636
// Testy test
37-
assert.ok(bqIsUnwrapped);
37+
assert(bqIsUnwrapped);
3838
assert.equal(bqUnwrappedHtml, '<p>inner</p>');
39-
assert.ok(pIsUnwrapped);
39+
assert(pIsUnwrapped);
4040
assert.equal(pUnwrappedHtml, 'inner');
4141
});
4242

@@ -52,7 +52,7 @@ void describe('unwrapHtml', () => {
5252
};
5353
const { willUnwrap: isUnwrapped, unwrappedHtml } = unwrapHtml(bqUnwrap);
5454

55-
assert.ok(!isUnwrapped);
55+
assert(!isUnwrapped);
5656
assert.equal(unwrappedHtml, bqUnwrap.html);
5757
});
5858

@@ -123,15 +123,15 @@ void describe('unwrapHtml', () => {
123123
unwrappedElement: ulUnwrappedElement,
124124
} = unwrapHtml(ulUnwrap);
125125

126-
assert.ok(bqIsUnwrapped);
126+
assert(bqIsUnwrapped);
127127
assert.equal(bqUnwrappedHtml, '<p>inner</p>');
128128
assert.equal(bqUnwrappedElement, 'blockquote');
129129

130-
assert.ok(pIsUnwrapped);
130+
assert(pIsUnwrapped);
131131
assert.equal(pUnwrappedHtml, 'inner');
132132
assert.equal(pUnwrappedElement, 'p');
133133

134-
assert.ok(ulIsUnwrapped);
134+
assert(ulIsUnwrapped);
135135
assert.equal(ulUnwrappedHtml, '<li>Test</li><li>test2</li>');
136136
assert.equal(ulUnwrappedElement, 'ul');
137137
});

0 commit comments

Comments
 (0)