This is the template project that's checked out and configured when you run the bando-up command from ljsthw-bandolier. This is where the code really lives.
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.
bandolier-template/tests/models/media.js

44 lines
1.0 KiB

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);
}
})