Skip to content

Commit

Permalink
chore: unit test coverage for groups feature (wip)
Browse files Browse the repository at this point in the history
Related to #767
  • Loading branch information
Skaiir committed Aug 30, 2023
1 parent 43d0a3d commit aac3a86
Show file tree
Hide file tree
Showing 10 changed files with 842 additions and 54 deletions.
12 changes: 6 additions & 6 deletions packages/form-js-editor/test/spec/FormEditor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('FormEditor', function() {
});

// then
expect(formEditor.get('formFieldRegistry').getAll()).to.have.length(17);
expect(formEditor.get('formFieldRegistry').getAll()).to.have.length(20);
});


Expand Down Expand Up @@ -114,7 +114,7 @@ describe('FormEditor', function() {
});

// then
expect(formEditor.get('formFieldRegistry').getAll()).to.have.length(17);
expect(formEditor.get('formFieldRegistry').getAll()).to.have.length(20);
});


Expand All @@ -137,7 +137,7 @@ describe('FormEditor', function() {
container.querySelector('.fjs-container').classList.add('fjs-no-theme');

// then
expect(formEditor.get('formFieldRegistry').getAll()).to.have.length(17);
expect(formEditor.get('formFieldRegistry').getAll()).to.have.length(20);
});


Expand Down Expand Up @@ -243,7 +243,7 @@ describe('FormEditor', function() {
await formEditor.importSchema(schema);

// then
expect(formEditor.get('formFieldRegistry').getAll()).to.have.length(17);
expect(formEditor.get('formFieldRegistry').getAll()).to.have.length(20);
});


Expand Down Expand Up @@ -980,15 +980,15 @@ describe('FormEditor', function() {
// assume
const formFieldRegistry = formEditor.get('formFieldRegistry');

expect(formFieldRegistry.getAll()).to.have.length(17);
expect(formFieldRegistry.getAll()).to.have.length(20);

// when
startDragging(container);
moveDragging(container);
endDragging(container);

// then
expect(formFieldRegistry.getAll()).to.have.length(18);
expect(formFieldRegistry.getAll()).to.have.length(21);

const selection = formEditor.get('selection');

Expand Down
34 changes: 33 additions & 1 deletion packages/form-js-editor/test/spec/core/FieldFactory.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,20 @@ describe('core/FieldFactory', function() {
}));


it('should throw if ID already assigned', inject(function(fieldFactory) {
it('should not assign key (path)', inject(function(fieldFactory) {

// when
const field = fieldFactory.create({
key: 'foo.bar',
type: 'textfield'
}, false);

// then
expect(field.key).to.equal('foo.bar');
}));


it('should throw if binding path is already claimed (simple key)', inject(function(fieldFactory) {

// given
fieldFactory.create({
Expand All @@ -238,6 +251,25 @@ describe('core/FieldFactory', function() {
expect(create).to.throw('binding path \'foo\' is already claimed');
}));


it('should throw if binding path is already claimed (path key)', inject(function(fieldFactory) {

// given
fieldFactory.create({
key: 'foo.bar',
type: 'textfield'
}, false);

// when
const create = () => fieldFactory.create({
key: 'foo.bar',
type: 'textfield'
}, false);

// then
expect(create).to.throw('binding path \'foo.bar\' is already claimed');
}));

});

});
Expand Down
Loading

0 comments on commit aac3a86

Please sign in to comment.