Skip to content

Commit

Permalink
fix(assets): allow assets without files
Browse files Browse the repository at this point in the history
  • Loading branch information
axe312ger committed Apr 4, 2018
1 parent 030f6a7 commit 8d99bab
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/utils/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const contentTypeSchema = {
const assetSchema = {
sys: Joi.object(),
fields: Joi.object({
file: Joi.object().required().pattern(/\S+-\S+/, Joi.object({
file: Joi.object().pattern(/.+/, Joi.object({
url: Joi.string().required(),
details: Joi.object({
size: Joi.number(),
Expand Down
11 changes: 2 additions & 9 deletions test/integration/import-cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,14 @@ test('It should import space properly when running as a cli', (done) => {
app()
.run(` --space-id ${space.sys.id} --management-token ${managementToken} --content-file ${resolve(__dirname, 'sample-space.json')}`)
.code(0)
.expect((result) => {
.expect(result => {
if (result.stderr.length) {
console.log(result.stdout)
console.log(result.stderr)
throw new Error('Should not have stderr output.')
}
})
.stdout(/The following entities are going to be imported:/)
.stdout(/Content Types +│ 2/)
.stdout(/Editor Interfaces +│ 2/)
.stdout(/Entries +│ 4/)
.stdout(/Assets +│ 4/)
.stdout(/Locales +│ 1/)
.stdout(/Webhooks +│ 0/)
.end((error) => {
.end(error => {
expect(error).toBeUndefined()
done()
})
Expand Down
9 changes: 7 additions & 2 deletions test/unit/validations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,13 @@ test('payload validation should fail when given an invalid data', () => {
sys: {id: 'myAsset'},
fields: {
title: {'en-US': 'a title'},
fileName: 'anAssets.png',
contentType: 'image/png'
file: {
'en-US': {
// url is missing
fileName: 'anAssets.png',
contentType: 'image/png'
}
}
}
}
expect(() => assertPayload({
Expand Down

0 comments on commit 8d99bab

Please sign in to comment.