summaryrefslogtreecommitdiff
path: root/www/lib/localforage/typing-tests
diff options
context:
space:
mode:
authorPliable Pixels <pliablepixels@gmail.com>2017-09-27 11:39:30 -0400
committerPliable Pixels <pliablepixels@gmail.com>2017-09-27 11:39:30 -0400
commite18708f10b04455be151a5a799f0109c34f20a25 (patch)
tree9e4559ef0fff8b366474e7768308ddca1e32268a /www/lib/localforage/typing-tests
parent97a1cb3ae199c7b5455dcba0001efd5b4c32040a (diff)
package updates to set up bower correctly #535
Diffstat (limited to 'www/lib/localforage/typing-tests')
-rw-r--r--www/lib/localforage/typing-tests/localforage-tests.ts128
-rw-r--r--www/lib/localforage/typing-tests/tsconfig.json19
2 files changed, 147 insertions, 0 deletions
diff --git a/www/lib/localforage/typing-tests/localforage-tests.ts b/www/lib/localforage/typing-tests/localforage-tests.ts
new file mode 100644
index 00000000..9cfe8ecf
--- /dev/null
+++ b/www/lib/localforage/typing-tests/localforage-tests.ts
@@ -0,0 +1,128 @@
+/// <reference path="../typings/localforage.d.ts" />
+
+declare let localForage: LocalForage;
+
+namespace LocalForageTest {
+ localForage.clear((err: any) => {
+ let newError: any = err;
+ });
+
+ localForage.getSerializer().then((s: LocalForageSerializer) => {
+ let serializer: LocalForageSerializer = s;
+ typeof serializer.bufferToString === "function";
+ typeof serializer.deserialize === "function";
+ typeof serializer.serialize === "function";
+ typeof serializer.stringToBuffer === "function";
+ });
+
+ localForage.iterate((str: string, key: string, num: number) => {
+ let newStr: string = str;
+ let newKey: string = key;
+ let newNum: number = num;
+ });
+
+ localForage.length((err: any, num: number) => {
+ let newError: any = err;
+ let newNumber: number = num;
+ });
+
+ localForage.length().then((num: number) => {
+ var newNumber: number = num;
+ });
+
+ localForage.key(0, (err: any, value: string) => {
+ let newError: any = err;
+ let newValue: string = value;
+ });
+
+ localForage.keys((err: any, keys: Array<string>) => {
+ let newError: any = err;
+ let newArray: Array<string> = keys;
+ });
+
+ localForage.keys().then((keys: Array<string>) => {
+ var newArray: Array<string> = keys;
+ });
+
+ localForage.getItem("key",(err: any, str: string) => {
+ let newError: any = err;
+ let newStr: string = str
+ });
+
+ localForage.getItem<string>("key").then((str: string) => {
+ let newStr: string = str;
+ });
+
+ localForage.setItem("key", "value",(err: any, str: string) => {
+ let newError: any = err;
+ let newStr: string = str
+ });
+
+ localForage.setItem("key", "value").then((str: string) => {
+ let newStr: string = str;
+ });
+
+ localForage.removeItem("key",(err: any) => {
+ let newError: any = err;
+ });
+
+ localForage.removeItem("key").then(() => {
+ });
+
+ localForage.getDriver("CustomDriver").then((result: LocalForageDriver) => {
+ var driver: LocalForageDriver = result;
+ // we need to use a variable for proper type guards before TS 2.0
+ var _support = driver._support;
+ if (typeof _support === "function") {
+ // _support = _support.bind(driver);
+ _support().then((result: boolean) => {
+ let doesSupport: boolean = result;
+ });
+ } else if (typeof _support === "boolean") {
+ let doesSupport: boolean = _support;
+ }
+ });
+
+ {
+ let config: boolean;
+
+ config = localForage.config({
+ name: "testyo",
+ driver: localForage.LOCALSTORAGE
+ });
+ }
+
+ {
+ let store: LocalForage;
+
+ store = localForage.createInstance({
+ name: "da instance",
+ driver: localForage.LOCALSTORAGE
+ });
+ }
+
+ {
+ let testSerializer: LocalForageSerializer;
+
+ localForage.getSerializer()
+ .then((serializer: LocalForageSerializer) => {
+ testSerializer = serializer;
+ });
+
+ localForage.getSerializer((serializer: LocalForageSerializer) => {
+ testSerializer = serializer;
+ });
+ }
+
+ {
+ localForage.ready().then(() => {});
+
+ localForage.ready((error) => {
+ if (error) {
+
+ } else {
+
+ }
+ });
+ }
+}
diff --git a/www/lib/localforage/typing-tests/tsconfig.json b/www/lib/localforage/typing-tests/tsconfig.json
new file mode 100644
index 00000000..cf7c2bf4
--- /dev/null
+++ b/www/lib/localforage/typing-tests/tsconfig.json
@@ -0,0 +1,19 @@
+{
+ "compileOnSave": false,
+ "compilerOptions": {
+ "lib": [
+ "dom",
+ "es2015"
+ ],
+ "module": "es2015",
+ "moduleResolution": "node",
+ "noEmit": true,
+ "noImplicitAny": true,
+ "strictNullChecks": true,
+ "target": "es5"
+ },
+ "files": [
+ "../typings/localforage.d.ts",
+ "./localforage-tests.ts"
+ ]
+}