Changing util.js to export an object

This allows the methods to be spied on in tests
This commit is contained in:
Jeff Avallone
2014-12-20 10:25:32 -05:00
parent 8a9a129856
commit 6c5b36f334
9 changed files with 31 additions and 31 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
import { customEvent } from './util.js';
import util from './util.js';
import Regexper from './regexper.js';
(function() {
@@ -8,7 +8,7 @@ import Regexper from './regexper.js';
regexper.bindListeners();
setTimeout(() => {
window.dispatchEvent(customEvent('hashchange'));
window.dispatchEvent(util.customEvent('hashchange'));
});
}
}());
+2 -2
View File
@@ -1,4 +1,4 @@
import { spaceVertically } from '../../util.js';
import util from '../../util.js';
import _ from 'lodash';
import Q from 'q';
export default {
@@ -26,7 +26,7 @@ export default {
return part.render(this.partContainer.group());
}))
.then(() => {
spaceVertically(this.elements, {
util.spaceVertically(this.elements, {
padding: 5
});
+6 -6
View File
@@ -1,4 +1,4 @@
import { normalizeBBox, spaceHorizontally } from '../../util.js';
import util from '../../util.js';
import _ from 'lodash';
import Q from 'q';
@@ -8,8 +8,8 @@ export default {
definedProperties: {
_anchor: {
get: function() {
var start = normalizeBBox(_.first(this.items).getBBox()),
end = normalizeBBox(_.last(this.items).getBBox()),
var start = util.normalizeBBox(_.first(this.items).getBBox()),
end = util.normalizeBBox(_.last(this.items).getBBox()),
matrix = this.transform().localMatrix;
return {
@@ -44,15 +44,15 @@ export default {
var prev, next, paths;
this.items = items;
spaceHorizontally(items, {
util.spaceHorizontally(items, {
padding: 10
});
prev = normalizeBBox(_.first(items).getBBox());
prev = util.normalizeBBox(_.first(items).getBBox());
paths = _.map(items.slice(1), item => {
var path;
next = normalizeBBox(item.getBBox());
next = util.normalizeBBox(item.getBBox());
path = `M${prev.ax2},${prev.ay}H${next.ax}`;
prev = next;
+2 -2
View File
@@ -1,4 +1,4 @@
import { customEvent, normalizeBBox } from '../../util.js';
import util from '../../util.js';
import _ from 'lodash';
import Q from 'q';
@@ -107,7 +107,7 @@ export default class Node {
this.state.renderCounter--;
document.body.dispatchEvent(customEvent('updateStatus', {
document.body.dispatchEvent(util.customEvent('updateStatus', {
percentage: (this.state.maxCounter - this.state.renderCounter) / this.state.maxCounter
}));
+2 -2
View File
@@ -1,4 +1,4 @@
import { spaceVertically } from '../../util.js';
import util from '../../util.js';
import _ from 'lodash';
import Q from 'q';
@@ -20,7 +20,7 @@ export default {
var containerBox,
paths;
spaceVertically(this.matches, {
util.spaceVertically(this.matches, {
padding: 5
});
+2 -2
View File
@@ -1,4 +1,4 @@
import { customEvent } from './util.js';
import util from './util.js';
import Parser from './parser/javascript.js';
import Snap from 'snapsvg';
import Q from 'q';
@@ -27,7 +27,7 @@ export default class Regexper {
event.preventDefault();
}
this.form.dispatchEvent(customEvent('submit'));
this.form.dispatchEvent(util.customEvent('submit'));
}
}
+4 -4
View File
@@ -1,6 +1,6 @@
import _ from 'lodash';
export function customEvent(name, detail) {
function customEvent(name, detail) {
var evt = document.createEvent('Event');
evt.initEvent(name, true, true);
evt.detail = detail;
@@ -8,7 +8,7 @@ export function customEvent(name, detail) {
}
export function normalizeBBox(box) {
function normalizeBBox(box) {
return _.extend({
ax: box.x,
ax2: box.x2,
@@ -16,7 +16,7 @@ export function normalizeBBox(box) {
}, box);
}
export function spaceHorizontally(items, options) {
function spaceHorizontally(items, options) {
var verticalCenter = 0;
options = _.defaults(options || {}, {
@@ -44,7 +44,7 @@ export function spaceHorizontally(items, options) {
}
}
export function spaceVertically(items, options) {
function spaceVertically(items, options) {
var horizontalCenter = 0;
options = _.defaults(options || {}, {