Permalink
Browse files

fixed regex test and added test cases PathResolverTest

  • Loading branch information...
1 parent cbbc450 commit 93a9e1b98ea6829a0ac64fad1946348d19d34c77 @ryanjduffy ryanjduffy committed Dec 27, 2012
Showing with 24 additions and 2 deletions.
  1. +1 −1 loader.js
  2. +23 −1 tools/test/core/tests/PathResolverTest.js
View
@@ -156,7 +156,7 @@
},
getPathPrefix: function(inPath) {
var delim = inPath.slice(0, 1);
- if ((delim != "/") && (delim != "\\") && (delim != "$") && !inPath.test(/^https?:/i)) {
+ if ((delim != "/") && (delim != "\\") && (delim != "$") && !/^https?:/i.test(inPath)) {
return this.packageFolder;
}
return "";
@@ -2,12 +2,34 @@ enyo.kind({
name: "PathResolverTest",
kind: enyo.TestSuite,
rewriteTest: function(inResolver, inPath, inExpected) {
- var result = inResolver.rewrite(inPath);
+ var pf= enyo.loader.packageFolder;
+ enyo.loader.packageFolder = "./source/";
+
+ var result = enyo.loader.getPathPrefix(inPath) + inResolver.rewrite(inPath);
+
if (result === inExpected) {
this.finish();
} else {
this.finish("Expected: '" + inExpected + "' Got: '" + result + "'");
}
+
+ enyo.loader.packageFolder = pf;
+ },
+ testNormalPath: function() {
+ var resolver = new enyo.pathResolverFactory();
+ this.rewriteTest(resolver, "my/folder", "./source/my/folder");
+ },
+ testLeadingSlashPath: function() {
+ var resolver = new enyo.pathResolverFactory();
+ this.rewriteTest(resolver, "/my/folder", "/my/folder");
+ },
+ testRewriteHttps: function() {
+ var resolver = new enyo.pathResolverFactory();
+ this.rewriteTest(resolver, "https://my.server/file.js", "https://my.server/file.js");
+ },
+ testRewriteHttpMixedCase: function() {
+ var resolver = new enyo.pathResolverFactory();
+ this.rewriteTest(resolver, "hTtP://my.server/file.js", "hTtP://my.server/file.js");
},
testRewriteUnknown: function() {
var resolver = new enyo.pathResolverFactory();

0 comments on commit 93a9e1b

Please sign in to comment.