Skip to content

Commit

Permalink
Configure testing for Travis-CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
schlosser committed May 17, 2015
1 parent 0c66891 commit fe95e54
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ node_js:
- "0.11"
- "0.10"
- "0.8"
- "0.6
- "0.6"
33 changes: 19 additions & 14 deletions src/replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,6 @@
return annotatedAction1.action.cost - annotatedAction2.action.cost;
}

/**
* Parse the array of raw sentence strings into an array of arrays of words.
*
* @param {string[]} rawSentences the sentences to parse
* @returns {string[][]} sentences the
*/
function _parseSentences(rawSentences) {
if (!rawSentences || typeof rawSentences !== "object") {
throw "rawSentences must be an array of strings.";
}
return rawSentences.map(_parseSentence);
}

/**
* Parse the raw sentence into an array of words.
*
Expand Down Expand Up @@ -217,6 +204,8 @@
* @param {bool} options.best - true if the sentences should be ordered to
* minimize the number of changes performed
* default: true
* @param {bool} options._testing - true if testing. sentences will be
* ignored
*/
function Replace(rawSentences, options) {
var self = this;
Expand All @@ -229,6 +218,7 @@
verbose: (opts.verbose !== undefined) ? opts.verbose : false,
random: (opts.random !== undefined) ? opts.random : false,
best: (opts.best !== undefined) ? opts.best : true,
_testing: (opts._testing !== undefined) ? opts._testing : false,
};
self.wrapper = document.getElementById(self.settings.containerId);
_injectStyle(self.settings.namespace, self.settings.speed / 1000, self.wrapper.offsetHeight);
Expand All @@ -239,10 +229,25 @@
self.visibleClass = " ." + self.settings.namespace + "-visible";
self.wrapperSelector = "#" + self.settings.namespace;
self._setupContainer();
self._setSentences(_parseSentences(rawSentences));
if (!self.settings._testing) {
self._setSentences(_parseSentences(rawSentences));
}
return this;
}

/**
* Parse the array of raw sentence strings into an array of arrays of words.
*
* @param {string[]} rawSentences the sentences to parse
* @returns {string[][]} sentences the
*/
Replace.prototype._parseSentences = function(rawSentences) {
if (!rawSentences || typeof rawSentences !== "object") {
throw "rawSentences must be an array of strings.";
}
return rawSentences.map(_parseSentence);
};

/**
* Find the container for the sentences, empty out any HTML that might be
* inside, and then give it the namespace class. It will be the root element
Expand Down
4 changes: 3 additions & 1 deletion test/ReplaceHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ function getReplaceInstance(id) {
div.id = id;
document.body.appendChild(div);
}
return new window.Replace([]);
return new window.Replace([], {
_testing: true
});
}

0 comments on commit fe95e54

Please sign in to comment.