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

Unified Diff: chrome/browser/web_dev_style/js_checker_test.py

Issue 2209053002: Add a presubmit check for element.$.localId (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stricter Created 4 years, 4 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/browser/web_dev_style/js_checker.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/web_dev_style/js_checker_test.py
diff --git a/chrome/browser/web_dev_style/js_checker_test.py b/chrome/browser/web_dev_style/js_checker_test.py
index a8f6336203754613f9653943120c957a203b1414..185ed05af78af7e285b351642e932ac1f5e96afc 100755
--- a/chrome/browser/web_dev_style/js_checker_test.py
+++ b/chrome/browser/web_dev_style/js_checker_test.py
@@ -240,6 +240,38 @@ class JsCheckerTest(SuperMoxTestBase):
for line in lines:
self.ShouldPassInheritDocCheck(line)
+ def ShouldFailPolymerLocalIdCheck(self, line):
+ """Checks that element.$.localId check marks |line| as a style error."""
+ error = self.checker.PolymerLocalIdCheck(1, line)
+ self.assertNotEqual('', error,
+ msg='Should be flagged as a style error: ' + line)
+ self.assertTrue('.$' in test_util.GetHighlight(line, error))
+
+ def ShouldPassPolymerLocalIdCheck(self, line):
+ """Checks that element.$.localId check doesn't mark |line| as a style
+ error."""
+ self.assertEqual('', self.checker.PolymerLocalIdCheck(1, line),
+ msg='Should not be flagged as a style error: ' + line)
+
+ def testPolymerLocalIdFails(self):
+ lines = [
+ "cat.$.dog",
+ "thing1.$.thing2",
+ "element.$.localId",
+ "element.$['fancy-hyphenated-id']",
+ ]
+ for line in lines:
+ self.ShouldFailPolymerLocalIdCheck(line)
+
+ def testPolymerLocalIdPasses(self):
+ lines = [
+ "this.$.id",
+ "this.$.localId",
+ "this.$['fancy-id']",
+ ]
+ for line in lines:
+ self.ShouldPassPolymerLocalIdCheck(line)
+
def ShouldFailWrapperTypeCheck(self, line):
"""Checks that the use of wrapper types (i.e. new Number(), @type {Number})
is a style error.
« no previous file with comments | « chrome/browser/web_dev_style/js_checker.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698