seamless-immutable-mergers
Advanced tools
Comparing version 3.0.0 to 3.0.2
{ | ||
"name": "seamless-immutable-mergers", | ||
"version": "3.0.0", | ||
"version": "3.0.2", | ||
"description": "A collection of merger functions for seamless-immutable.", | ||
@@ -5,0 +5,0 @@ "main": "seamless-immutable-mergers.js", |
{ | ||
"name": "seamless-immutable-mergers", | ||
"version": "3.0.0", | ||
"version": "3.0.2", | ||
"description": "A collection of merger functions for seamless-immutable.", | ||
@@ -5,0 +5,0 @@ "main": "seamless-immutable-mergers.js", |
@@ -157,3 +157,9 @@ seamless-immutable-mergers | ||
## Major and minor releases | ||
## Releases | ||
### 3.0.2 | ||
Fixed a bug in *updatingByIdArrayMerger* where a merge with an empty array would wipe the content of the current array. | ||
### 3.0.0 | ||
Updated to *[seamless-immutable](https://github.com/rtfeldman/seamless-immutable)* 3.0.0 and bumped the major version to be in sync. | ||
### 2.2.0 | ||
@@ -160,0 +166,0 @@ Started using the UMD pattern so the library will be easy to consume as a global or with requirejs (and not only node/browserify). |
@@ -30,3 +30,4 @@ "use strict"; | ||
if (!(current instanceof Array) || !(other instanceof Array)) return; | ||
if (current.length === 0 || other.length === 0) return; | ||
if (current.length === 0) return; | ||
if (other.length === 0) return current; | ||
@@ -33,0 +34,0 @@ var identifier = config.mergerObjectIdentifier; |
@@ -187,2 +187,63 @@ "use strict"; | ||
}); | ||
it("doesn't empty an array when the push contains an empty array", function() { | ||
var current = immutable({ | ||
array: [ | ||
{ | ||
id: 10, | ||
status: "ok", | ||
content: "text", | ||
items: [ | ||
{ | ||
id: 100, | ||
status: "ok", | ||
content: "text" | ||
} | ||
] | ||
} | ||
] | ||
}); | ||
var update = { | ||
array: [] | ||
}; | ||
var result = current.merge(update, config); | ||
assert.equal(result.array.length, 1); | ||
}); | ||
it("doesn't deeply empty an array when the push contains an empty array", function() { | ||
var current = immutable({ | ||
array: [ | ||
{ | ||
id: 10, | ||
status: "ok", | ||
content: "text", | ||
items: [ | ||
{ | ||
id: 100, | ||
status: "ok", | ||
content: "text" | ||
} | ||
] | ||
} | ||
] | ||
}); | ||
var update = { | ||
array: [ | ||
{ | ||
id: 10, | ||
items: [] | ||
} | ||
] | ||
}; | ||
var result = current.merge(update, config); | ||
assert.equal(result.array.length, 1); | ||
var resultObject = result.array[0]; | ||
var items = resultObject.items; | ||
assert.equal(items.length, 1); | ||
}); | ||
}); |
30066
410
172