Skip to content

Commit

Permalink
Validate that files-added receives a filtered list
Browse files Browse the repository at this point in the history
  • Loading branch information
ilessiivi committed Oct 11, 2021
1 parent 29b0ea6 commit a44217c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/fileAddSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,23 @@ describe('fileAdd event', function() {
expect(valid).toBeTruthy();
});

it('should validate file-added filtering before files-added', async function() {
var valid = false;
flow.on('file-added', (flowFile) => {
if(flowFile.name === 'f2') {
delete flowFile.file;
}
});
flow.on('files-added', (files) => {
valid = files.length === 1;
});
await flow.addFiles([
new File(['file'], 'f1'),
new File(['file2'], 'f2')
]);
expect(valid).toBeTruthy();
});

it('should validate multiple filter-file hooks', async function() {
const customFunction = jasmine.createSpy('fn');
flow.on('filter-file', async () => {
Expand Down

0 comments on commit a44217c

Please sign in to comment.