Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdye committed Dec 14, 2020
1 parent aa1ff8e commit 19368f9
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/file-uploader/tests/unit/FileUploader.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { tsx } from '@dojo/framework/core/vdom';
import { assertion, renderer, wrap } from '@dojo/framework/testing/renderer';
import { noop } from '@dojo/widgets/common/tests/support/test-helpers';
import { noop } from '../../../common/tests/support/test-helpers';
import * as sinon from 'sinon';
import FileUploader, { formatBytes } from '../../index';
import FileUploadInput from '../../../file-upload-input';
Expand Down Expand Up @@ -163,7 +163,7 @@ describe('FileUploader', function() {
);
});

r.expect(baseAssertion.setChildren(WrappedFileUploadInput, () => [{ label, content: '' }]));
r.expect(baseAssertion.setChildren(WrappedFileUploadInput, () => ({ label, content: '' })));
});

it('renders files from property', function() {
Expand All @@ -173,7 +173,7 @@ describe('FileUploader', function() {
});
const content = getRenderedFiles(files);

r.expect(baseAssertion.setChildren(WrappedFileUploadInput, () => [{ content }]));
r.expect(baseAssertion.setChildren(WrappedFileUploadInput, () => ({ content })));
});

it('renders files from FileUploadInput', function() {
Expand All @@ -185,7 +185,7 @@ describe('FileUploader', function() {

r.expect(baseAssertion);
r.property(WrappedFileUploadInput, 'onValue', files as any);
r.expect(baseAssertion.setChildren(WrappedFileUploadInput, () => [{ content }]));
r.expect(baseAssertion.setChildren(WrappedFileUploadInput, () => ({ content })));
});

it('renders and validates multiple files from FileUploadInput', function() {
Expand Down Expand Up @@ -219,7 +219,7 @@ describe('FileUploader', function() {
r.property(WrappedFileUploadInput, 'onValue', files as any);

const content = getRenderedFiles(files);
r.expect(multipleAssertion.setChildren(WrappedFileUploadInput, () => [{ content }]));
r.expect(multipleAssertion.setChildren(WrappedFileUploadInput, () => ({ content })));
});

it('renders added files cumulatively when multiple=true', function() {
Expand All @@ -236,17 +236,17 @@ describe('FileUploader', function() {
const files = [{ name: 'file1', size: 100 }];
r.property(WrappedFileUploadInput, 'onValue', files as any);
r.expect(
multipleAssertion.setChildren(WrappedFileUploadInput, () => [
{ content: getRenderedFiles(files) }
])
multipleAssertion.setChildren(WrappedFileUploadInput, () => ({
content: getRenderedFiles(files as any)
}))
);

const moreFiles = [{ name: 'file2', size: 200 }];
r.property(WrappedFileUploadInput, 'onValue', moreFiles as any);
r.expect(
multipleAssertion.setChildren(WrappedFileUploadInput, () => [
{ content: getRenderedFiles([...files, ...moreFiles]) }
])
multipleAssertion.setChildren(WrappedFileUploadInput, () => ({
content: getRenderedFiles([...(files as any), ...moreFiles])
}))
);
});

Expand All @@ -259,16 +259,16 @@ describe('FileUploader', function() {
const files = [{ name: 'file1', size: 100 }, { name: 'file2', size: 200 }];
r.property(WrappedFileUploadInput, 'onValue', files as any);
r.expect(
baseAssertion.setChildren(WrappedFileUploadInput, () => [
{ content: getRenderedFiles([files[0]]) }
])
baseAssertion.setChildren(WrappedFileUploadInput, () => ({
content: getRenderedFiles([files[0] as any])
}))
);
const moreFiles = [{ name: 'file3', size: 300 }, { name: 'file4', size: 400 }];
r.property(WrappedFileUploadInput, 'onValue', moreFiles as any);
r.expect(
baseAssertion.setChildren(WrappedFileUploadInput, () => [
{ content: getRenderedFiles([moreFiles[0]]) }
])
baseAssertion.setChildren(WrappedFileUploadInput, () => ({
content: getRenderedFiles([moreFiles[0] as any])
}))
);
});

Expand Down Expand Up @@ -305,9 +305,9 @@ describe('FileUploader', function() {
});
r.property(WrappedFileUploadInput, 'onValue', files as any);
r.expect(
multipleAssertion.setChildren(WrappedFileUploadInput, () => [
{ content: getRenderedFiles(expectedFiles) }
])
multipleAssertion.setChildren(WrappedFileUploadInput, () => ({
content: getRenderedFiles(expectedFiles)
}))
);
assert.deepEqual(onValue.firstCall.args[0], expectedFiles);
});
Expand All @@ -319,7 +319,7 @@ describe('FileUploader', function() {
});
const content = getRenderedFiles(files);

r.expect(baseAssertion.setChildren(WrappedFileUploadInput, () => [{ content }]));
r.expect(baseAssertion.setChildren(WrappedFileUploadInput, () => ({ content })));
// TODO: the click event is not firing
// r.property(WrappedButton, 'onclick');
// r.expect(baseAssertion.setChildren(WrappedFileUploadInput, () => [{ content: getRenderedFiles(files.slice(1)) }]));
Expand Down

0 comments on commit 19368f9

Please sign in to comment.