Add unit tests to several API utility functions (#16662)

* add unit tests to several API util functions

* fix timezone tests to account for daylight saving

* add a note for future reference

* Update api/src/utils/get-date-formatted.test.ts

Co-authored-by: Brainslug <br41nslug@users.noreply.github.com>

* remove unnecessary note as it is not an issue

* fix getEnv mock in validate-env test

Co-authored-by: Brainslug <br41nslug@users.noreply.github.com>
Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
This commit is contained in:
Azri Kahar
2022-12-24 00:51:49 +08:00
committed by GitHub
parent 6bf5de1f9d
commit e899244ef3
7 changed files with 177 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
import { expect, test } from 'vitest';
import { stripFunction } from './strip-function';
test.each([
{ field: 'year(date_created)', expected: 'date_created' },
{ field: 'test', expected: 'test' },
])('should return "$expected" for "$field"', ({ field, expected }) => {
expect(stripFunction(field)).toBe(expected);
});