Skip to content

Commit 740fc09

Browse files
committed
add codecov tests, use assert/strict
1 parent 5c3787c commit 740fc09

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+207
-222
lines changed

.github/workflows/lint-and-tests.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,14 @@ jobs:
132132
# that changes to dependencies or translations don't break the Unit Tests
133133
run: npm run test:ci
134134

135-
- name: Upload
136-
if: success() || failure()
135+
- name: Upload test coverage to Codecov
136+
if: ${{ !cancelled() }}
137137
uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5.4.0
138138
with:
139139
files: ./apps/site/lcov.info,./packages/ui-components/lcov.info
140+
141+
- name: Upload test results to Codecov
142+
if: ${{ !cancelled() }}
143+
uses: codecov/test-results-action@f2dba722c67b86c6caa034178c6e4d35335f6706 # v1.1.0
144+
with:
145+
files: ./apps/site/junit.xml,./packages/ui-components/junit.xml
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it } from 'node:test';
2-
import assert from 'node:assert';
2+
import assert from 'node:assert/strict';
33

44
import { render, screen } from '@testing-library/react';
55

@@ -9,24 +9,24 @@ describe('BlogHeader', () => {
99
it('should have correct href when category is all', () => {
1010
render(<BlogHeader category="all" />);
1111
const link = screen.getByRole('link');
12-
assert.strictEqual(link.getAttribute('href'), '/feed/blog.xml');
12+
assert.equal(link.getAttribute('href'), '/feed/blog.xml');
1313
});
1414

1515
it('should have correct href when category is release', () => {
1616
render(<BlogHeader category="release" />);
1717
const link = screen.getByRole('link');
18-
assert.strictEqual(link.getAttribute('href'), '/feed/releases.xml');
18+
assert.equal(link.getAttribute('href'), '/feed/releases.xml');
1919
});
2020

2121
it('should have correct href when category is vulnerability', () => {
2222
render(<BlogHeader category="vulnerability" />);
2323
const link = screen.getByRole('link');
24-
assert.strictEqual(link.getAttribute('href'), '/feed/vulnerability.xml');
24+
assert.equal(link.getAttribute('href'), '/feed/vulnerability.xml');
2525
});
2626

2727
it('should have correct href when category is random', () => {
2828
render(<BlogHeader category="random" />);
2929
const link = screen.getByRole('link');
30-
assert.strictEqual(link.getAttribute('href'), '/feed/blog.xml');
30+
assert.equal(link.getAttribute('href'), '/feed/blog.xml');
3131
});
3232
});

apps/site/components/Blog/BlogPostCard/__tests__/index.test.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { render, screen } from '@testing-library/react';
22
import { describe, it } from 'node:test';
3-
import assert from 'node:assert';
3+
import assert from 'node:assert/strict';
44
import { isVisible } from '../../../../../../tests/utilities.mjs';
55

66
import BlogPostCard from '@/components/Blog/BlogPostCard';
@@ -38,11 +38,11 @@ describe('BlogPostCard', () => {
3838
it('Renders the title prop correctly', () => {
3939
const { title } = renderBlogPostCard({});
4040

41-
assert.strictEqual(screen.getAllByText(title).length, 2);
41+
assert.equal(screen.getAllByText(title).length, 2);
4242

4343
// title from preview should be ignored as the one from Links
4444
// and blog card/post are what matter
45-
assert.strictEqual(
45+
assert.equal(
4646
screen.getAllByText(title)[0].getAttribute('aria-hidden'),
4747
'true'
4848
);

apps/site/hooks/react-client/__tests__/useClientContext.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import useClientContext from '@/hooks/react-client/useClientContext';
44
import { MatterContext } from '@/providers/matterProvider';
55

66
import { describe, it } from 'node:test';
7-
import assert from 'node:assert';
7+
import assert from 'node:assert/strict';
88

99
describe('useClientContext', () => {
1010
it('should return client context values', () => {

apps/site/hooks/react-client/__tests__/useCopyToClipboard.test.jsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { render, fireEvent, screen } from '@testing-library/react';
22
import { describe, it } from 'node:test';
3-
import assert from 'node:assert';
3+
import assert from 'node:assert/strict';
44
import { setTimeout } from 'node:timers/promises';
55

66
import useCopyToClipboard from '@/hooks/react-client/useCopyToClipboard';
@@ -34,10 +34,9 @@ await describe('useCopyToClipboard', async () => {
3434

3535
assert.ok((await screen.findByText(/copy/i)).ownerDocument);
3636

37-
assert(navigator.clipboard.writeText.mock.callCount(), 1);
38-
assert.deepStrictEqual(
39-
navigator.clipboard.writeText.mock.calls[0].arguments,
40-
['test']
41-
);
37+
assert.ok(navigator.clipboard.writeText.mock.callCount(), 1);
38+
assert.deepEqual(navigator.clipboard.writeText.mock.calls[0].arguments, [
39+
'test',
40+
]);
4241
});
4342
});

apps/site/hooks/react-client/__tests__/useDetectOS.test.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import assert from 'node:assert';
1+
import assert from 'node:assert/strict';
22
import { describe, it, afterEach } from 'node:test';
33

44
import { renderHook, waitFor } from '@testing-library/react';
@@ -35,7 +35,7 @@ describe('useDetectOS', () => {
3535
const { result } = renderHook(() => useDetectOS());
3636

3737
await waitFor(() => {
38-
assert.deepStrictEqual(result.current, {
38+
assert.deepEqual(result.current, {
3939
os: 'WIN',
4040
bitness: '64',
4141
architecture: 'x86',
@@ -52,7 +52,7 @@ describe('useDetectOS', () => {
5252
const { result } = renderHook(() => useDetectOS());
5353

5454
await waitFor(() => {
55-
assert.deepStrictEqual(result.current, {
55+
assert.deepEqual(result.current, {
5656
os: 'WIN',
5757
bitness: '64',
5858
architecture: 'x86',
@@ -69,7 +69,7 @@ describe('useDetectOS', () => {
6969
const { result } = renderHook(() => useDetectOS());
7070

7171
await waitFor(() => {
72-
assert.deepStrictEqual(result.current, {
72+
assert.deepEqual(result.current, {
7373
os: 'MAC',
7474
bitness: '32',
7575
architecture: 'x86',

apps/site/hooks/react-client/__tests__/useMediaQuery.test.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import assert from 'node:assert';
1+
import assert from 'node:assert/strict';
22
import { describe, it } from 'node:test';
33

44
import { renderHook } from '@testing-library/react';
@@ -10,7 +10,7 @@ const noop = () => {};
1010
describe('useMediaQuery', () => {
1111
it('should return undefined initially', () => {
1212
const { result } = renderHook(() => useMediaQuery('media-query-mock'));
13-
assert.strictEqual(result.current, false);
13+
assert.equal(result.current, false);
1414
});
1515

1616
it('should return true for matched query', () => {
@@ -25,7 +25,7 @@ describe('useMediaQuery', () => {
2525
});
2626

2727
const { result } = renderHook(() => useMediaQuery('media-query-mock'));
28-
assert.strictEqual(result.current, true);
28+
assert.equal(result.current, true);
2929
});
3030

3131
it('should return false for not-matched query', () => {
@@ -40,7 +40,7 @@ describe('useMediaQuery', () => {
4040
});
4141

4242
const { result } = renderHook(() => useMediaQuery('media-query-mock'));
43-
assert.strictEqual(result.current, false);
43+
assert.equal(result.current, false);
4444
});
4545

4646
it('should subscribe for media changes', t => {
@@ -59,6 +59,6 @@ describe('useMediaQuery', () => {
5959
});
6060

6161
renderHook(() => useMediaQuery('media-query-mock'));
62-
assert.strictEqual(listenerMock.mock.callCount(), 1);
62+
assert.equal(listenerMock.mock.callCount(), 1);
6363
});
6464
});

apps/site/hooks/react-client/__tests__/useNotification.test.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { render } from '@testing-library/react';
33
import useNotification from '@/hooks/react-client/useNotification';
44
import { NotificationProvider } from '@/providers/notificationProvider';
55
import { describe, it } from 'node:test';
6-
import assert from 'node:assert';
6+
import assert from 'node:assert/strict';
77

88
describe('useNotification', () => {
99
it('should return the notification dispatch function', () => {
@@ -48,6 +48,6 @@ describe('useNotification', () => {
4848
return element.textContent === 'Dispatch unavailable';
4949
});
5050

51-
assert.strictEqual(result, null);
51+
assert.equal(result, null);
5252
});
5353
});

apps/site/next-data/generators/__tests__/releaseData.test.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import assert from 'node:assert';
1+
import assert from 'node:assert/strict';
22
import { describe, it } from 'node:test';
33

44
describe('generateReleaseData', () => {
@@ -37,7 +37,7 @@ describe('generateReleaseData', () => {
3737

3838
const result = await generateReleaseData();
3939

40-
assert.strictEqual(result.length, 1);
40+
assert.equal(result.length, 1);
4141
assert.partialDeepStrictEqual(result[0], {
4242
major: 14,
4343
version: '14.0.0',

apps/site/next-data/generators/__tests__/websiteFeeds.test.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import assert from 'node:assert';
1+
import assert from 'node:assert/strict';
22
import { describe, it } from 'node:test';
33

44
import generateWebsiteFeeds from '@/next-data/generators/websiteFeeds.mjs';
@@ -23,18 +23,18 @@ describe('generateWebsiteFeeds', () => {
2323
};
2424

2525
const result = generateWebsiteFeeds(blogData);
26-
assert.strictEqual(result.size, 3);
26+
assert.equal(result.size, 3);
2727

2828
const blogFeed = result.get('blog.xml');
29-
assert.deepStrictEqual(blogFeed.options, {
29+
assert.deepEqual(blogFeed.options, {
3030
id: siteConfig.rssFeeds[0].file,
3131
title: siteConfig.rssFeeds[0].title,
3232
language: 'en',
3333
link: `${base}/feed/${siteConfig.rssFeeds[0].file}`,
3434
description: siteConfig.rssFeeds[0].description,
3535
});
3636

37-
assert.deepStrictEqual(blogFeed.items, [
37+
assert.deepEqual(blogFeed.items, [
3838
{
3939
author: blogData.posts[0].author,
4040
id: blogData.posts[0].slug,

0 commit comments

Comments
 (0)