Remove Set equal comparison

This commit is contained in:
barsdeveloper
2023-01-19 19:05:23 +01:00
parent 47106f748d
commit efe560adda
3 changed files with 0 additions and 43 deletions

View File

@@ -48,11 +48,6 @@ describe("Entity initialization", () => {
.which.is.an("array")
.and.is.deep.equal([400, 500, 600, 700, 800])
)
it("has someSet with numbers", () => expect(entity)
.to.have.property("someSet")
.which.is.instanceOf(Set)
.and.is.deep.equal(new Set([10, 20, 30, 40, 50, 60, 70]))
)
it("is equal to another empty SimpleEntity", () => expect(entity.equals(new SimpleEntity()))
.to.be.true
)
@@ -70,7 +65,6 @@ describe("Entity initialization", () => {
someBoolean2: false,
someObjectString: new String("delta"),
someArray: [-1, -2, -3],
someSet: new Set([-10, -20, -30]),
})
const other2 = new SimpleEntity({
someNumber: 123,
@@ -80,7 +74,6 @@ describe("Entity initialization", () => {
someBoolean2: false,
someObjectString: "delta",
someArray: [-1, -2, -3],
someSet: new Set([-10, -20, -30]),
})
it("compares equal entities as equal", () => expect(other1.equals(other2))
.to.be.true

View File

@@ -69,34 +69,6 @@ describe("Utility class", () => {
[-2, "Alpha", new String("beta"), new Number(40), [1, 2, 3]],
[new Number(-2), new String("alpha"), new String("beta"), new Number(40), new Array(1, 2, 3)]
)).to.be.false // Second element is different
expect(Utility.equals(
new Set(["alpha", -67, new String("beta"), [1, 2, 3]]),
new Set([-67, "beta", new String("alpha"), [1, 2, 3]])
)).to.be.true
expect(Utility.equals( // First element has capital Beta
new Set(["alpha", -67, new String("Beta"), [1, 2, 3]]),
new Set([-67, "beta", new String("alpha"), [1, 2, 3]])
)).to.be.false
expect(Utility.equals( // First element has capital Beta
new Set(["alpha", -67, new String("beta"), [1, 2, 3]]),
new Set([-67, "beta", new String("alpha"), [1, 3]])
)).to.be.false
expect(Utility.equals( // Different number of elements
new Set([2, 4, 6, 8]),
new Set([8, 6, 4])
)).to.be.false
expect(Utility.equals( // Second element has different type
new Set([4, "6", 8]),
new Set([8, 6, 4])
)).to.be.false
expect(Utility.equals(
new Set([new IEntity({ a: "alpha", b: new String("beta") })]),
new Set([new IEntity({ a: "alpha", b: new String("beta") })]),
)).to.be.true
expect(Utility.equals( // First a key has a number
new Set([new IEntity({ a: 2, b: new String("beta") })]),
new Set([new IEntity({ a: "alpha", b: new String("beta") })]),
)).to.be.false
})
it("isValueOfType method test", () => {
expect(Utility.isValueOfType(34, Number)).to.be.true

View File

@@ -175,14 +175,6 @@ export default class Utility {
if (a instanceof Array && b instanceof Array) {
return a.length === b.length && a.every((value, i) => Utility.equals(value, b[i]))
}
if (a instanceof Set && b instanceof Set) {
if (a.size !== b.size) {
return false
}
a = [...a]
b = [...b]
return a.every(first => /** @type {Array} */(b).some(second => Utility.equals(first, second)))
}
return false
}