Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add vitest suite #114

Closed
bdougie opened this issue May 24, 2023 · 1 comment
Closed

feat: Add vitest suite #114

bdougie opened this issue May 24, 2023 · 1 comment

Comments

@bdougie
Copy link
Member

bdougie commented May 24, 2023

We really should have a vitest suite. The PR #109 adds a getRelativeDays function that can be tested.

import { getRelativeDays } from './dateUtils';

describe('getRelativeDays', () => {
  it('returns "-" for 0 days', () => {
    expect(getRelativeDays(0)).toBe('-');
  });

  it('returns "1d" for 1 day', () => {
    expect(getRelativeDays(1)).toBe('1d');
  });

  it('returns "30d" for 30 days', () => {
    expect(getRelativeDays(30)).toBe('30d');
  });

  it('returns "1mo" for 31 days', () => {
    expect(getRelativeDays(31)).toBe('1mo');
  });

  it('returns "1y" for 365 days', () => {
    expect(getRelativeDays(365)).toBe('1y');
  });

  it('returns "2y" for 730 days', () => {
    expect(getRelativeDays(730)).toBe('2y');
  });
});

Originally posted by @bdougie in #111 (comment)

@Nanak360
Copy link
Contributor

Yup.
PR #111 can be merged once we have the vitest library intigrated in the app. Or, even if it is merged, we can create one more PR for writing test cases.
Also if needed vitest can be added in PR #111 itself with unit tests for the getRelativeDays file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

3 participants