summaryrefslogtreecommitdiffstats
path: root/addon-sdk/source/test/test-jetpack-id.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /addon-sdk/source/test/test-jetpack-id.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'addon-sdk/source/test/test-jetpack-id.js')
-rw-r--r--addon-sdk/source/test/test-jetpack-id.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/addon-sdk/source/test/test-jetpack-id.js b/addon-sdk/source/test/test-jetpack-id.js
new file mode 100644
index 000000000..99479e32d
--- /dev/null
+++ b/addon-sdk/source/test/test-jetpack-id.js
@@ -0,0 +1,64 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+var getID = require("jetpack-id/index");
+
+exports["test Returns GUID when `id` GUID"] = assert => {
+ var guid = "{8490ae4f-93bc-13af-80b3-39adf9e7b243}";
+ assert.equal(getID({ id: guid }), guid);
+};
+
+exports["test Returns domain id when `id` domain id"] = assert => {
+ var id = "my-addon@jetpack";
+ assert.equal(getID({ id: id }), id);
+};
+
+exports["test allows underscores in name"] = assert => {
+ var name = "my_addon";
+ assert.equal(getID({ name: name }), `@${name}`);
+};
+
+exports["test allows underscores in id"] = assert => {
+ var id = "my_addon@jetpack";
+ assert.equal(getID({ id: id }), id);
+};
+
+exports["test Returns valid name when `name` exists"] = assert => {
+ var id = "my-addon";
+ assert.equal(getID({ name: id }), `@${id}`);
+};
+
+
+exports["test Returns null when `id` and `name` do not exist"] = assert => {
+ assert.equal(getID({}), null)
+}
+
+exports["test Returns null when no object passed in"] = assert => {
+ assert.equal(getID(), null)
+}
+
+exports["test Returns null when `id` exists but not GUID/domain"] = assert => {
+ var id = "my-addon";
+ assert.equal(getID({ id: id }), null);
+}
+
+exports["test Returns null when `id` contains multiple @"] = assert => {
+ assert.equal(getID({ id: "my@addon@yeah" }), null);
+};
+
+exports["test Returns null when `id` or `name` specified in domain format but has invalid characters"] = assert => {
+ [" ", "!", "/", "$", " ", "~", "("].forEach(sym => {
+ assert.equal(getID({ id: "my" + sym + "addon@domain" }), null);
+ assert.equal(getID({ name: "my" + sym + "addon" }), null);
+ });
+};
+
+exports["test Returns null, does not crash, when providing non-string properties for `name` and `id`"] = assert => {
+ assert.equal(getID({ id: 5 }), null);
+ assert.equal(getID({ name: 5 }), null);
+ assert.equal(getID({ name: {} }), null);
+};
+
+require("sdk/test").run(exports);