Skip to content

Added a testcase for LDEV-5349 #2560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 7.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions test/tickets/LDEV5349.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
component extends="org.lucee.cfml.test.LuceeTestCase" {
function run( testResults, testBox ) {
describe("Testcase for LDEV-5349", function() {
// JSON data
var testJSON = '
[
{
"id": "1",
"name": "pothys"
},
{
"id": "2",
"name": "lucee"
}
]';
it(title='Check deserializeJSON with strictMapping as query type', skip=true, body=function(currentSpec) {
var deserializedQuery = deserializeJSON(testJSON, "query");

// Create the expected query object manually
var expectedQuery = queryNew("id, name");
queryAddRow(expectedQuery, [1, "pothys"]);
queryAddRow(expectedQuery, [2, "lucee"]);

// Compare the deserialized query to the expected query
expect(deserializedQuery).toBe(expectedQuery);
});

it(title='Check deserializeJSON with strictMapping as true', skip=false, body=function(currentSpec) {
var deserializedArray = deserializeJSON(testJSON, true);
expect(arrayLen(deserializedArray)).toBe(2);
expect(deserializedArray[1].id).toBe("1");
expect(deserializedArray[2].name).toBe("lucee");
});

it(title='Check deserializeJSON with strictMapping as false', skip=false, body=function(currentSpec) {
var deserializedArray = deserializeJSON(testJSON, false);
expect(arrayLen(deserializedArray)).toBe(2);
expect(deserializedArray[1].id).toBe("1");
expect(deserializedArray[2].name).toBe("lucee");
});

it(title='Check deserializeJSON without strictMapping', skip=false, body=function(currentSpec) {
var deserializedArray = deserializeJSON(testJSON);
expect(arrayLen(deserializedArray)).toBe(2);
expect(deserializedArray[1].id).toBe("1");
expect(deserializedArray[2].name).toBe("lucee");
});

});
}
}