forked from 0x2620/pandora
move js files from js/pandora to js, fixes #1366
This commit is contained in:
parent
b5eda32bbd
commit
a9b7738aa8
104 changed files with 7 additions and 2 deletions
58
static/js/tests.js
Normal file
58
static/js/tests.js
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
||||
'use strict';
|
||||
|
||||
pandora.tests = function() {
|
||||
var tests = [];
|
||||
pandora.api.find({
|
||||
query: {conditions: [{key: 'rendered', value: true, operator: '='}], operator: '&'},
|
||||
sort: [{key: 'random', operator:'+'}],
|
||||
keys: ['id', 'duration'],
|
||||
range: [0, 10]
|
||||
}, function(result) {
|
||||
var item = result.data.items.filter(function(item) { return item.duration > 300; })[0],
|
||||
position = 60;
|
||||
pandora.UI.set('videoPoints.' + item.id, {
|
||||
annotation: '',
|
||||
'in': position,
|
||||
out: position,
|
||||
position: position
|
||||
});
|
||||
pandora.UI.set({item: item.id, itemView: 'player'});
|
||||
test('set item', pandora.user.ui.item, item.id);
|
||||
startPlayback();
|
||||
function startPlayback() {
|
||||
if (pandora.$ui.player) {
|
||||
pandora.$ui.player.options({paused: false});
|
||||
setTimeout(function() {
|
||||
pandora.$ui.player.options({paused: true});
|
||||
test('video position increased after playback', pandora.user.ui.videoPoints[item.id].position > position, true);
|
||||
results();
|
||||
}, 5000);
|
||||
} else {
|
||||
setTimeout(startPlayback, 500);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function test(title, actual, expected) {
|
||||
tests.push({
|
||||
actual: actual,
|
||||
expected: expected,
|
||||
passed: Ox.isEqual(actual, expected),
|
||||
title: title
|
||||
})
|
||||
}
|
||||
|
||||
function results() {
|
||||
var passed = tests.filter(function(test) {
|
||||
return test.passed;
|
||||
}).length,
|
||||
failed = tests.length - passed;
|
||||
Ox.print(JSON.stringify({
|
||||
tests: tests.length,
|
||||
passed: passed,
|
||||
failed: failed,
|
||||
results: tests
|
||||
}, null, ' '));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue