mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-04 03:45:58 -05:00
Clean up compareItems() test code.
This commit is contained in:
parent
b3281806a3
commit
456abcfda3
1 changed files with 22 additions and 19 deletions
|
@ -100,29 +100,31 @@ function compareItems(item, item2) {
|
||||||
return item != item2;
|
return item != item2;
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
equals(function() {
|
||||||
|
return item.id != item2.id;
|
||||||
|
}, true);
|
||||||
|
|
||||||
var itemProperties = ['opacity', 'locked', 'visible', 'blendMode', 'name',
|
var itemProperties = ['opacity', 'locked', 'visible', 'blendMode', 'name',
|
||||||
'closed', 'selected'];
|
'closed', 'selected'];
|
||||||
Base.each(itemProperties, function(key) {
|
Base.each(itemProperties, function(key) {
|
||||||
equals(function() {
|
equals(function() {
|
||||||
return item[key] == item2[key];
|
return item[key] == item2[key];
|
||||||
}, true, 'item[\'' + key + '\'] == item2[\'' + key + '\']');
|
}, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
equals(function() {
|
|
||||||
return item.id != item2.id;
|
|
||||||
}, true);
|
|
||||||
|
|
||||||
if (item._matrix) {
|
if (item._matrix) {
|
||||||
equals(function() {
|
equals(function() {
|
||||||
return item._matrix != item2._matrix;
|
return item._matrix != item2._matrix;
|
||||||
}, true);
|
}, true);
|
||||||
equals(item._matrix.toString(), item2._matrix.toString(),
|
equals(function() {
|
||||||
'item._matrix.toString() == item2._matrix.toString()');
|
return item._matrix.toString() == item2._matrix.toString()
|
||||||
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item2.segments) {
|
if (item2.segments) {
|
||||||
equals(item.segments.toString(), item2.segments.toString(),
|
equals(function() {
|
||||||
'item.segments.toString() == item2.segments.toString()');
|
return item.segments.toString() == item2.segments.toString()
|
||||||
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Path specific
|
// Path specific
|
||||||
|
@ -157,20 +159,20 @@ function compareItems(item, item2) {
|
||||||
|
|
||||||
// TextItem specific:
|
// TextItem specific:
|
||||||
if (item instanceof TextItem) {
|
if (item instanceof TextItem) {
|
||||||
equals(item.content, item2.content, 'item.content == item2.content');
|
equals(function() {
|
||||||
|
return item.content == item2.content;
|
||||||
|
}, true);
|
||||||
var characterStyleKeys = ['fontSize', 'font'];
|
var characterStyleKeys = ['fontSize', 'font'];
|
||||||
Base.each(characterStyleKeys, function(key) {
|
Base.each(characterStyleKeys, function(key) {
|
||||||
equals(function() {
|
equals(function() {
|
||||||
return item2.characterStyle[key];
|
return item.characterStyle[key] == item2.characterStyle[key];
|
||||||
}, item.characterStyle[key], 'item.characterStyle[\'' + key
|
}, true);
|
||||||
+ '\'] == item2.characterStyle[\'' + key + '\']');
|
|
||||||
});
|
});
|
||||||
var paragraphStyleKeys = ['justification'];
|
var paragraphStyleKeys = ['justification'];
|
||||||
Base.each(paragraphStyleKeys, function(key) {
|
Base.each(paragraphStyleKeys, function(key) {
|
||||||
equals(function() {
|
equals(function() {
|
||||||
return item2.paragraphStyle[key];
|
return item.paragraphStyle[key] == item2.paragraphStyle[key];
|
||||||
}, item.paragraphStyle[key], 'item.paragraphStyle[\'' + key
|
}, true);
|
||||||
+ '\'] == item2.paragraphStyle[\'' + key + '\']');
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,13 +211,14 @@ function compareItems(item, item2) {
|
||||||
if (item[key]) {
|
if (item[key]) {
|
||||||
equals(function() {
|
equals(function() {
|
||||||
return item[key] == item2[key];
|
return item[key] == item2[key];
|
||||||
}, true, 'item[\'' + key + '\'] == item2[\'' + key + '\']');
|
}, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (item.dashArray) {
|
if (item.dashArray) {
|
||||||
equals(item.dashArray.toString(), item2.dashArray.toString(),
|
equals(function() {
|
||||||
'item.dashArray.toString(), item2.dashArray.toString()');
|
return item.dashArray.toString() == item2.dashArray.toString();
|
||||||
|
}, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue