Skip to content

Commit 7e10443

Browse files
chore: eslint vitest (#28)
1 parent 07a579a commit 7e10443

File tree

2 files changed

+38
-14
lines changed

2 files changed

+38
-14
lines changed

eslint.config.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import {default as config} from '@dfinity/eslint-config-oisy-wallet';
2+
import {default as vitestConfig} from '@dfinity/eslint-config-oisy-wallet/vitest';
23

34
export default [
45
...config,
6+
...vitestConfig,
57
{
68
ignores: ['**/dist/', 'eslint-local-rules.cjs', 'scripts/**/*', '**/esbuild.mjs']
79
}

plugins/plugin-tools/src/config.spec.ts

+36-14
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ vi.mock('@junobuild/config-loader', async () => {
3636
describe('config', () => {
3737
describe('useDockerContainer', () => {
3838
it('returns true if container is true and mode is development', () => {
39-
expect(useDockerContainer({params: {container: true}, mode: MODE_DEVELOPMENT})).toBe(true);
39+
expect(useDockerContainer({params: {container: true}, mode: MODE_DEVELOPMENT})).toBeTruthy();
4040
});
4141

4242
it('returns false if container is false', () => {
43-
expect(useDockerContainer({params: {container: false}, mode: MODE_DEVELOPMENT})).toBe(false);
43+
expect(useDockerContainer({params: {container: false}, mode: MODE_DEVELOPMENT})).toBeFalsy();
4444
});
4545

4646
it('returns false in production mode', () => {
47-
expect(useDockerContainer({params: {container: true}, mode: 'production'})).toBe(false);
47+
expect(useDockerContainer({params: {container: true}, mode: 'production'})).toBeFalsy();
4848
});
4949

5050
it('returns true if container has matching mode in modes[]', () => {
@@ -57,7 +57,7 @@ describe('config', () => {
5757
},
5858
mode: MODE_DEVELOPMENT
5959
})
60-
).toBe(true);
60+
).toBeTruthy();
6161
});
6262

6363
it('returns false if container has non-matching mode in modes[]', () => {
@@ -70,7 +70,7 @@ describe('config', () => {
7070
},
7171
mode: 'production'
7272
})
73-
).toBe(false);
73+
).toBeFalsy();
7474
});
7575

7676
it('returns true if container has no modes[] (default to development)', () => {
@@ -83,27 +83,27 @@ describe('config', () => {
8383
},
8484
mode: MODE_DEVELOPMENT
8585
})
86-
).toBe(true);
86+
).toBeTruthy();
8787
});
8888

8989
it('returns true if container is undefined and mode is development', () => {
90-
expect(useDockerContainer({params: {}, mode: MODE_DEVELOPMENT})).toBe(true);
90+
expect(useDockerContainer({params: {}, mode: MODE_DEVELOPMENT})).toBeTruthy();
9191
});
9292

9393
it('returns false if container is undefined and mode is production', () => {
94-
expect(useDockerContainer({params: {}, mode: 'production'})).toBe(false);
94+
expect(useDockerContainer({params: {}, mode: 'production'})).toBeFalsy();
9595
});
9696

9797
it('returns true if params is undefined and mode is development', () => {
98-
expect(useDockerContainer({params: undefined, mode: MODE_DEVELOPMENT})).toBe(true);
98+
expect(useDockerContainer({params: undefined, mode: MODE_DEVELOPMENT})).toBeTruthy();
9999
});
100100

101101
it('returns false if params is undefined and mode is production', () => {
102-
expect(useDockerContainer({params: undefined, mode: 'production'})).toBe(false);
102+
expect(useDockerContainer({params: undefined, mode: 'production'})).toBeFalsy();
103103
});
104104

105105
it('returns true if container is an empty object and mode is development', () => {
106-
expect(useDockerContainer({params: {container: {}}, mode: MODE_DEVELOPMENT})).toBe(true);
106+
expect(useDockerContainer({params: {container: {}}, mode: MODE_DEVELOPMENT})).toBeTruthy();
107107
});
108108

109109
it('returns false if container has empty modes[]', () => {
@@ -116,7 +116,7 @@ describe('config', () => {
116116
},
117117
mode: MODE_DEVELOPMENT
118118
})
119-
).toBe(false);
119+
).toBeFalsy();
120120
});
121121
});
122122

@@ -125,11 +125,12 @@ describe('config', () => {
125125
vi.clearAllMocks();
126126
});
127127

128-
describe(MODE_DEVELOPMENT, () => {
128+
describe(`${MODE_DEVELOPMENT}`, () => {
129129
it('returns docker satellite ID in dev mode with container true and no config file', async () => {
130130
vi.spyOn(configLoader, 'junoConfigExist').mockResolvedValue(false);
131131

132132
const id = await satelliteId({params: {container: true}, mode: MODE_DEVELOPMENT});
133+
133134
expect(id).toBe(DOCKER_SATELLITE_ID);
134135
});
135136

@@ -141,6 +142,7 @@ describe('config', () => {
141142
});
142143

143144
const id = await satelliteId({params: {container: true}, mode: MODE_DEVELOPMENT});
145+
144146
expect(id).toBe('dev-custom-id');
145147
});
146148

@@ -152,6 +154,7 @@ describe('config', () => {
152154
});
153155

154156
const id = await satelliteId({params: {container: true}, mode: MODE_DEVELOPMENT});
157+
155158
expect(id).toBe(DOCKER_SATELLITE_ID);
156159
});
157160

