Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
ZenMasterJacob20011 committed Jul 10, 2024
1 parent e99c9c9 commit 5e11157
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 3 deletions.
16 changes: 15 additions & 1 deletion src/components/day/Day.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
comp4,
comp5,
comp6,
comp7
comp7,
comp8
} from './fixtures';
import PanelComponent from '../panel/Panel';

Expand Down Expand Up @@ -265,6 +266,7 @@ describe('Day Component', () => {
}, 500);
}).catch(done);
});

it('Should translate placeholder text', () => {
const element = document.createElement('div');
return Formio.createForm(element, comp7, {
Expand All @@ -283,4 +285,16 @@ describe('Day Component', () => {
assert.equal(dayComponent.refs.year.placeholder, 'Year3');
})
});

it('Should translate requiredDayField to {{ field }} is required', (done) => {
Formio.createForm(document.createElement('div'), comp8, {}).then((form) => {
const dayComponent = form.getComponent('dayTable');
const buttonComponent = form.getComponent('submit');
buttonComponent.refs.button.click();
setTimeout(()=>{
assert.equal(dayComponent.errors[0].message, 'Day - Table is required');
done();
},200);
});
});
});
38 changes: 38 additions & 0 deletions src/components/day/fixtures/comp8.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
export default {
"components": [
{
"label": "Day - Table",
"hideInputLabels": false,
"inputsLabelPosition": "top",
"useLocaleSettings": false,
"alwaysEnabled": false,
"tableView": false,
"fields": {
"day": {
"hide": false,
"required": true
},
"month": {
"hide": false,
"required": true
},
"year": {
"hide": false,
"required": true
}
},
"key": "dayTable",
"type": "day",
"input": true
},
{
"label": "Submit",
"showValidations": false,
"alwaysEnabled": false,
"tableView": false,
"key": "submit",
"type": "button",
"input": true
}
]
}
3 changes: 2 additions & 1 deletion src/components/day/fixtures/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ import comp4 from './comp4';
import comp5 from './comp5';
import comp6 from './comp6';
import comp7 from './comp7';
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7 };
import comp8 from './comp8';
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8 };
2 changes: 1 addition & 1 deletion src/translations/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ export default {
apiKey: 'API Key is not unique: {{key}}',
typeRemaining: '{{ remaining }} {{ type }} remaining.',
typeCount: '{{ count }} {{ type }}',
requiredDayField: '{{field}} is required'
requiredDayField: '{{ field }} is required'
};

0 comments on commit 5e11157

Please sign in to comment.