Skip to content
Snippets Groups Projects
Commit 9249922b authored by Eugen Ciur's avatar Eugen Ciur
Browse files

add test function for rearange_items

parent cf8cf375
Branches
No related tags found
No related merge requests found
...@@ -2,6 +2,20 @@ import { module, test } from 'qunit'; ...@@ -2,6 +2,20 @@ import { module, test } from 'qunit';
import { get_id, reposition_items } from 'papermerge/utils/array'; import { get_id, reposition_items } from 'papermerge/utils/array';
class Page {
constructor(page_id) {
this.id = page_id;
}
get() {
return this.id;
}
toString() {
return `Page(${this.id})`;
}
}
module('Unit | Utils | Array', function () { module('Unit | Utils | Array', function () {
test('get_id 1', function (assert) { test('get_id 1', function (assert) {
...@@ -23,5 +37,32 @@ module('Unit | Utils | Array', function () { ...@@ -23,5 +37,32 @@ module('Unit | Utils | Array', function () {
assert.strictEqual(get_id(item), 13); assert.strictEqual(get_id(item), 13);
}); });
test('reposition_items 1', function(assert) {
let items,
selected_ids = ['2'],
drop_pos = 0,
actual_result,
expected_result;
items = [
new Page('1'), new Page('2'), new Page('3'), new Page('4')
];
expected_result = [
new Page('2'), new Page('1'), new Page('3'), new Page('4')
]
actual_result = reposition_items({
items, selected_ids, drop_pos
});
assert.expect( expected_result.length );
expected_result.forEach((page, index) => {
assert.strictEqual(page.id, actual_result[index].id);
});
});
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment