1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Merge pull request #17385 from calixteman/bug1868503

Set text field value as a string when it's for a date or a time (bug 1868503)
This commit is contained in:
calixteman 2023-12-06 10:48:32 +01:00 committed by GitHub
commit 7e64f8213d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 78 additions and 3 deletions

View file

@ -971,6 +971,76 @@ describe("Scripting", function () {
value: "4/15/07 3:14 am",
});
});
it("should format a date", async () => {
const refId = getId();
const data = {
objects: {
field: [
{
id: refId,
value: "",
actions: {
Format: [`AFDate_FormatEx("mmddyyyy");`],
Keystroke: [`AFDate_KeystrokeEx("mmddyyyy");`],
},
type: "text",
},
],
},
appInfo: { language: "en-US", platform: "Linux x86_64" },
calculationOrder: [],
dispatchEventName: "_dispatchMe",
};
sandbox.createSandbox(data);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "12062023",
name: "Keystroke",
willCommit: true,
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
siblings: null,
value: "12062023",
formattedValue: "12062023",
});
send_queue.delete(refId);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "1206202",
name: "Keystroke",
willCommit: true,
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
siblings: null,
value: "",
formattedValue: null,
selRange: [0, 0],
});
send_queue.delete(refId);
sandbox.createSandbox(data);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "02062023",
name: "Keystroke",
willCommit: true,
});
expect(send_queue.has(refId)).toEqual(true);
expect(send_queue.get(refId)).toEqual({
id: refId,
siblings: null,
value: "02062023",
formattedValue: "02062023",
});
send_queue.delete(refId);
});
});
describe("AFRange_Validate", function () {