[Pkg-javascript-commits] [dojo] 38/149: test for correct caching of relative MIDs in parser (refs #18455)

David Prévot taffit at moszumanska.debian.org
Sat Feb 27 03:13:45 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository dojo.

commit a55e67827e54b023cc68077e4df8eb6a0bc698f9
Author: Adrian Rakovsky <adrian.rakovsky at gratex.com>
Date:   Fri Jan 16 14:22:21 2015 +0100

    test for correct caching of relative MIDs in parser (refs #18455)
---
 tests/functional/parser.js                        |  3 +-
 tests/functional/parser/parserContextRequire.html | 45 ++++++++++++++++++++++
 tests/functional/parser/parserContextRequire.js   | 46 +++++++++++++++++++++++
 tests/functional/parser/support/a/AMDWidget.js    | 19 ++++++++++
 tests/functional/parser/support/a/AMDWidget2.js   |  7 ++++
 tests/functional/parser/support/b/AMDWidget.js    | 19 ++++++++++
 tests/functional/parser/support/b/AMDWidget2.js   |  7 ++++
 7 files changed, 145 insertions(+), 1 deletion(-)

diff --git a/tests/functional/parser.js b/tests/functional/parser.js
index c390de0..eb695ab 100644
--- a/tests/functional/parser.js
+++ b/tests/functional/parser.js
@@ -2,5 +2,6 @@ define([
 	'./parser/parseOnLoadAutoRequire',
 	'./parser/parseOnLoadDeclarativeRequire',
 	'./parser/parser-args',
-	'./parser/parserAsync'
+	'./parser/parserAsync',
+	'./parser/parserContextRequire'
 ], function () { });
diff --git a/tests/functional/parser/parserContextRequire.html b/tests/functional/parser/parserContextRequire.html
new file mode 100644
index 0000000..7c39355
--- /dev/null
+++ b/tests/functional/parser/parserContextRequire.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+	<head>
+		<title>parser auto-require unit test</title>
+		<style type="text/css">
+			@import "../../../resources/dojo.css";
+		</style>
+		<script>
+			var ready = false;
+			var dojoConfig = {
+				async: true,
+				isDebug: true,
+				baseUrl: '.',
+				packages: [
+					{ name: 'dojo', location: '../../../node_modules/dojo' },
+					{ name: 'testing', location: '../../../' }
+				],
+				map: {
+					testing: {
+						dojo: 'testing'
+					}
+				},
+				callback: function () {
+					ready = true;
+				}
+			};
+		</script>
+		<script src="../../../dojo.js"></script>
+	</head>
+	<body>
+		<h1>parseOnLoad:true, async: true, auto-require unit test</h1>
+
+		<p>This page tests that:</p>
+		<ol>
+			<li>parser resolves relative MIDs in widget templates</li>
+			<li>parser correctly caches constructors with same relative MIDs</li>
+		</ol>
+		<p>See console for test results.</p>
+
+
+		<div data-testing-id="cr1" data-testing-type="testing/tests/functional/parser/support/a/AMDWidget"></div>
+		<div data-testing-id="cr2" data-testing-type="testing/tests/functional/parser/support/b/AMDWidget"></div>
+
+	</body>
+</html>
diff --git a/tests/functional/parser/parserContextRequire.js b/tests/functional/parser/parserContextRequire.js
new file mode 100644
index 0000000..f364c1d
--- /dev/null
+++ b/tests/functional/parser/parserContextRequire.js
@@ -0,0 +1,46 @@
+define([
+	'require',
+	'intern!object',
+	'intern/chai!assert',
+	'../../support/ready'
+], function(require, registerSuite, assert, ready) {
+	registerSuite({
+		name : 'dojo/parser - context require',
+
+		test : function() {
+			return ready(this.get('remote'), require.toUrl('./parserContextRequire.html')).setExecuteAsyncTimeout(50000).executeAsync(function(done, e) {
+				require([
+					'testing/parser',
+					'testing/tests/functional/parser/support/a/AMDWidget',
+					'testing/tests/functional/parser/support/a/AMDWidget2',
+					'testing/tests/functional/parser/support/b/AMDWidget',
+					'testing/tests/functional/parser/support/b/AMDWidget2',
+					'dojo/domReady!'
+				], function(parser, AMDWidgetA1, AMDWidgetA2, AMDWidgetB1, AMDWidgetB2) {
+					try {
+						parser.parse().then(function() {
+							/* global cr1, cr2 */
+							done({
+								cr1CorrectType : cr1.isInstanceOf(AMDWidgetA1),
+								cr2CorrectType : cr2.isInstanceOf(AMDWidgetB1),
+								cr1ChildCorrectType : cr1.child.isInstanceOf(AMDWidgetA2),
+								cr2ChildCorrectType : cr2.child.isInstanceOf(AMDWidgetB2)
+							});
+						}).otherwise(done);
+					} catch (e) {
+						done({
+							e : "x"
+						});
+					}
+				});
+			}).then(function(results) {
+				assert.deepEqual(results, {
+					cr1CorrectType : true,
+					cr2CorrectType : true,
+					cr1ChildCorrectType : true,
+					cr2ChildCorrectType : true
+				});
+			});
+		}
+	});
+});
diff --git a/tests/functional/parser/support/a/AMDWidget.js b/tests/functional/parser/support/a/AMDWidget.js
new file mode 100644
index 0000000..895a41f
--- /dev/null
+++ b/tests/functional/parser/support/a/AMDWidget.js
@@ -0,0 +1,19 @@
+define([
+	"require",
+	"dojo/_base/declare",
+	"dojo/dom-construct",
+	"dojo/parser",
+	"./AMDWidget2"
+], function(require, declare, domConstruct, parser) {
+
+	return declare(null, {
+		constructor : function() {
+			var node = domConstruct.create("div", {
+				innerHTML : '<div data-testing-type="./AMDWidget2"></div>'
+			});
+			this.child = parser.parse(node, {
+				contextRequire : require
+			})[0];
+		}
+	});
+});
\ No newline at end of file
diff --git a/tests/functional/parser/support/a/AMDWidget2.js b/tests/functional/parser/support/a/AMDWidget2.js
new file mode 100644
index 0000000..6a202b2
--- /dev/null
+++ b/tests/functional/parser/support/a/AMDWidget2.js
@@ -0,0 +1,7 @@
+define([
+	"dojo/_base/declare"
+], function(declare) {
+
+	return declare(null, {});
+
+});
\ No newline at end of file
diff --git a/tests/functional/parser/support/b/AMDWidget.js b/tests/functional/parser/support/b/AMDWidget.js
new file mode 100644
index 0000000..895a41f
--- /dev/null
+++ b/tests/functional/parser/support/b/AMDWidget.js
@@ -0,0 +1,19 @@
+define([
+	"require",
+	"dojo/_base/declare",
+	"dojo/dom-construct",
+	"dojo/parser",
+	"./AMDWidget2"
+], function(require, declare, domConstruct, parser) {
+
+	return declare(null, {
+		constructor : function() {
+			var node = domConstruct.create("div", {
+				innerHTML : '<div data-testing-type="./AMDWidget2"></div>'
+			});
+			this.child = parser.parse(node, {
+				contextRequire : require
+			})[0];
+		}
+	});
+});
\ No newline at end of file
diff --git a/tests/functional/parser/support/b/AMDWidget2.js b/tests/functional/parser/support/b/AMDWidget2.js
new file mode 100644
index 0000000..6a202b2
--- /dev/null
+++ b/tests/functional/parser/support/b/AMDWidget2.js
@@ -0,0 +1,7 @@
+define([
+	"dojo/_base/declare"
+], function(declare) {
+
+	return declare(null, {});
+
+});
\ No newline at end of file

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/dojo.git



More information about the Pkg-javascript-commits mailing list