You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by sv...@apache.org on 2018/05/29 15:24:19 UTC

[4/4] wicket git commit: WICKET-6557 ajax meta updates

WICKET-6557 ajax meta updates

moved new js tests to ajax.js


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/55ce67b3
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/55ce67b3
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/55ce67b3

Branch: refs/heads/master
Commit: 55ce67b3d47e7e9b2c99bb958f1c9a1274299d2d
Parents: c4d2cb3
Author: Sven Meier <sv...@apache.org>
Authored: Tue May 29 17:10:40 2018 +0200
Committer: Sven Meier <sv...@apache.org>
Committed: Tue May 29 17:23:23 2018 +0200

----------------------------------------------------------------------
 wicket-core/src/test/js/ajax.js              | 68 +++++++++++++++++++++++
 wicket-core/src/test/js/data/ajax/metaId.xml | 18 ++++++
 wicket-core/src/test/js/head.js              | 39 -------------
 3 files changed, 86 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/55ce67b3/wicket-core/src/test/js/ajax.js
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/js/ajax.js b/wicket-core/src/test/js/ajax.js
index f95c702..fb3af11 100644
--- a/wicket-core/src/test/js/ajax.js
+++ b/wicket-core/src/test/js/ajax.js
@@ -1466,5 +1466,73 @@ jQuery(document).ready(function() {
 
 			execute(attrs);
 		});
+		
+		var metaByName = function(name) {
+			return jQuery('head meta[name=' + name + ']');
+		};
+
+		asyncTest('processMeta() create meta tag', function() {
+
+			expect(3);
+
+			jQuery('meta').remove();
+			equal(metaByName("m1").length, 0, "There must be no meta tag before the contribution.");
+			
+			var attrs = {
+				u: 'data/ajax/metaId.xml',
+				sh: [
+					function() {
+						start();
+						equal(metaByName("m1").length, 1, "There must be one meta tag after the contribution.");
+						equal(metaByName("m1").attr("content"), "c1", "The meta tag must have the content as requested.");
+					}
+				]
+			};
+			execute(attrs);
+		});
+		
+		asyncTest('processMeta() change meta tag', function() {
+
+			expect(3);
+
+			jQuery('meta').remove();
+			jQuery('head').append('<meta name="m1" content="c1_old" />');
+			equal(metaByName("m1").length, 1, "There must be one old meta tag before the contribution.");
+			
+			var attrs = {
+				u: 'data/ajax/metaId.xml',
+				sh: [
+					function() {
+						start();
+						equal(metaByName("m1").length, 1, "There must be one meta tag after the contribution.");
+						equal(metaByName("m1").attr("content"), "c1", "The meta tag must have the content as requested.");
+					}
+				]
+			};
+			execute(attrs);
+		});
+
+		asyncTest('processMeta() add meta tag', function() {
+
+			expect(5);
+
+			jQuery('meta').remove();
+			jQuery('head').append('<meta name="m2" content="c2" />');
+			equal(metaByName("m2").length, 1, "There must be one old meta tag before the contribution.");
+			
+			var attrs = {
+				u: 'data/ajax/metaId.xml',
+				sh: [
+					function() {
+						start();
+						equal(metaByName("m2").length, 1, "There must be one old meta tag after the contribution.");
+						equal(metaByName("m2").attr("content"), "c2", "The old meta tag must still have the old content.");
+						equal(metaByName("m1").length, 1, "There must be one new meta tag after the contribution.");
+						equal(metaByName("m1").attr("content"), "c1", "The meta tag must have the content as requested.");
+					}
+				]
+			};
+			execute(attrs);
+		});
 	}
 });

http://git-wip-us.apache.org/repos/asf/wicket/blob/55ce67b3/wicket-core/src/test/js/data/ajax/metaId.xml
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/js/data/ajax/metaId.xml b/wicket-core/src/test/js/data/ajax/metaId.xml
new file mode 100644
index 0000000..89cacab
--- /dev/null
+++ b/wicket-core/src/test/js/data/ajax/metaId.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<ajax-response><header-contribution encoding="wicket1"><![CDATA[<head><meta name="m1" content="c1" /></head>]]></header-contribution></ajax-response>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/55ce67b3/wicket-core/src/test/js/head.js
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/js/head.js b/wicket-core/src/test/js/head.js
index 71710db..9966749 100644
--- a/wicket-core/src/test/js/head.js
+++ b/wicket-core/src/test/js/head.js
@@ -267,45 +267,6 @@ jQuery(document).ready(function() {
 		equal(baseUrlText, '/**/Wicket.Ajax.baseUrl=\"clock\";/**/', "Wicket.Ajax.baseUrl must be the third item's content");
 	});
 
-	module('Wicket.Head.Contributor.processContribution');
-
-	test('Wicket.Head.Contributor.processContribution - can add meta tags', function() {
-		var process = function(contribution) {
-			var doc = Wicket.Xml.parse('<header-contribution><![CDATA[<head>' + contribution + '</head>]]></header-contribution>').documentElement,
-				context = {
-					steps: []
-				};
-				Wicket.Head.Contributor.processContribution(context, doc);
-				return context;
-			},
-			metaTags = function(name) {
-				return jQuery('head meta[name=' + name + ']');
-			};
-
-		var context1 = process('<meta name="m1" content="c1" />');
-		equal(context1.steps.length, 1, "There must be 1 steps to be executed.");
-		equal(metaTags("m1").length, 0, "There must be no meta tag before the first contribution.");
-		context1.steps[0]();
-		equal(metaTags("m1").length, 1, "There must be one meta tag after the first contribution.");
-		equal(metaTags("m1").attr("content"), "c1", "The meta tag must have the content as requested.");
-
-		var context2 = process('<meta name="m1" content="c1_1" />');
-		equal(context2.steps.length, 1, "There must be 1 steps to be executed.");
-		equal(metaTags("m1").length, 1, "There must be one old meta tag before the second contribution.");
-		context2.steps[0]();
-		equal(metaTags("m1").length, 1, "There must be one meta tag after the second contribution.");
-		equal(metaTags("m1").attr("content"), "c1_1", "The meta tag must have the content as requested.");
-
-		var context3 = process('<meta name="m2" content="c2" />');
-		equal(context3.steps.length, 1, "There must be 1 steps to be executed.");
-		equal(metaTags("m2").length, 0, "There must be no meta tag before the third contribution.");
-		context3.steps[0]();
-		equal(metaTags("m2").length, 1, "There must be one new meta tag after the third contribution.");
-		equal(metaTags("m2").attr("content"), "c2", "The meta tag must have the content as requested.");
-		equal(metaTags("m1").length, 1, "There must be still the old meta tag after the third contribution.");
-		equal(metaTags("m1").attr("content"), "c1_1", "The meta tag must still have the content as requested.");
-	});
-
 	/**
 	 * Wicket.Head.Contributor.processXYZ method will be tested in ajax.js
 	 */