Skip to content

Commit eff5c8e

Browse files
committed
Standardize on arrow functions in unit tests
I'm planning to add this to a code style doc, probably in CONTRIBUTING.md
1 parent 114c910 commit eff5c8e

9 files changed

Lines changed: 874 additions & 729 deletions

unitTests/components/Scope.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,11 @@ describe('Scope', () => {
113113
const callArgs = handleEntrySpy.getCall(0).args[0];
114114
assert.equal(callArgs.eventType, 'add', 'handleEntry argument `eventType` should be `add`');
115115
assert.equal(callArgs.entryType, 'file', 'handleEntry argument `entryType` should be `file`');
116-
assert.equal(callArgs.absolutePath, this.testFilePath, 'handleEntry argument `absolutePath` should be the test file path');
116+
assert.equal(
117+
callArgs.absolutePath,
118+
this.testFilePath,
119+
'handleEntry argument `absolutePath` should be the test file path'
120+
);
117121
assert.equal(callArgs.urlPath, '/abc/test.js', 'handleEntry argument `urlPath` should be `abc/test.js`');
118122
assert.ok(callArgs.stats !== undefined, 'add event argument `stats` should be defined');
119123
assert.ok(callArgs.stats.isFile(), 'add event argument `stats` should be a file');

unitTests/components/componentLoader.test.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ const path = require('path');
55
const { tmpdir } = require('os');
66
const { mkdtempSync, mkdirSync, writeFileSync, rmSync, existsSync } = require('fs');
77

8-
describe('ComponentLoader Status Integration', function () {
8+
describe('ComponentLoader Status Integration', () => {
99
let componentStatusRegistry;
1010
let tempDir;
1111
let componentLoader;
1212
let lifecycle;
1313

14-
before(function () {
14+
before(() => {
1515
// Create a temporary directory for test components
1616
tempDir = mkdtempSync(path.join(tmpdir(), 'harper-test-components-'));
1717

@@ -58,7 +58,7 @@ describe('ComponentLoader Status Integration', function () {
5858
componentLoader = require('#harper/components/componentLoader');
5959
});
6060

61-
after(function () {
61+
after(() => {
6262
// Restore all spies
6363
sinon.restore();
6464

@@ -71,7 +71,7 @@ describe('ComponentLoader Status Integration', function () {
7171
componentStatusRegistry.reset();
7272
});
7373

74-
beforeEach(function () {
74+
beforeEach(() => {
7575
// Reset spy history before each test
7676
lifecycle.loading.resetHistory();
7777
lifecycle.loaded.resetHistory();
@@ -86,8 +86,8 @@ describe('ComponentLoader Status Integration', function () {
8686
componentStatusRegistry.reset();
8787
});
8888

89-
describe('Basic component status tracking', function () {
90-
it('should initialize loading status for non-root components', async function () {
89+
describe('Basic component status tracking', () => {
90+
it('should initialize loading status for non-root components', async () => {
9191
// Create a test component directory
9292
const componentDirName = 'test-component';
9393
const componentDir = path.join(tempDir, componentDirName);
@@ -121,7 +121,7 @@ describe('ComponentLoader Status Integration', function () {
121121
);
122122
});
123123

124-
it('should track loading for components with trusted loaders', async function () {
124+
it('should track loading for components with trusted loaders', async () => {
125125
// Create a component using a trusted loader
126126
const componentDirName = 'trusted-component';
127127
const componentDir = path.join(tempDir, componentDirName);
@@ -154,7 +154,7 @@ describe('ComponentLoader Status Integration', function () {
154154
assert.match(loadedCalls[0].args[1], /loaded successfully/);
155155
});
156156

157-
it('should mark component as failed when it loads no functionality', async function () {
157+
it('should mark component as failed when it loads no functionality', async () => {
158158
// Create a component directory without config
159159
// This will use DEFAULT_CONFIG but won't actually load anything
160160
const componentDirName = 'empty-component';
@@ -188,8 +188,8 @@ describe('ComponentLoader Status Integration', function () {
188188
});
189189
});
190190

191-
describe('Component status verification', function () {
192-
it('should properly set status in registry after successful load', async function () {
191+
describe('Component status verification', () => {
192+
it('should properly set status in registry after successful load', async () => {
193193
// Create a component
194194
const componentDirName = 'verify-status';
195195
const componentDir = path.join(tempDir, componentDirName);
@@ -213,7 +213,7 @@ describe('ComponentLoader Status Integration', function () {
213213
assert.ok(status.message, 'Should have a status message');
214214
});
215215

216-
it('should handle component loading errors gracefully', async function () {
216+
it('should handle component loading errors gracefully', async () => {
217217
// Stub the dataLoader module's handleApplication method to throw an error
218218
const dataLoaderModule = require('#harper/resources/dataLoader');
219219
const originalhandleApplication = dataLoaderModule.handleApplication;

0 commit comments

Comments
 (0)