Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export var testInvalidKey = function () {
try {
appSettings.hasKey(undefined);
TKUnit.assert(false, "There is a key undefined");
}
catch (e) {
// we should receive an exception here
}
try {
appSettings.hasKey(null);
TKUnit.assert(false, "There is a key null");
}
catch (e) {
// we should receive an exception here
}
try {
appSettings.hasKey(123);
TKUnit.assert(false, "There is a key undefined");
}
catch (e) {
// we should receive an exception here
}
try {
appSettings.hasKey(null);
TKUnit.assert(false, "There is a key null");
}
catch (e) {
// we should receive an exception here
}
try {
appSettings.hasKey(123);
TKUnit.assert(false, "There is a key number");
}
catch (e) {
// we should receive an exception here
}
appSettings.hasKey("string");
};
export var testInvalidKey = function () {
try {
appSettings.hasKey(undefined);
TKUnit.assert(false, "There is a key undefined");
}
catch (e) {
// we should receive an exception here
}
try {
appSettings.hasKey(null);
TKUnit.assert(false, "There is a key null");
}
catch (e) {
// we should receive an exception here
}
try {
appSettings.hasKey(123);
TKUnit.assert(false, "There is a key number");
}
catch (e) {
// we should receive an exception here
}
appSettings.hasKey("string");
};
export var testHasKey = function () {
var hasKey = appSettings.hasKey("noBoolKey");
// will return false if there is no value for "noBoolKey"
TKUnit.assert(!hasKey, "There is a key: " + noBoolKey);
TKUnit.assert(!appSettings.hasKey(noStringKey), "There is a key: " + noStringKey);
TKUnit.assert(!appSettings.hasKey(noNumberKey), "There is a key: " + noNumberKey);
TKUnit.assert(appSettings.hasKey(boolKey), "There is no key: " + boolKey);
TKUnit.assert(appSettings.hasKey(stringKey), "There is no key: " + stringKey);
TKUnit.assert(appSettings.hasKey(numberKey), "There is no key: " + numberKey);
};
export var testHasKey = function () {
var hasKey = appSettings.hasKey("noBoolKey");
// will return false if there is no value for "noBoolKey"
TKUnit.assert(!hasKey, "There is a key: " + noBoolKey);
TKUnit.assert(!appSettings.hasKey(noStringKey), "There is a key: " + noStringKey);
TKUnit.assert(!appSettings.hasKey(noNumberKey), "There is a key: " + noNumberKey);
TKUnit.assert(appSettings.hasKey(boolKey), "There is no key: " + boolKey);
TKUnit.assert(appSettings.hasKey(stringKey), "There is no key: " + stringKey);
TKUnit.assert(appSettings.hasKey(numberKey), "There is no key: " + numberKey);
};
export var testHasKey = function () {
var hasKey = appSettings.hasKey("noBoolKey");
// will return false if there is no value for "noBoolKey"
TKUnit.assert(!hasKey, "There is a key: " + noBoolKey);
TKUnit.assert(!appSettings.hasKey(noStringKey), "There is a key: " + noStringKey);
TKUnit.assert(!appSettings.hasKey(noNumberKey), "There is a key: " + noNumberKey);
TKUnit.assert(appSettings.hasKey(boolKey), "There is no key: " + boolKey);
TKUnit.assert(appSettings.hasKey(stringKey), "There is no key: " + stringKey);
TKUnit.assert(appSettings.hasKey(numberKey), "There is no key: " + numberKey);
};
export var testFlush = function () {
appSettings.setString(stringKey, "String value");
var flushed = appSettings.flush();
// will return boolean indicating whether flush to disk was successful
TKUnit.assert(flushed, "Flush failed: " + flushed);
TKUnit.assert(appSettings.hasKey(stringKey), "There is no key: " + stringKey);
};
export var testClear = function () {
appSettings.clear();
TKUnit.assert(!appSettings.hasKey(boolKey), "Failed to remove key: " + boolKey);
TKUnit.assert(!appSettings.hasKey(stringKey), "Failed to remove key: " + stringKey);
TKUnit.assert(!appSettings.hasKey(numberKey), "Failed to remove key: " + numberKey);
};
export var testClear = function () {
appSettings.clear();
TKUnit.assert(!appSettings.hasKey(boolKey), "Failed to remove key: " + boolKey);
TKUnit.assert(!appSettings.hasKey(stringKey), "Failed to remove key: " + stringKey);
TKUnit.assert(!appSettings.hasKey(numberKey), "Failed to remove key: " + numberKey);
};
export var testRemove = function () {
appSettings.remove("boolKey");
TKUnit.assert(!appSettings.hasKey(boolKey), "Failed to remove key: " + boolKey);
appSettings.remove(stringKey);
TKUnit.assert(!appSettings.hasKey(stringKey), "Failed to remove key: " + stringKey);
appSettings.remove(numberKey);
TKUnit.assert(!appSettings.hasKey(numberKey), "Failed to remove key: " + numberKey);
};