timered-counter
Version:
Make the value change more vivid and natural
30 lines • 1.45 kB
JavaScript
import { expect } from '@storybook/test';
import { sleep } from '../utils/index.js';
export async function datetimeLocale(context, { counter, setBy, }) {
const { step, args } = context;
const locales = [
['zh-CN', ['日', '小时', '分钟', '秒']],
['zh-HK', ['日', '小時', '分鐘', '秒']],
['zh-TW', ['日', '小時', '分鐘', '秒']],
['en-US', ['day', 'hour', 'minute', 'second']],
['en-GB', ['day', 'hour', 'minute', 'second']],
['fr-FR', ['jour', 'heure', 'minute', 'seconde']],
['de-DE', ['Tag', 'Stunde', 'Minute', 'Sekunde']],
['ja-JP', ['日', '時', '分', '秒']],
['ko-KR', ['일', '시', '분', '초']],
];
await step('Test different locale', async () => {
for await (const [locale, testTarget] of locales) {
await step(`Locale: ${locale}`, async () => {
setBy(counter, 'locale', locale);
await sleep((args.animationOptions.duration ?? 100) + 10);
const partSuffixes = Array.from((counter.shadowRoot
?.querySelector('timered-counter-roller')
?.shadowRoot?.querySelectorAll('.roller-part__suffix slot') ??
[])).map(el => el.assignedElements()[0].textContent?.trim());
await expect(partSuffixes).toEqual(testTarget);
});
}
});
}
//# sourceMappingURL=datetime-locale.js.map