Adding tests for Match nodes

This commit is contained in:
Jeff Avallone
2014-12-26 12:48:02 -05:00
parent cf159c28a5
commit aa6c792867
2 changed files with 310 additions and 18 deletions
+19 -17
View File
@@ -41,8 +41,6 @@ export default {
return Q.all(_([start, partPromises, end]).flatten().compact().value())
.then(items => {
var prev, next, paths;
this.start = _.first(items);
this.end = _.last(items);
@@ -50,28 +48,32 @@ export default {
padding: 10
});
prev = util.normalizeBBox(_.first(items).getBBox());
paths = _.map(items.slice(1), item => {
var path;
next = util.normalizeBBox(item.getBBox());
path = `M${prev.ax2},${prev.ay}H${next.ax}`;
prev = next;
return path;
});
this.container.prepend(
this.container.path(paths.join('')));
this.container.path(this.connectorPaths(items).join('')));
});
},
connectorPaths(items) {
var prev, next;
prev = util.normalizeBBox(_.first(items).getBBox());
return _.map(items.slice(1), item => {
try {
next = util.normalizeBBox(item.getBBox());
return `M${prev.ax2},${prev.ay}H${next.ax}`;
}
finally {
prev = next;
}
});
},
setup() {
this.parts = _.reduce(this.properties.parts.elements, function(result, node) {
var last = _.last(result);
if (last && node.canMerge && last.canMerge) {
last.elements[0].merge(node.elements[0]);
last.content.merge(node.content);
} else {
result.push(node);
}
@@ -79,8 +81,8 @@ export default {
return result;
}, []);
this.anchorStart = this.properties.anchor_start.textValue !== '';
this.anchorEnd = this.properties.anchor_end.textValue !== '';
this.anchorStart = (this.properties.anchor_start.textValue !== '');
this.anchorEnd = (this.properties.anchor_end.textValue !== '');
if (!this.anchorStart && !this.anchorEnd && this.parts.length === 1) {
this.proxy = this.parts[0];