Skip to content

Commit 138f19f

Browse files
committed
Add missing repotools tests
1 parent b43125c commit 138f19f

File tree

14 files changed

+464
-62
lines changed

14 files changed

+464
-62
lines changed

eslint.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ export default tseslint.config(
8787
'always',
8888
{ markers: todoTreeKeywordsAll }
8989
],
90-
9190
}
9291
},
9392
{
@@ -424,9 +423,11 @@ export default tseslint.config(
424423
'vitest/no-conditional-expect': 'off',
425424
'vitest/no-export': 'off',
426425
'vitest/no-focused-tests': ['warn', { fixable: false }],
426+
'vitest/prefer-describe-function-title': 'warn',
427427
'vitest/require-top-level-describe': 'off',
428428
'vitest/valid-describe-callback': 'off',
429429
'vitest/valid-expect-in-promise': 'error',
430+
'vitest/valid-title': ['error', { ignoreTypeOfDescribeName: true }],
430431

431432
'import/extensions': ['error', 'never', {
432433
config: 'ignore'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"name": "test0"
2+
"name": "@sourceacademy/bundle-test0"
33
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"name": "test1"
2+
"name": "@sourceacademy/bundle-test1"
33
}

lib/buildtools/src/build/docs/__tests__/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const mockBundle: ResolvedBundle = {
1818
manifest: {}
1919
};
2020

21-
describe('Test buildSingleBundleDocs', () => {
21+
describe(buildSingleBundleDocs, () => {
2222
const mockedJsonInit = vi.spyOn(init, 'initTypedocForJson');
2323
test('Project conversion failure', async () => {
2424
const mockGenerateJson = vi.fn(() => Promise.resolve());
@@ -63,7 +63,7 @@ describe('Test buildSingleBundleDocs', () => {
6363
});
6464
});
6565

66-
describe('Test buildHtml', () => {
66+
describe(buildHtml, () => {
6767
const mockedHtmlInit = vi.spyOn(init, 'initTypedocForHtml');
6868
const mockedFsStat = vi.spyOn(fs, 'stat');
6969

lib/buildtools/src/build/docs/__tests__/json.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ vi.setConfig({
1212
testTimeout: 10000
1313
});
1414

15-
describe('Test buildJson', () => {
15+
describe(buildJson, () => {
1616
interface Fixtures {
1717
testBundle: ResolvedBundle;
1818
project: td.ProjectReflection;

lib/buildtools/src/commands/__tests__/commandUtils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Severity } from '@sourceacademy/modules-repotools/types';
22
import { describe, expect, test } from 'vitest';
33
import { processResult } from '../commandUtils.js';
44

5-
describe('Testing processResults', () => {
5+
describe(processResult, () => {
66
const testCases: [any, Severity][] = [
77
[{ severity: 'success' }, 'success'],
88
[{ severity: 'error' }, 'error'],

lib/buildtools/src/commands/__tests__/list.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { testMocksDir } from '../../__tests__/fixtures.js';
66
import { getListBundlesCommand, getListTabsCommand } from '../list.js';
77
import { getCommandRunner } from './testingUtils.js';
88

9-
vi.spyOn(console, 'log');
10-
vi.spyOn(console, 'error');
9+
const mockedConsoleLog = vi.spyOn(console, 'log');
10+
const mockedConsoleError = vi.spyOn(console, 'error');
1111

1212
describe('Test list command with bundles', () => {
1313
const mockedResolveSingleBundle = vi.spyOn(manifest, 'resolveSingleBundle');
@@ -18,7 +18,7 @@ describe('Test list command with bundles', () => {
1818
test('Running command with no arguments', async ({ expect }) => {
1919
await expect(runCommand()).commandSuccess();
2020
expect(console.log).toHaveBeenCalledTimes(1);
21-
const [[data]] = vi.mocked(console.log).mock.calls;
21+
const [[data]] = mockedConsoleLog.mock.calls;
2222
expect(data).toMatch(/^Detected 2 bundles in .+:\n1. test0\n2. test1$/);
2323
});
2424

@@ -30,7 +30,7 @@ describe('Test list command with bundles', () => {
3030
await expect(runCommand()).commandExit();
3131

3232
expect(console.error).toHaveBeenCalledTimes(1);
33-
const [[data]] = vi.mocked(console.error).mock.calls;
33+
const [[data]] = mockedConsoleError.mock.calls;
3434
expect(data).toMatch(/^No bundles in .+$/);
3535
});
3636

@@ -43,7 +43,7 @@ describe('Test list command with bundles', () => {
4343
await expect(runCommand(`${testMocksDir}/bundles/test0`)).commandSuccess();
4444

4545
expect(console.log).toHaveBeenCalledTimes(1);
46-
const [[data]] = vi.mocked(console.log).mock.calls;
46+
const [[data]] = mockedConsoleLog.mock.calls;
4747
const sanitized = (data as string).split('\n').join('');
4848

4949
const match = /^.+:(\{.+\})$/gm.exec(sanitized);
@@ -94,7 +94,7 @@ describe('Test list command with tabs', () => {
9494
await expect(runCommand()).commandSuccess();
9595

9696
expect(console.log).toHaveBeenCalledTimes(1);
97-
const [[data]] = vi.mocked(console.log).mock.calls;
97+
const [[data]] = mockedConsoleLog.mock.calls;
9898
expect(data).toMatch(/^Detected 2 tabs in .+:\n1. tab0\n2. tab1$/);
9999
});
100100

@@ -106,7 +106,7 @@ describe('Test list command with tabs', () => {
106106
await expect(runCommand()).commandExit();
107107

108108
expect(console.error).toHaveBeenCalledTimes(1);
109-
const [[data]] = vi.mocked(console.error).mock.calls;
109+
const [[data]] = mockedConsoleError.mock.calls;
110110
expect(data).toMatch(/^No tabs in .+$/);
111111
});
112112

@@ -119,7 +119,7 @@ describe('Test list command with tabs', () => {
119119
await expect(runCommand(`${testMocksDir}/tabs/tab0`)).commandSuccess();
120120

121121
expect(console.log).toHaveBeenCalledTimes(1);
122-
const [[data]] = vi.mocked(console.log).mock.calls;
122+
const [[data]] = mockedConsoleLog.mock.calls;
123123
expect(data).toMatch(/^Tab 'tab0' found in .+$/);
124124
});
125125
});
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { resolve } from 'path';
1+
import { join, resolve } from 'path';
22

3-
const testMocksDir = resolve(import.meta.dirname, '../../__test_mocks__');
3+
const testMocksDir = resolve(import.meta.dirname, '../../../__test_mocks__');
44

5-
export const getBundlesDir = () => Promise.resolve(`${testMocksDir}/bundles`);
6-
export const getTabsDir = () => Promise.resolve(`${testMocksDir}/tabs`);
7-
export const getOutDir = () => Promise.resolve('/build');
5+
export const bundlesDir = join(testMocksDir, 'bundles');
6+
export const tabsDir = join(testMocksDir, 'tabs');
7+
export const outDir = '/build';
88
export const getGitRoot = () => Promise.resolve(testMocksDir);

0 commit comments

Comments
 (0)