Skip to content

Commit

Permalink
try another fix for lower node version
Browse files Browse the repository at this point in the history
  • Loading branch information
Freezystem committed Feb 4, 2025
1 parent e749fcf commit 41d815b
Showing 1 changed file with 41 additions and 39 deletions.
80 changes: 41 additions & 39 deletions packages/moleculer-db/test/unit/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,49 @@ const { flatten } = require("../../src/utils");
if (process.versions.node.split(".")[0] < 14) {
console.log("Skipping utils tests because node version is too low");
it("Skipping utils tests because node version is too low", () => {});
}
} else {

describe("Test Utils", () => {
describe("flatten", () => {
it("should properly flatten a given object", () => {
const { randomUUID } = require("crypto");
const uuid = randomUUID();
const date = new Date("2024-01-01");
const obj = {
name: "John",
address: {
street: "Main St",
location: {
city: "Boston",
country: "USA"
}
},
account: {
createdAt: date,
identifier: uuid,
settings: {
theme: null,
language: undefined
}
},
scores: [85, 90, 95],
};
describe("Test Utils", () => {
describe("flatten", () => {
it("should properly flatten a given object", () => {
const {randomUUID} = require("crypto");
const uuid = randomUUID();
const date = new Date("2024-01-01");
const obj = {
name: "John",
address: {
street: "Main St",
location: {
city: "Boston",
country: "USA"
}
},
account: {
createdAt: date,
identifier: uuid,
settings: {
theme: null,
language: undefined
}
},
scores: [85, 90, 95],
};

const expected = {
"name": "John",
"address.street": "Main St",
"address.location.city": "Boston",
"address.location.country": "USA",
"account.createdAt": date,
"account.identifier": uuid,
"account.settings.theme": null,
"account.settings.language": undefined,
"scores": [85, 90, 95],
};
const expected = {
"name": "John",
"address.street": "Main St",
"address.location.city": "Boston",
"address.location.country": "USA",
"account.createdAt": date,
"account.identifier": uuid,
"account.settings.theme": null,
"account.settings.language": undefined,
"scores": [85, 90, 95],
};

expect(flatten(obj)).toEqual(expected);
expect(flatten(obj)).toEqual(expected);
});
});
});
});

}

0 comments on commit 41d815b

Please sign in to comment.