Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanbond committed Nov 11, 2024
1 parent 983db90 commit a781e56
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 2 deletions.
46 changes: 45 additions & 1 deletion src/process/__tests__/process.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1603,7 +1603,6 @@ describe('Process Tests', function () {
});
});

// TODO: test case naming
it('Should not unset submission data of nested forms with identical keys', function () {
const parentForm = {
display: 'form',
Expand Down Expand Up @@ -3323,6 +3322,51 @@ describe('Process Tests', function () {
});
});

it('Should include submission data for intentionally hidden fields', async function () {
const form = {
display: 'form',
components: [
{
type: 'textfield',
key: 'textField',
label: 'Text Field',
input: true,
},
{
type: 'textarea',
key: 'textArea',
label: 'Text Area',
input: true,
hidden: true,
},
],
};

const submission = {
data: {
textField: 'not empty',
textArea: 'also not empty',
},
};

const context = {
form,
submission,
data: submission.data,
components: form.components,
processors: ProcessTargets.evaluator,
scope: {},
config: {
server: true,
},
};
processSync(context);
expect(context.data).to.deep.equal({
textField: 'not empty',
textArea: 'also not empty',
});
});

it('Should not filter a simple datamap compoennt', async function () {
const form = {
display: 'form',
Expand Down
26 changes: 25 additions & 1 deletion src/process/clearHidden/__tests__/clearHidden.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('clearHidden', function () {
expect(context.data).to.deep.equal({ foo: 'bar' });
});

it('Should clear conditiionally hidden component data when clearOnHide is true', function () {
it('Should clear conditionally hidden component data when clearOnHide is true', function () {
// Test case data
const context = {
component: {
Expand Down Expand Up @@ -60,4 +60,28 @@ describe('clearHidden', function () {
clearHiddenProcess(context);
expect(context.data).to.deep.equal({});
});

it('Should not clear component data when the component is intentionally hidden', function () {
// Test case data
const context = {
component: {
type: 'textfield',
key: 'foo',
clearOnHide: true,
input: true,
hidden: true,
},
data: {
foo: 'bar',
},
value: 'foo',
row: {},
scope: {
clearHidden: {},
},
path: 'foo',
};
clearHiddenProcess(context);
expect(context.data).to.deep.equal({ foo: 'bar' });
});
});

0 comments on commit a781e56

Please sign in to comment.