diff --git a/src/slash-command/stats.js b/src/slash-command/stats.js index e28945a..73dc09c 100644 --- a/src/slash-command/stats.js +++ b/src/slash-command/stats.js @@ -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 { @@ -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({ diff --git a/src/util/time.test.js b/src/util/time.test.js new file mode 100644 index 0000000..9c75972 --- /dev/null +++ b/src/util/time.test.js @@ -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); + }); + }); +});