-
-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LDEV-5378 test case for cfprocessing directive (#2520)
- Loading branch information
Showing
4 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
component extends="org.lucee.cfml.test.LuceeTestCase" { | ||
|
||
function run() { | ||
describe("Tests for cfprocessingdirective", function() { | ||
|
||
it("should correctly set page encoding", function() { | ||
var result = _InternalRequest(template="#createURI('processingDirective')#/cfprocessingdirective_encoding.cfm"); | ||
debug(result); | ||
expect(result.fileContent.trim()).toBe("Encoding set to UTF-8"); | ||
}); | ||
|
||
// ACF 2023 doesn't seem to strip whitespace at all? | ||
it("should suppress whitespace when specified", function() { | ||
var result = _InternalRequest(template="#createURI('processingDirective')#/cfprocessingdirective_whitespace.cfm"); | ||
var text = replace( | ||
replace( | ||
replace(result.fileContent,chr(10),"LF","all"), | ||
chr(13),"CR","all"), | ||
" ",".","all" | ||
); | ||
// test file is LF | ||
expect( text ).toBe( "LFLFLine1LFLine2LFLine3LF" ); | ||
}); | ||
}); | ||
|
||
// disabled hangs https://luceeserver.atlassian.net/browse/LDEV-5378 | ||
|
||
xdescribe("Tests for cfprocessingdirective - preservecase", function() { | ||
|
||
it("should preserve case when enabled", function() { | ||
var result = _InternalRequest( | ||
template="#createURI('processingDirective')#/cfprocessingdirective_preservecase.cfm", | ||
url: { | ||
preserve: true | ||
} | ||
); | ||
expect(result.fileContent).toBeWithCase('{"camelCase":true}'); | ||
}); | ||
|
||
it("shouldn't preserve case when disabled", function() { | ||
var result = _InternalRequest( | ||
template="#createURI('processingDirective')#/cfprocessingdirective_preservecase.cfm", | ||
url: { | ||
preserve: false | ||
} | ||
); | ||
expect(result.fileContent).toBeWithCase('{"CAMELCASE":false}'); | ||
}); | ||
|
||
it("shouldn't preserve case by default, no processingdirective", function() { | ||
var result = _InternalRequest( | ||
template="#createURI('processingDirective')#/cfprocessingdirective_preservecase.cfm", | ||
url: { | ||
default: true | ||
} | ||
); | ||
expect(result.fileContent).toBeWithCase('{"CAMELCASE":"default"}'); | ||
}); | ||
}); | ||
} | ||
|
||
private string function createURI(string calledName){ | ||
var baseURI="/test/#listLast(getDirectoryFromPath(getCurrentTemplatePath()),"\/")#/"; | ||
return baseURI&""&calledName; | ||
} | ||
|
||
private function isWindows(){ | ||
return (server.os.name contains "windows"); | ||
} | ||
|
||
} |
2 changes: 2 additions & 0 deletions
2
test/tags/processingDirective/cfprocessingdirective_encoding.cfm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<cfprocessingdirective pageencoding="UTF-8"> | ||
<cfoutput>Encoding set to UTF-8</cfoutput> |
24 changes: 24 additions & 0 deletions
24
test/tags/processingDirective/cfprocessingdirective_preservecase.cfm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<cfscript> | ||
param name="url.default" value="false"; | ||
param name="url.preserve" value="true"; | ||
if (url.default){ | ||
st = { | ||
camelCase: "default" | ||
}; | ||
echo( st.toJson() ); | ||
} else if (url.preserve) { | ||
processingDirective preserveCase=true { | ||
st = { | ||
camelCase: true | ||
}; | ||
echo(st.toJson()); | ||
}; | ||
} else { | ||
processingDirective preserveCase=false { | ||
st = { | ||
camelCase: false | ||
}; | ||
echo(st.toJson()); | ||
}; | ||
} | ||
</cfscript> |
8 changes: 8 additions & 0 deletions
8
test/tags/processingDirective/cfprocessingdirective_whitespace.cfm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!--- this file uses LF line endings ---> | ||
<cfprocessingdirective suppresswhitespace="yes"> | ||
<cfoutput> | ||
Line1 | ||
Line2 | ||
Line3 | ||
</cfoutput> | ||
</cfprocessingdirective> |