Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Yaxel Perez
jio
Commits
40764fad
Commit
40764fad
authored
Feb 13, 2019
by
Yaxel Perez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
making the stuff use promises like it's supposed to
parent
d21cdad4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
43 deletions
+53
-43
src/jio.storage/liststorage.js
src/jio.storage/liststorage.js
+11
-6
src/jio.storage/nocapacitystorage.js
src/jio.storage/nocapacitystorage.js
+1
-1
test/jio.storage/liststorage.tests.js
test/jio.storage/liststorage.tests.js
+26
-17
test/jio.storage/nocapacitystorage.tests.js
test/jio.storage/nocapacitystorage.tests.js
+15
-19
No files found.
src/jio.storage/liststorage.js
View file @
40764fad
...
@@ -15,16 +15,19 @@
...
@@ -15,16 +15,19 @@
"
type
"
:
"
indexeddb
"
,
"
type
"
:
"
indexeddb
"
,
"
database
"
:
randomId
()
"
database
"
:
randomId
()
});
});
this
.
_signature_storage
.
p
os
t
(
"
_
"
,
{
this
.
_signature_storage
.
p
u
t
(
"
_
"
,
{
list
:
[]
list
:
[]
});
});
}
}
ListStorage
.
prototype
.
post
=
function
()
{
ListStorage
.
prototype
.
post
=
function
()
{
console
.
log
(
'
alright alright alright alright alright ok now ladies
'
);
var
id
=
this
.
_sub_storage
.
post
.
apply
(
this
.
_sub_storage
,
arguments
);
var
id
=
this
.
_sub_storage
.
post
.
apply
(
this
.
_sub_storage
,
arguments
),
this
.
_signature_storage
.
get
(
'
_
'
).
then
(
function
(
storage
)
{
updated_list
=
this
.
_signature_storage
.
get
(
"
_
"
).
list
.
concat
(
id
);
this
.
_signature_storage
.
put
(
'
_
'
,
{
list
:
storage
.
list
.
concat
(
id
)
});
this
.
_signature_storage
.
put
(
"
_
"
,
{
list
:
updated_list
});
}).
fail
(
function
(
err
)
{
throw
err
;
});
return
id
;
};
};
ListStorage
.
prototype
.
get
=
function
()
{
ListStorage
.
prototype
.
get
=
function
()
{
...
@@ -42,7 +45,9 @@
...
@@ -42,7 +45,9 @@
};
};
ListStorage
.
prototype
.
list
=
function
()
{
ListStorage
.
prototype
.
list
=
function
()
{
return
this
.
_sub_storage
.
get
(
"
_
"
).
list
;
return
this
.
_sub_storage
.
get
(
"
_
"
).
then
(
function
(
storage
)
{
return
storage
.
list
;
});
};
};
jIO
.
addStorage
(
"
list
"
,
ListStorage
);
jIO
.
addStorage
(
"
list
"
,
ListStorage
);
...
...
src/jio.storage/nocapacitystorage.js
View file @
40764fad
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
console
.
log
(
"
Nocapacity
"
);
console
.
log
(
"
Nocapacity
"
);
function
NoCapacityStorage
(
spec
)
{
function
NoCapacityStorage
(
spec
)
{
this
.
sub_storage
=
jIO
.
createJIO
(
spec
.
sub_storage
);
this
.
_
sub_storage
=
jIO
.
createJIO
(
spec
.
sub_storage
);
}
}
NoCapacityStorage
.
prototype
.
hasCapacity
=
function
()
{
NoCapacityStorage
.
prototype
.
hasCapacity
=
function
()
{
...
...
test/jio.storage/liststorage.tests.js
View file @
40764fad
...
@@ -14,25 +14,34 @@
...
@@ -14,25 +14,34 @@
QUnit
.
expect
(
0
);
QUnit
.
expect
(
0
);
});
});
// line is too long (>80) if I don't do this weird indenting
QUnit
.
test
(
'
list method returns ordered list of ids
'
,
function
(
assert
)
{
QUnit
.
test
(
QUnit
.
stop
();
"
Storage list method returns ordered list of ids
"
,
QUnit
.
expect
(
1
);
function
(
assert
)
{
var
storage
=
jIO
.
createJIO
({
var
jio
=
jIO
.
createJIO
({
type
:
"
list
"
,
type
:
'
list
'
,
sub_storage
:
{
type
:
'
uuid
'
,
sub_storage
:
{
sub_storage
:
{
type
:
"
uuid
"
,
type
:
'
memory
'
sub_storage
:
{
type
:
"
memory
"
,
}
}
}
}
),
}
ids
=
RSVP
.
all
([
storage
.
post
(),
storage
.
post
(),
storage
.
post
()]);
}),
ids
=
[
jio
.
post
({}),
jio
.
post
({}),
jio
.
post
({})];
ids
.
then
(
function
(
values
)
{
RSVP
.
all
(
ids
).
then
(
});
function
(
values
)
{
}
jio
.
list
().
then
(
function
(
list
)
{
);
QUnit
.
start
();
assert
.
equal
(
values
,
jio
.
list
());
}).
fail
(
function
(
err
)
{
assert
.
ok
(
false
,
err
);
});
}
).
fail
(
function
(
err
)
{
QUnit
.
start
();
assert
.
ok
(
false
,
err
);
});
});
}(
jIO
,
RSVP
,
QUnit
));
}(
jIO
,
RSVP
,
QUnit
));
test/jio.storage/nocapacitystorage.tests.js
View file @
40764fad
...
@@ -2,17 +2,6 @@
...
@@ -2,17 +2,6 @@
(
function
(
jIO
,
QUnit
)
{
(
function
(
jIO
,
QUnit
)
{
"
use strict
"
;
"
use strict
"
;
function
TestStorage
()
{
return
this
;
}
TestStorage
.
prototype
.
get
=
function
()
{
return
true
;
};
TestStorage
.
prototype
.
post
=
function
()
{
return
true
;
};
TestStorage
.
prototype
.
put
=
function
()
{
return
true
;
};
TestStorage
.
prototype
.
remove
=
function
()
{
return
true
;
};
jIO
.
addStorage
(
'
teststorage
'
,
TestStorage
);
module
(
"
NoCapacityStorage
"
);
module
(
"
NoCapacityStorage
"
);
QUnit
.
test
(
'
Constructor does not crash
'
,
function
()
{
QUnit
.
test
(
'
Constructor does not crash
'
,
function
()
{
...
@@ -20,7 +9,7 @@
...
@@ -20,7 +9,7 @@
type
:
"
nocapacity
"
,
type
:
"
nocapacity
"
,
schema
:
{
'
date
'
:
{
'
type
'
:
'
string
'
,
format
:
'
date-time
'
}},
schema
:
{
'
date
'
:
{
'
type
'
:
'
string
'
,
format
:
'
date-time
'
}},
sub_storage
:
{
sub_storage
:
{
type
:
'
teststorage
'
type
:
'
memory
'
}
}
});
});
QUnit
.
expect
(
0
);
QUnit
.
expect
(
0
);
...
@@ -31,7 +20,7 @@
...
@@ -31,7 +20,7 @@
type
:
"
nocapacity
"
,
type
:
"
nocapacity
"
,
schema
:
{
'
date
'
:
{
'
type
'
:
'
string
'
,
format
:
'
date-time
'
}},
schema
:
{
'
date
'
:
{
'
type
'
:
'
string
'
,
format
:
'
date-time
'
}},
sub_storage
:
{
sub_storage
:
{
type
:
'
teststorage
'
type
:
'
memory
'
}
}
});
});
assert
.
throws
(
assert
.
throws
(
...
@@ -40,17 +29,24 @@
...
@@ -40,17 +29,24 @@
});
});
QUnit
.
test
(
'
Storage calls sub-storage methods
'
,
function
(
assert
)
{
QUnit
.
test
(
'
Storage calls sub-storage methods
'
,
function
(
assert
)
{
QUnit
.
stop
();
QUnit
.
expect
(
1
);
var
jio
=
jIO
.
createJIO
({
var
jio
=
jIO
.
createJIO
({
type
:
"
nocapacity
"
,
type
:
"
nocapacity
"
,
schema
:
{
'
date
'
:
{
'
type
'
:
'
string
'
,
format
:
'
date-time
'
}},
sub_storage
:
{
sub_storage
:
{
type
:
'
teststorage
'
type
:
'
memory
'
}
}
});
});
assert
.
ok
(
jio
.
get
(
"
fake id
"
));
assert
.
ok
(
jio
.
post
());
jio
.
put
(
"
test_id
"
,
{
foo
:
"
bar
"
});
assert
.
ok
(
jio
.
put
(
"
fake id
"
));
jio
.
get
(
"
test_id
"
).
then
(
function
(
val
)
{
assert
.
ok
(
jio
.
remove
(
"
fake id
"
));
QUnit
.
start
();
assert
.
deepEqual
(
val
,
{
foo
:
"
bar
"
});
}).
fail
(
function
(
err
)
{
QUnit
.
start
();
assert
.
ok
(
false
,
err
);
});
});
});
}(
jIO
,
QUnit
));
}(
jIO
,
QUnit
));
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment