Skip to content

Commit

Permalink
Merge pull request #264 from moeyashi/feature/261
Browse files Browse the repository at this point in the history
fix(stats): 時間の形式を修正 #261
  • Loading branch information
moeyashi authored Dec 16, 2024
2 parents 1ebd7d7 + 01e411a commit 165a237
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/slash-command/stats.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @ts-check
import { SlashCommandBuilder } from 'discord.js';
import { searchTrack } from '../const/track.js';
import { toMilliseconds } from '../util/time.js';

/** @type { import('../types.js').SlashCommand } */
export default {
Expand All @@ -21,7 +20,7 @@ export default {
throw new Error(`コースが見つかりませんでした。\n入力されたコース名: ${trackQuery}`);
}

const stats = await nitaRepository.selectStats(track.code, toMilliseconds(track.nitaVSWRMilliseconds));
const stats = await nitaRepository.selectStats(track.code, track.nitaVSWRMilliseconds);
console.info(stats);

await interaction.reply({
Expand Down
21 changes: 21 additions & 0 deletions src/util/time.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// @ts-check
import { describe, expect, test } from 'vitest';
import { toMilliseconds } from './time.js';

describe('toMilliseconds', () => {
describe('1分台で繰り上がらない', () => {
test('1:39:999', () => {
expect(toMilliseconds(139999)).toBe(99999);
});
});
describe('1分台で繰り上がる', () => {
test('1:40:000', () => {
expect(toMilliseconds(140000)).toBe(100000);
});
});
describe('2分台', () => {
test('2:00:000', () => {
expect(toMilliseconds(200000)).toBe(120000);
});
});
});

0 comments on commit 165a237

Please sign in to comment.