This is the code that runs https://bandolier.learnjsthehardway.com/ for you to review. It uses the https://git.learnjsthehardway.com/learn-javascript-the-hard-way/bandolier-template to create the documentation for the project.
https://bandolier.learnjsthehardway.com/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.0 KiB
44 lines
1.0 KiB
2 years ago
|
import test from "ava";
|
||
|
import { Media } from "../../lib/models.js";
|
||
|
|
||
|
test('test media model basics work', async (t) => {
|
||
|
try {
|
||
|
let test1 = await Media.insert({
|
||
|
"src": "/good.mp4",
|
||
|
"preload": "none",
|
||
|
"torrent_url": "/torrents/sample.torrent"
|
||
|
});
|
||
|
|
||
|
let test2 = await Media.first({id: test1.id});
|
||
|
t.is(test1.id, test2.id);
|
||
|
t.not(test2.src, undefined);
|
||
|
|
||
|
let count = await Media.count({id: test2.id});
|
||
|
t.is(count, 1);
|
||
|
|
||
|
let all = await Media.all({src: test1.src});
|
||
|
t.is(all.length, 1);
|
||
|
t.is(all[0].src, test1.src);
|
||
|
|
||
|
let res = await Media.update({id: test1.id}, {src: "/invalid.mp4"});
|
||
|
t.is(res, 1);
|
||
|
|
||
|
res = await Media.first({src: "/invalid.mp4"});
|
||
|
t.is(res.id, test2.id);
|
||
|
t.is(res.src, "/invalid.mp4");
|
||
|
|
||
|
res = await Media.delete({id: test2.id});
|
||
|
t.is(res, 1);
|
||
|
|
||
|
count = await Media.count({id: test2.id});
|
||
|
t.is(count, 0);
|
||
|
|
||
|
all = await Media.all({id: test2.id});
|
||
|
t.is(all.length, 0);
|
||
|
|
||
|
} catch (error) {
|
||
|
console.log(error);
|
||
|
t.fail(error.message);
|
||
|
}
|
||
|
})
|