Skip to content

Commit 61d0871

Browse files
added string sortable test
1 parent 87c38fe commit 61d0871

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

tests/integration/sortable/sortableTest.js

+45
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,51 @@ describe("Sortable tests", () => {
6565
chai.assert.equal(c, c1);
6666
});
6767

68+
const str_values = ["a", "az", "azzz", "b", "ba", "baaa", "o", "oe", "z", "zaaa"];
69+
const encrypted_values = [];
70+
71+
it("should encrypt a string", function() {
72+
for (let i = 0; i < str_values.length; i++) {
73+
const v = str_values[i];
74+
75+
encrypted_values.push(group.encryptSortableRawString(v));
76+
}
77+
78+
//check the number
79+
let past_item = BigInt(0);
80+
81+
for (let i = 0; i < encrypted_values.length; i++) {
82+
const item = encrypted_values[i];
83+
84+
chai.assert.equal(past_item < item, true);
85+
past_item = item;
86+
}
87+
});
88+
89+
it("should encrypt the same values", function() {
90+
const new_values = [];
91+
92+
for (let i = 0; i < str_values.length; i++) {
93+
const v = str_values[i];
94+
95+
new_values.push(group_for_user_1.encryptSortableRawString(v));
96+
}
97+
98+
//check the number
99+
let past_item = BigInt(0);
100+
101+
for (let i = 0; i < new_values.length; i++) {
102+
const item = new_values[i];
103+
const check_item = encrypted_values[i];
104+
105+
chai.assert.equal(past_item < item, true);
106+
107+
chai.assert.equal(check_item, item);
108+
109+
past_item = item;
110+
}
111+
});
112+
68113
after(async () => {
69114
//clean up
70115

0 commit comments

Comments
 (0)