<commit_before>/*global QUnit */
sap.ui.define([
	"sap/ui/qunit/utils/createAndAppendDiv",
	"sap/ui/core/util/MockServer",
	"sap/m/List",
	"sap/m/GrowingEnablement",
	"sap/ui/model/odata/ODataModel",
	"sap/ui/model/json/JSONModel",
	"sap/ui/model/Sorter",
	"sap/m/StandardListItem",
	"sap/m/CustomListItem",
	"sap/ui/core/HTML",
	"sap/m/Page"
], function(createAndAppendDiv, MockServer, List, GrowingEnablement, ODataModel, JSONModel, Sorter, StandardListItem, CustomListItem, HTML, Page) {
	"use strict";
	createAndAppendDiv("growing1");
	createAndAppendDiv("growing2");



	QUnit.module("trigger");
	QUnit.test("Should update the trigger state correctly", function(assert) {
		var done = assert.async();
		//Arrange
		var data = { items: [ {},{}] };

		var oModel = new JSONModel();
		oModel.setData(data);

		//System under Test
		var oList = new List({
			growing : true,
			growingThreshold: 1,
			items : {
				path : "/items",
				template : new CustomListItem({
					content : new HTML({content:'<div style="height: 10000px"></div>'})
				})
			}
		}).setModel(oModel);

		var oPage = new Page({
			title: "List Page",
			content : oList
		});

		oPage.placeAt("qunit-fixture");
		sap.ui.getCore().applyChanges();

		// sytem under test
		var oGrowingDelegate = oList._oGrowingDelegate;
		var oTrigger = oGrowingDelegate._oTrigger;

		// Act
		setTimeout(function() {
			assert.ok(oList.$("triggerList").is(":visible"), "Load more trigger is visible after initial rendering");

			// act + assert loading is started case
			oGrowingDelegate._updateTrigger(true);

			assert.ok(oTrigger.getBusy(), "Trigger shows the busy indicator");
			assert.ok(!oTrigger.$().hasClass("sapMLIBActive"), "Trigger is not active since it is busy");
			assert.ok(oTrigger.$().hasClass("sapMGrowingListBusyIndicatorVisible"), "Busy indicator visible class is added");
			assert.strictEqual(oList.$("triggerText").css("visibility"), "hidden", "Growing trigger text is hidden");
			assert.strictEqual(oList.$("triggerInfo").css("visibility"), "hidden", "Growing infor text is hidden");
			assert.ok(oList.$("triggerList").is(":visible"), "Load more trigger is visible");

			// act + assert loading is finished case for growingScrollToLoad=false
			oGrowingDelegate._updateTrigger(false);
			assert.ok(!oTrigger.getBusy(), "Trigger does not show the busy indicator");
			assert.ok(!oTrigger.$().hasClass("sapMGrowingListBusyIndicatorVisible"), "Busy indicator visible class is removed");
			assert.strictEqual(oList.$("triggerText").css("visibility"), "visible", "Growing trigger text is visible");
			assert.strictEqual(oList.$("triggerInfo").css("visibility"), "visible", "Growing info text is visible");
			assert.ok(oList.$("triggerList").is(":visible"), "Load more trigger is visible");

			// act + assert growingScrollToLoad=true
			oList.setGrowingScrollToLoad(true);
			sap.ui.getCore().applyChanges();
			assert.ok(oList.$("triggerList").is(":hidden"), "Load more trigger is not visible");

			// act + assert loading is started case for growingScrollToLoad=true
			oGrowingDelegate._updateTrigger(true);
			assert.ok(oTrigger.getBusy(), "Trigger shows the busy indicator");
			assert.ok(!oTrigger.$().hasClass("sapMLIBActive"), "Trigger is not active since it is busy");
			assert.ok(oTrigger.$().hasClass("sapMGrowingListBusyIndicatorVisible"), "Busy indicator visible class is added");
			assert.strictEqual(oList.$("triggerText").css("visibility"), "hidden", "Growing trigger text is hidden");
			assert.strictEqual(oList.$("triggerInfo").css("visibility"), "hidden", "Growing infor text is hidden");
			assert.ok(oList.$("triggerList").is(":visible"), "Load more trigger is visible");

			// act + assert loading is finished case for growingScrollToLoad=true
			oGrowingDelegate._updateTrigger(false);
			assert.ok(!oTrigger.getBusy(), "Trigger does not show the busy indicator");
			assert.ok(!oTrigger.$().hasClass("sapMGrowingListBusyIndicatorVisible"), "Busy indicator visible class is removed");
			assert.ok(!oList.$("triggerText").is(":visible"), "visible", "Growing trigger text is not visible");
			assert.ok(!oList.$("triggerInfo").css(":visible"), "visible", "Growing info text is not visible");
			assert.ok(!oList.$("triggerList").is(":visible"), "Load more trigger is not visible");

			// check for Growing trigger DOM
			assert.equal(oTrigger.TagName, "div", "Growing trigger has TagName as div");
			assert.ok(oTrigger.$().is("div"), "Growing trigger rendered as div in DOM");
			assert.ok(jQuery(".sapMSLITitle").is("span"), "More button rendered with span tag");
			assert.strictEqual(oTrigger.$().attr("role"), "button", "role=button");
			assert.strictEqual(oTrigger.$().attr("aria-selected"), undefined, "aria-selected attribute removed as role=button");

			// act + assert growingScrollToLoad=true
			oList.setGrowingScrollToLoad(false);
			sap.ui.getCore().applyChanges();<commit_msg>[INTERNAL] m.GrowingEnablement (test): fix wrong jQuery call<commit_after>/*global QUnit */
sap.ui.define([
	"sap/ui/qunit/utils/createAndAppendDiv",
	"sap/ui/core/util/MockServer",
	"sap/m/List",
	"sap/m/GrowingEnablement",
	"sap/ui/model/odata/ODataModel",
	"sap/ui/model/json/JSONModel",
	"sap/ui/model/Sorter",
	"sap/m/StandardListItem",
	"sap/m/CustomListItem",
	"sap/ui/core/HTML",
	"sap/m/Page"
], function(createAndAppendDiv, MockServer, List, GrowingEnablement, ODataModel, JSONModel, Sorter, StandardListItem, CustomListItem, HTML, Page) {
	"use strict";
	createAndAppendDiv("growing1");
	createAndAppendDiv("growing2");



	QUnit.module("trigger");
	QUnit.test("Should update the trigger state correctly", function(assert) {
		var done = assert.async();
		//Arrange
		var data = { items: [ {},{}] };

		var oModel = new JSONModel();
		oModel.setData(data);

		//System under Test
		var oList = new List({
			growing : true,
			growingThreshold: 1,
			items : {
				path : "/items",
				template : new CustomListItem({
					content : new HTML({content:'<div style="height: 10000px"></div>'})
				})
			}
		}).setModel(oModel);

		var oPage = new Page({
			title: "List Page",
			content : oList
		});

		oPage.placeAt("qunit-fixture");
		sap.ui.getCore().applyChanges();

		// sytem under test
		var oGrowingDelegate = oList._oGrowingDelegate;
		var oTrigger = oGrowingDelegate._oTrigger;

		// Act
		setTimeout(function() {
			assert.ok(oList.$("triggerList").is(":visible"), "Load more trigger is visible after initial rendering");

			// act + assert loading is started case
			oGrowingDelegate._updateTrigger(true);

			assert.ok(oTrigger.getBusy(), "Trigger shows the busy indicator");
			assert.ok(!oTrigger.$().hasClass("sapMLIBActive"), "Trigger is not active since it is busy");
			assert.ok(oTrigger.$().hasClass("sapMGrowingListBusyIndicatorVisible"), "Busy indicator visible class is added");
			assert.strictEqual(oList.$("triggerText").css("visibility"), "hidden", "Growing trigger text is hidden");
			assert.strictEqual(oList.$("triggerInfo").css("visibility"), "hidden", "Growing infor text is hidden");
			assert.ok(oList.$("triggerList").is(":visible"), "Load more trigger is visible");

			// act + assert loading is finished case for growingScrollToLoad=false
			oGrowingDelegate._updateTrigger(false);
			assert.ok(!oTrigger.getBusy(), "Trigger does not show the busy indicator");
			assert.ok(!oTrigger.$().hasClass("sapMGrowingListBusyIndicatorVisible"), "Busy indicator visible class is removed");
			assert.strictEqual(oList.$("triggerText").css("visibility"), "visible", "Growing trigger text is visible");
			assert.strictEqual(oList.$("triggerInfo").css("visibility"), "visible", "Growing info text is visible");
			assert.ok(oList.$("triggerList").is(":visible"), "Load more trigger is visible");

			// act + assert growingScrollToLoad=true
			oList.setGrowingScrollToLoad(true);
			sap.ui.getCore().applyChanges();
			assert.ok(oList.$("triggerList").is(":hidden"), "Load more trigger is not visible");

			// act + assert loading is started case for growingScrollToLoad=true
			oGrowingDelegate._updateTrigger(true);
			assert.ok(oTrigger.getBusy(), "Trigger shows the busy indicator");
			assert.ok(!oTrigger.$().hasClass("sapMLIBActive"), "Trigger is not active since it is busy");
			assert.ok(oTrigger.$().hasClass("sapMGrowingListBusyIndicatorVisible"), "Busy indicator visible class is added");
			assert.strictEqual(oList.$("triggerText").css("visibility"), "hidden", "Growing trigger text is hidden");
			assert.strictEqual(oList.$("triggerInfo").css("visibility"), "hidden", "Growing infor text is hidden");
			assert.ok(oList.$("triggerList").is(":visible"), "Load more trigger is visible");

			// act + assert loading is finished case for growingScrollToLoad=true
			oGrowingDelegate._updateTrigger(false);
			assert.ok(!oTrigger.getBusy(), "Trigger does not show the busy indicator");
			assert.ok(!oTrigger.$().hasClass("sapMGrowingListBusyIndicatorVisible"), "Busy indicator visible class is removed");
			assert.ok(!oList.$("triggerText").is(":visible"), "Growing trigger text is not visible");
			assert.ok(!oList.$("triggerInfo").is(":visible"), "Growing info text is not visible");
			assert.ok(!oList.$("triggerList").is(":visible"), "Load more trigger is not visible");

			// check for Growing trigger DOM
			assert.equal(oTrigger.TagName, "div", "Growing trigger has TagName as div");
			assert.ok(oTrigger.$().is("div"), "Growing trigger rendered as div in DOM");
			assert.ok(jQuery(".sapMSLITitle").is("span"), "More button rendered with span tag");
			assert.strictEqual(oTrigger.$().attr("role"), "button", "role=button");
			assert.strictEqual(oTrigger.$().attr("aria-selected"), undefined, "aria-selected attribute removed as role=button");

			// act + assert growingScrollToLoad=true
			oList.setGrowingScrollToLoad(false);
			sap.ui.getCore().applyChanges();
{'fraction_non_alphanumeric': 0.16395774075579034, 'fraction_numerical': 0.0016253555465258025, 'mean_word_length': 5.199622166246852, 'pattern_counts': {'":': 16, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1884679', 'n_tokens_mistral': 3312, 'n_tokens_neox': 2985, 'n_words': 701}