Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2944)

Unified Diff: chrome/test/data/webui/test_api.js

Issue 23477006: Unit tests for utility.js (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing unit test + more arv@ comments Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/test_api.js
diff --git a/chrome/test/data/webui/test_api.js b/chrome/test/data/webui/test_api.js
index 6bf21775e2e49e6fedada2cc0cfb97356b50ecda..4974933c31d45cf6eb8906262d74704e9809a409 100644
--- a/chrome/test/data/webui/test_api.js
+++ b/chrome/test/data/webui/test_api.js
@@ -1628,9 +1628,9 @@ var testing = {};
}
/**
- * Mock4JS matcher object that matches the actual agrument and the expected
+ * Mock4JS matcher object that matches the actual argument and the expected
* value iff their JSON represenations are same.
- * @param {Object} expectedValue Expected value.
+ * @param {Object} expectedValue
* @constructor
*/
function MatchJSON(expectedValue) {
@@ -1659,14 +1659,54 @@ var testing = {};
};
/**
- * Builds a MatchJSON agrument matcher for a given expected value.
- * @param {Object} expectedValue Expected value.
+ * Builds a MatchJSON argument matcher for a given expected value.
+ * @param {Object} expectedValue
* @return {MatchJSON} Resulting Mock4JS matcher.
*/
function eqJSON(expectedValue) {
return new MatchJSON(expectedValue);
}
+ /**
+ * Mock4JS matcher object that matches the actual argument and the expected
+ * value iff the the string representation of the actual argument is equal to
+ * the expected value.
+ * @param {string} expectedValue
+ * @constructor
+ */
+ function MatchToString(expectedValue) {
+ this.expectedValue_ = expectedValue;
+ }
+
+ MatchToString.prototype = {
+ /**
+ * Checks that the the string representation of the actual argument matches
+ * the expected value.
+ * @param {*} actualArgument The argument to match.
+ * @return {boolean} Result of the comparison.
+ */
+ argumentMatches: function(actualArgument) {
+ return this.expectedValue_ === String(actualArgument);
+ },
+
+ /**
+ * Describes the matcher.
+ * @return {string} Description of this Mock4JS matcher.
+ */
+ describe: function() {
+ return 'eqToString("' + this.expectedValue_ + '")';
+ },
+ };
+
+ /**
+ * Builds a MatchToString argument matcher for a given expected value.
+ * @param {Object} expectedValue
+ * @return {MatchToString} Resulting Mock4JS matcher.
+ */
+ function eqToString(expectedValue) {
+ return new MatchToString(expectedValue);
+ }
+
// Exports.
testing.Test = Test;
exports.testDone = testDone;
@@ -1684,6 +1724,7 @@ var testing = {};
exports.callFunctionWithSavedArgs = callFunctionWithSavedArgs;
exports.callGlobalWithSavedArgs = callGlobalWithSavedArgs;
exports.eqJSON = eqJSON;
+ exports.eqToString = eqToString;
exports.expectTrue = createExpect(assertTrue);
exports.expectFalse = createExpect(assertFalse);
exports.expectGE = createExpect(assertGE);
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698