Skip to content

Commit

Permalink
test(flattenObject): change using constant date in test case (#253)
Browse files Browse the repository at this point in the history
* fix: change test case to use constant date in flattenObject test cases

* Update src/object/flattenObject.spec.ts

* Update src/object/flattenObject.spec.ts

---------

Co-authored-by: Sojin Park <raon0211@gmail.com>
Co-authored-by: Sojin Park <raon0211@toss.im>
  • Loading branch information
3 people authored Jul 20, 2024
1 parent d12453a commit 0b71ce9
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/object/flattenObject.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, expect, it, test } from "vitest"
import { describe, expect, it } from "vitest"
import { flattenObject } from "./flattenObject";

describe('flattenObject', function () {
Expand All @@ -13,6 +13,8 @@ describe('flattenObject', function () {
'a.b': 'yay'
})

const date = new Date();

const result2 = flattenObject({
a: {
b: {
Expand All @@ -21,7 +23,7 @@ describe('flattenObject', function () {
boolean: true,
null: null,
undefined: undefined,
date: new Date(),
date: date,
}
}
})
Expand All @@ -32,11 +34,13 @@ describe('flattenObject', function () {
'a.b.boolean': true,
'a.b.null': null,
'a.b.undefined': undefined,
'a.b.date': new Date(),
'a.b.date': date,
})
})

it('flattens multiple keys', () => {
const date = new Date();

const result = flattenObject({
a: {
b: {
Expand All @@ -45,7 +49,7 @@ describe('flattenObject', function () {
d: {
e: {
f: {
g: new Date()
g: date
}
}
}
Expand All @@ -57,7 +61,7 @@ describe('flattenObject', function () {

expect(result).toEqual({
'a.b.c': 1,
'a.d.e.f.g': new Date(),
'a.d.e.f.g': date,
'h.i': 'hi'
})
})
Expand Down Expand Up @@ -137,4 +141,4 @@ describe('flattenObject', function () {
'a.2': 3,
});
})
})
})

0 comments on commit 0b71ce9

Please sign in to comment.