| 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]);
|
| + });
|
| +});
|
|
|