Skip to content

Commit

Permalink
🔥 raw function in shared-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnath committed Dec 19, 2016
1 parent f032df2 commit e2f5900
Showing 1 changed file with 2 additions and 39 deletions.
41 changes: 2 additions & 39 deletions tests/fixtures/files/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,6 @@ const all = [
path.join(process.cwd(), '../src/images', 'punchcard-404.svg'),
];

/*
* Raw File Fixture
*
* @returns {array} - An array file objects as one receives from a multi-upload form
*/
const raw = () => {
const files = _.cloneDeep(all);
const items = [];
let counter = 0;
let random;
do {
random = Math.round(Math.random() * (files.length - 1));

const type = path.extname(files[random]) === '.js' ? 'document/javascript' : 'image/svg';

items.push({
fieldName: `file-upload--file-${counter}`,
originalFilename: path.basename(files[random]),
path: files[random],
headers: {
'content-disposition': `form-data; name="file-upload--file-${counter}"; filename="${path.basename(files[random])}"`,
'content-type': type,
},
size: fs.statSync(files[random]).size,
name: path.basename(files[random]),
type,
});

files.splice(random, 1);
counter++;
} while (files.length > 0 && Math.random() > 0.5);


return items;
};

/*
* Saved File Fixtures
*
Expand All @@ -64,8 +28,8 @@ const saved = () => {
const type = path.extname(files[counter]) === '.js' ? 'document/javascript' : 'image/svg';

items.push({
name: path.basename(files[counter]),
path: `${uuid.v4()}${path.extname(files[counter])}`,
original: path.basename(files[counter]),
relative: `${uuid.v4()}${path.extname(files[counter])}`,
type,
});

Expand All @@ -78,6 +42,5 @@ const saved = () => {


module.exports = {
raw,
saved,
};

0 comments on commit e2f5900

Please sign in to comment.