-
Notifications
You must be signed in to change notification settings - Fork 26
/
rowColMove.tests.js
122 lines (103 loc) · 5.31 KB
/
rowColMove.tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/* eslint-env qunit */
/*eslint no-magic-numbers: 0*/
window.edittable = window.edittable || {};
(function (edittable) {
'use strict';
QUnit.module('Tests for edittable.moveRow and edittable.moveCol');
QUnit.test('edittable.moveRow 0 to 1', function (assert) {
var meta = [['a', 'b'], ['c', 'd'], ['e', 'f']];
var actual_meta = edittable.moveRow([0], 2, meta);
var expected_meta = [['c', 'd'], ['a', 'b'], ['e', 'f']];
assert.deepEqual(actual_meta, expected_meta);
});
QUnit.test('edittable.moveRow 0 to 2', function (assert) {
var meta = [['a', 'b'], ['c', 'd'], ['e', 'f']];
var actual_meta = edittable.moveRow([0], 3, meta);
var expected_meta = [['c', 'd'], ['e', 'f'], ['a', 'b']];
assert.deepEqual(actual_meta, expected_meta);
});
QUnit.test('edittable.moveRow 1 to 2', function (assert) {
var meta = [['a', 'b'], ['c', 'd'], ['e', 'f']];
var actual_meta = edittable.moveRow([1], 3, meta);
var expected_meta = [['a', 'b'], ['e', 'f'], ['c', 'd']];
assert.deepEqual(actual_meta, expected_meta);
});
QUnit.test('edittable.moveRow 2 to 1', function (assert) {
var meta = [['a', 'b'], ['c', 'd'], ['e', 'f']];
var actual_meta = edittable.moveRow([2], 1, meta);
var expected_meta = [['a', 'b'], ['e', 'f'], ['c', 'd']];
assert.deepEqual(actual_meta, expected_meta);
});
QUnit.test('edittable.moveRow 2 to 0', function (assert) {
var meta = [['a', 'b'], ['c', 'd'], ['e', 'f']];
var actual_meta = edittable.moveRow([2], 0, meta);
var expected_meta = [['e', 'f'], ['a', 'b'], ['c', 'd']];
assert.deepEqual(actual_meta, expected_meta);
});
QUnit.test('edittable.moveRow 1 to 0', function (assert) {
var meta = [['a', 'b'], ['c', 'd'], ['e', 'f']];
var actual_meta = edittable.moveRow([1], 0, meta);
var expected_meta = [['c', 'd'], ['a', 'b'], ['e', 'f']];
assert.deepEqual(actual_meta, expected_meta);
});
QUnit.test('edittable.moveRow [0,1] to 2', function (assert) {
var meta = [['a', 'b'], ['c', 'd'], ['e', 'f']];
var actual_meta = edittable.moveRow([0, 1], 3, meta);
var expected_meta = [['e', 'f'], ['a', 'b'], ['c', 'd']];
assert.deepEqual(actual_meta, expected_meta);
});
QUnit.test('edittable.moveRow [1, 2] to 0', function (assert) {
var meta = [['a', 'b'], ['c', 'd'], ['e', 'f']];
var actual_meta = edittable.moveRow([1, 2], 0, meta);
var expected_meta = [['c', 'd'], ['e', 'f'], ['a', 'b']];
assert.deepEqual(actual_meta, expected_meta);
});
QUnit.test('edittable.moveCol 0 to 1', function (assert) {
var meta = [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i']];
var actual_meta = edittable.moveCol([0], 2, meta);
var expected_meta = [['b', 'a', 'c'], ['e', 'd', 'f'], ['h', 'g', 'i']];
assert.deepEqual(actual_meta, expected_meta);
});
QUnit.test('edittable.moveCol 0 to 2', function (assert) {
var meta = [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i']];
var actual_meta = edittable.moveCol([0], 3, meta);
var expected_meta = [['b', 'c', 'a'], ['e', 'f', 'd'], ['h', 'i', 'g']];
assert.deepEqual(actual_meta, expected_meta);
});
QUnit.test('edittable.moveCol 1 to 2', function (assert) {
var meta = [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i']];
var actual_meta = edittable.moveCol([1], 3, meta);
var expected_meta = [['a', 'c', 'b'], ['d', 'f', 'e'], ['g', 'i', 'h']];
assert.deepEqual(actual_meta, expected_meta);
});
QUnit.test('edittable.moveCol 1 to 0', function (assert) {
var meta = [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i']];
var actual_meta = edittable.moveCol([1], 0, meta);
var expected_meta = [['b', 'a', 'c'], ['e', 'd', 'f'], ['h', 'g', 'i']];
assert.deepEqual(actual_meta, expected_meta);
});
QUnit.test('edittable.moveCol 2 to 0', function (assert) {
var meta = [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i']];
var actual_meta = edittable.moveCol([2], 0, meta);
var expected_meta = [['c', 'a', 'b'], ['f', 'd', 'e'], ['i', 'g', 'h']];
assert.deepEqual(actual_meta, expected_meta);
});
QUnit.test('edittable.moveCol 2 to 1', function (assert) {
var meta = [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i']];
var actual_meta = edittable.moveCol([2], 1, meta);
var expected_meta = [['a', 'c', 'b'], ['d', 'f', 'e'], ['g', 'i', 'h']];
assert.deepEqual(actual_meta, expected_meta);
});
QUnit.test('edittable.moveCol [0, 1] to 2', function (assert) {
var meta = [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i']];
var actual_meta = edittable.moveCol([0, 1], 3, meta);
var expected_meta = [['c', 'a', 'b'], ['f', 'd', 'e'], ['i', 'g', 'h']];
assert.deepEqual(actual_meta, expected_meta);
});
QUnit.test('edittable.moveCol [1, 2] to 0', function (assert) {
var meta = [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i']];
var actual_meta = edittable.moveCol([1, 2], 0, meta);
var expected_meta = [['b', 'c', 'a'], ['e', 'f', 'd'], ['h', 'i', 'g']];
assert.deepEqual(actual_meta, expected_meta);
});
}(window.edittable));