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

Unified Diff: appengine/swarming/ui/test/js/test-alias.js

Issue 2419613002: Add basic swarming UI tests
Patch Set: Make sure symlink isn't followed for uploading Created 4 years, 2 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 | « appengine/swarming/ui/test/common/test-pageable-data.html ('k') | appengine/swarming/ui/wct.conf.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/swarming/ui/test/js/test-alias.js
diff --git a/appengine/swarming/ui/test/js/test-alias.js b/appengine/swarming/ui/test/js/test-alias.js
new file mode 100644
index 0000000000000000000000000000000000000000..465036e49fc45500464858b62e364b0aa8e26259
--- /dev/null
+++ b/appengine/swarming/ui/test/js/test-alias.js
@@ -0,0 +1,41 @@
+// Copyright 2016 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+suite("swarming.alias", function() {
+ test("is defined", function() {
+ assert.isOk(swarming.alias)
+ assert.typeOf(swarming.alias, "object");
+ });
+ test("has all known aliases defined", function() {
+ swarming.alias.DIMENSIONS_WITH_ALIASES.forEach(function(a){
+ assert(swarming.alias.has(a));
+ });
+ });
+ test("applying alias of known type", function() {
+ assert.equal(swarming.alias.apply("foster", "device_type"), "NVIDIA Shield (foster)");
+ assert.equal(swarming.alias.apply("10de:08a4", "gpu"), "NVIDIA GeForce 320M (10de:08a4)");
+ assert.equal(swarming.alias.apply("4", "battery_health"), "Dead (4)");
+ });
+ test("applying unknown alias of known type", function() {
+ assert.equal(swarming.alias.apply("fosterz", "device_type"), "fosterz");
+ assert.equal(swarming.alias.apply("10de:08a4z", "gpu"), "10de:08a4z");
+ assert.equal(swarming.alias.apply("4z", "battery_health"), "4z");
+ });
+ test("applying custom alias", function() {
+ assert.equal(swarming.alias.apply("alpha", "beta"), "beta (alpha)");
+ });
+
+ test("unapplying well formed alias", function() {
+ assert.equal(swarming.alias.unapply("NVIDIA Shield (foster)"), "foster");
+ assert.equal(swarming.alias.unapply("NVIDIA GeForce 320M (10de:08a4)"), "10de:08a4");
+ assert.equal(swarming.alias.unapply("Dead (4)"), "4");
+ assert.equal(swarming.alias.unapply("beta (alpha)"), "alpha");
+ });
+ test("unapplying not an alias", function() {
+ assert.equal(swarming.alias.unapply("alpha-beta-gamma"), "alpha-beta-gamma");
+ assert.equal(swarming.alias.unapply(""), "");
+ assert.equal(swarming.alias.unapply(undefined), undefined);
+ assert.deepEqual(swarming.alias.unapply([1,2,3,4]), [1,2,3,4]);
+ });
+});
« no previous file with comments | « appengine/swarming/ui/test/common/test-pageable-data.html ('k') | appengine/swarming/ui/wct.conf.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698