+});
+
+describe("Check SortBy options", function () {
+ var $ = mkws.$;
+
+ it("show per page", function () {
+ if (!jasmine_config.check_sortby) {
+ debug("ignore check for sort by");
+ return;
+ }
+
+ var waitcount = 0;
+ var sort_value = 'title:1';
+ var per_page_number = 20;
+ var title_list_old = title_list("xxx ");
+
+ function title_list(prefix) {
+ var list = [];
+ var terms = $("div.mkwsRecords > div.mkwsSummary > a");
+ for (var i = 0; i < terms.length; i++) {
+ var term = $(terms[i]).text();
+ list.push(term);
+ // debug(prefix + "title: " + term);
+ }
+ return list;
+ }
+
+ runs(function () {
+ $("div.mkwsRecords").bind("DOMNodeInserted DOMNodeRemoved propertychange", function () {
+ waitcount++;
+ debug("DOM change mkwsRecords, sort by: " + waitcount);
+ });
+
+ var select = $("select.mkwsSort option[selected='selected']");
+ debug("Sort by default is: " + select.text() + " and unselect it");
+ select.removeAttr('selected');
+
+ select = $("select.mkwsSort option[value='" + sort_value + "']").attr('selected', true);
+ debug("sort by is set to: " + select.text());
+ select.trigger("change");
+ });
+
+ waitsFor(function () {
+ //debug("wait for2: " + waitcount);
+ return waitcount >= (per_page_number + 10) ? true : false;
+ }, "DOM change mkwsRecords, by sort page", 3 * jasmine_config.second);
+
+ runs(function () {
+ $("div.mkwsRecords").unbind("DOMNodeInserted DOMNodeRemoved propertychange");
+ debug("unbind by sort");
+
+ var records = $("div.mkwsRecords > div.mkwsSummary > a");
+ debug("Sort by got now " + records.length + " records");
+ expect(records.length).toBe(per_page_number);
+ });
+
+ runs(function () {
+ var title_list_new = title_list("yyy ");
+ var diff_flag = 0;
+ for (var i = 0; i < title_list_old.length; i++) {
+ debug(title_list_old[i] + " :: " + title_list_new[i]);
+
+ if (title_list_old[i] != title_list_new[i]) {
+ diff_flag++;
+ }
+ }
+ debug("Title changes: " + diff_flag + " out of " + per_page_number);
+ expect(diff_flag).not.toBe(0);
+ });
+ });
+});