@@ -163,6 +166,7 @@ describe('config', () => {
163166
});
164167

165168
const id = await satelliteId({params: {container: true}, mode: MODE_DEVELOPMENT});
169+
166170
expect(id).toBe(DOCKER_SATELLITE_ID);
167171
});
168172
});
@@ -176,6 +180,7 @@ describe('config', () => {
176180
});
177181

178182
const id = await satelliteId({params: {container: false}, mode: 'production'});
183+
179184
expect(id).toBe('prod-sat-id');
180185
});
181186

@@ -208,11 +213,12 @@ describe('config', () => {
208213
vi.clearAllMocks();
209214
});
210215

211-
describe(MODE_DEVELOPMENT, () => {
216+
describe(`${MODE_DEVELOPMENT}`, () => {
212217
it('returns undefined in dev mode with container true and no config file', async () => {
213218
vi.spyOn(configLoader, 'junoConfigExist').mockResolvedValue(false);
214219

215220
const id = await orbiterId({params: {container: true}, mode: MODE_DEVELOPMENT});
221+
216222
expect(id).toBeUndefined();
217223
});
218224

@@ -224,6 +230,7 @@ describe('config', () => {
224230
} as unknown as JunoConfig);
225231

226232
const id = await orbiterId({params: {container: true}, mode: MODE_DEVELOPMENT});
233+
227234
expect(id).toBe('orb-dev-id');
228235
});
229236

@@ -235,6 +242,7 @@ describe('config', () => {
235242
} as unknown as JunoConfig);
236243

237244
const id = await orbiterId({params: {container: true}, mode: MODE_DEVELOPMENT});
245+
238246
expect(id).toBeUndefined();
239247
});
240248

@@ -246,6 +254,7 @@ describe('config', () => {
246254
} as unknown as JunoConfig);
247255

248256
const id = await orbiterId({params: {container: true}, mode: MODE_DEVELOPMENT});
257+
249258
expect(id).toBeUndefined();
250259
});
251260

@@ -257,6 +266,7 @@ describe('config', () => {
257266
} as unknown as JunoConfig);
258267

259268
const id = await orbiterId({params: {container: true}, mode: MODE_DEVELOPMENT});
269+
260270
expect(id).toBeUndefined();
261271
});
262272
});
@@ -274,6 +284,7 @@ describe('config', () => {
274284
} as unknown as JunoConfig);
275285

276286
const id = await orbiterId({params: {container: false}, mode: 'production'});
287+
277288
expect(id).toBe('orb-prod-id');
278289
});
279290

@@ -285,6 +296,7 @@ describe('config', () => {
285296
} as unknown as JunoConfig);
286297

287298
const id = await orbiterId({params: {container: false}, mode: 'production'});
299+
288300
expect(id).toBe('orb-id');
289301
});
290302

@@ -296,6 +308,7 @@ describe('config', () => {
296308
} as unknown as JunoConfig);
297309

298310
const id = await orbiterId({params: {}, mode: 'production'});
311+
299312
expect(id).toBe('fallback-id');
300313
});
301314

@@ -304,6 +317,7 @@ describe('config', () => {
304317
vi.spyOn(configLoader, 'readJunoConfig').mockResolvedValue({} as unknown as JunoConfig);
305318

306319
const id = await orbiterId({params: {}, mode: 'production'});
320+
307321
expect(id).toBeUndefined();
308322
});
309323

@@ -314,6 +328,7 @@ describe('config', () => {
314328
);
315329

316330
const id = await orbiterId({params: {}, mode: 'production'});
331+
317332
expect(id).toBeUndefined();
318333
});
319334
});
@@ -353,11 +368,13 @@ describe('config', () => {
353368

354369
it('returns default URL if container is true', () => {
355370
const url = container({params: {container: true}, mode: MODE_DEVELOPMENT});
371+
356372
expect(url).toBe('http://127.0.0.1:5987');
357373
});
358374

359375
it('returns undefined in production when container is true', () => {
360376
const url = container({params: {container: true}, mode: 'production'});
377+
361378
expect(url).toBeUndefined();
362379
});
363380

@@ -370,6 +387,7 @@ describe('config', () => {
370387
},
371388
mode: MODE_DEVELOPMENT
372389
});
390+
373391
expect(url).toBe('http://custom-container.local');
374392
});
375393

@@ -382,6 +400,7 @@ describe('config', () => {
382400
},
383401
mode: MODE_DEVELOPMENT
384402
});
403+
385404
expect(url).toBe('http://127.0.0.1:5987');
386405
});
387406

@@ -392,6 +411,7 @@ describe('config', () => {
392411
},
393412
mode: MODE_DEVELOPMENT
394413
});
414+
395415
expect(url).toBeUndefined();
396416
});
397417
});
@@ -403,11 +423,13 @@ describe('config', () => {
403423

404424
it('throws if config does not exist', async () => {
405425
vi.spyOn(configLoader, 'junoConfigExist').mockResolvedValue(false);
426+
406427
await expect(assertJunoConfig()).rejects.toThrow(JunoPluginError);
407428
});
408429

409430
it('resolves if config exists', async () => {
410431
vi.spyOn(configLoader, 'junoConfigExist').mockResolvedValue(true);
432+
411433
await expect(assertJunoConfig()).resolves.toBeUndefined();
412434
});
413435
});

0 commit comments

Comments
 (0)