AnonSec Shell
Server IP : 92.204.138.22  /  Your IP : 18.224.55.82
Web Server : Apache
System : Linux ns1009439.ip-92-204-138.us 4.18.0-553.8.1.el8_10.x86_64 #1 SMP Tue Jul 2 07:26:33 EDT 2024 x86_64
User : internationaljou ( 1019)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/internationaljou/www/application/admin1/bower_components/datatables/media/unit_testing/tests_onhold/2_js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/internationaljou/www/application/admin1/bower_components/datatables/media/unit_testing/tests_onhold/2_js/6872-default-content-missing-props.js
// DATA_TEMPLATE: empty_table
oTest.fnStart( "6872 - mDataProp and sDefaultContent for deep objects" );

$(document).ready( function () {
	var test = false;

	$.fn.dataTable.ext.sErrMode = "throw";



	/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
	 * Shallow properties
	 */
	
	$('#example').dataTable( {
		"aaData": [
			{
				"a": "a",
				"b": "b",
				"c": "c",
				"d": "d",
				"e": "e"
			}
		],
		"aoColumns": [
			{ "mDataProp": "a" },
			{ "mDataProp": "b" },
			{ "mDataProp": "c" },
			{ "mDataProp": "d" },
			{ "mDataProp": "e" }
		]
	} );
	
	oTest.fnTest( 
		"Basic initialisation of objects works",
		null,
		function () { return $('#example tbody td:eq(0)').html() === "a"; }
	);
	
	oTest.fnTest( 
		"Error when property missing (no default content)",
		function () {
			oSession.fnRestore();
			test = false;

			try {
				$('#example').dataTable( {
					"aaData": [
						{
							"a": "a",
							"b": "b",
							"d": "d",
							"e": "e"
						}
					],
					"aoColumns": [
						{ "mDataProp": "a" },
						{ "mDataProp": "b" },
						{ "mDataProp": "c" },
						{ "mDataProp": "d" },
						{ "mDataProp": "e" }
					]
				} );
			} catch (e) {
				test = true;
			}
		},
		function () { return test; }
	);
	
	oTest.fnTest( 
		"Default content used for missing prop and no error",
		function () {
			oSession.fnRestore();

			$('#example').dataTable( {
				"aaData": [
					{
						"a": "a",
						"b": "b",
						"d": "d",
						"e": "e"
					}
				],
				"aoColumns": [
					{ "mDataProp": "a" },
					{ "mDataProp": "b" },
					{ "mDataProp": "c", "sDefaultContent": "test" },
					{ "mDataProp": "d" },
					{ "mDataProp": "e" }
				]
			} );
		},
		function () { return $('#example tbody td:eq(2)').html() === "test"; }
	);



	/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
	 * Deep properties with a single object
	 */
	
	oTest.fnTest( 
		"Basic test with deep properties",
		function () {
			oSession.fnRestore();
			
			$('#example').dataTable( {
				"aaData": [
					{
						"z": {
							"a": "a",
							"b": "b",
							"c": "c",
							"d": "d",
							"e": "e"
						}
					}
				],
				"aoColumns": [
					{ "mDataProp": "z.a" },
					{ "mDataProp": "z.b" },
					{ "mDataProp": "z.c" },
					{ "mDataProp": "z.d" },
					{ "mDataProp": "z.e" }
				]
			} );
		},
		function () { return $('#example tbody td:eq(0)').html() === "a"; }
	);
	
	oTest.fnTest( 
		"Error when property missing on deep get (no default content)",
		function () {
			oSession.fnRestore();
			test = false;
			
			try {
				$('#example').dataTable( {
					"aaData": [
						{
							"z": {
								"a": "a",
								"b": "b",
								"c": "c",
								"e": "e"
							}
						}
					],
					"aoColumns": [
						{ "mDataProp": "z.a" },
						{ "mDataProp": "z.b" },
						{ "mDataProp": "z.c" },
						{ "mDataProp": "z.d" },
						{ "mDataProp": "z.e" }
					]
				} );
			} catch (e) {
				test = true;
			}
		},
		function () { return test; }
	);
	
	oTest.fnTest( 
		"Default content used for missing prop on deep get and no error",
		function () {
			oSession.fnRestore();

			$('#example').dataTable( {
				"aaData": [
					{
						"z": {
							"a": "a",
							"b": "b",
							"c": "c",
							"e": "e"
						}
					}
				],
				"aoColumns": [
					{ "mDataProp": "z.a" },
					{ "mDataProp": "z.b" },
					{ "mDataProp": "z.c" },
					{ "mDataProp": "z.d", "sDefaultContent": "test" },
					{ "mDataProp": "z.e" }
				]
			} );
		},
		function () { return $('#example tbody td:eq(3)').html() === "test"; }
	);



	/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
	 * Deep properties with individual objects
	 */
	
	oTest.fnTest( 
		"Basic test with deep individual properties",
		function () {
			oSession.fnRestore();
			
			$('#example').dataTable( {
				"aaData": [
					{
						"m": { "a": "a" },
						"n": { "b": "b" },
						"o": { "c": "c" },
						"p": { "d": "d" },
						"q": { "e": "e" }
					}
				],
				"aoColumns": [
					{ "mDataProp": "m.a" },
					{ "mDataProp": "n.b" },
					{ "mDataProp": "o.c" },
					{ "mDataProp": "p.d" },
					{ "mDataProp": "q.e" }
				]
			} );
		},
		function () { return $('#example tbody td:eq(0)').html() === "a"; }
	);
	
	oTest.fnTest( 
		"Error when property missing on deep individual get (no default content)",
		function () {
			oSession.fnRestore();
			test = false;
			
			try {
				$('#example').dataTable( {
					"aaData": [
						{
							"m": { "a": "a" },
							"n": { "b": "b" },
							"p": { "d": "d" },
							"q": { "e": "e" }
						}
					],
					"aoColumns": [
						{ "mDataProp": "m.a" },
						{ "mDataProp": "n.b" },
						{ "mDataProp": "o.c" },
						{ "mDataProp": "p.d" },
						{ "mDataProp": "q.e" }
					]
				} );
			} catch (e) {
				test = true;
			}
		},
		function () { return test; }
	);
	
	oTest.fnTest( 
		"Default content used for missing prop on deep individual get and no error",
		function () {
			oSession.fnRestore();

			$('#example').dataTable( {
				"aaData": [
					{
						"m": { "a": "a" },
						"n": { "b": "b" },
						"p": { "d": "d" },
						"q": { "e": "e" }
					}
				],
				"aoColumns": [
					{ "mDataProp": "m.a" },
					{ "mDataProp": "n.b" },
					{ "mDataProp": "o.c", "sDefaultContent": "test" },
					{ "mDataProp": "p.d" },
					{ "mDataProp": "q.e" }
				]
			} );
		},
		function () { return $('#example tbody td:eq(2)').html() === "test"; }
	);
	
	
	oTest.fnComplete();
} );

Anon7 - 2022
AnonSec Team