@shopify/slate-config
Advanced tools
Comparing version 1.0.0-alpha.16 to 1.0.0-alpha.17
@@ -8,3 +8,8 @@ module.exports = { | ||
}, | ||
{ | ||
id: 'test-array', | ||
default: ['item1', 'item2'], | ||
type: 'array', | ||
}, | ||
], | ||
}; |
@@ -0,3 +1,3 @@ | ||
const fs = require('fs'); | ||
const slateConfig = require('../index'); | ||
const fs = require('fs'); | ||
const schema = require('./fixtures/schema'); | ||
@@ -13,3 +13,3 @@ const slaterc = require('./fixtures/slaterc.json'); | ||
schema.items[0].id, | ||
schema.items[0].default | ||
schema.items[0].default, | ||
); | ||
@@ -27,3 +27,3 @@ }); | ||
schema.items[0].id, | ||
'override-value' | ||
'override-value', | ||
); | ||
@@ -30,0 +30,0 @@ |
@@ -14,2 +14,11 @@ const validate = require('../validate'); | ||
describe('test: isValidType', () => { | ||
test('validates item of type array when read from json', () => { | ||
const json = '{"test-array": ["item1", "item2", "item3"]}'; | ||
const slatercWithArray = JSON.parse(json); | ||
const results = validate(schema, slatercWithArray); | ||
expect(results).toHaveProperty('isValid'); | ||
expect(results.isValid).toEqual(true); | ||
}); | ||
test('returns error if invalid type is provided', () => { | ||
@@ -16,0 +25,0 @@ const invalidSlateRc = Object.assign({}, slaterc, { |
{ | ||
"name": "@shopify/slate-config", | ||
"version": "1.0.0-alpha.16", | ||
"version": "1.0.0-alpha.17", | ||
"description": "Generate Slate config files", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -19,2 +19,10 @@ function validate(schema, slaterc) { | ||
function extractType(item, value) { | ||
if (item.type === `array` && Array.isArray(value)) { | ||
return item.type; | ||
} | ||
return typeof value; | ||
} | ||
function isValidType(schema, slaterc) { | ||
@@ -27,3 +35,3 @@ const errors = []; | ||
const value = slaterc[key]; | ||
const type = typeof value; | ||
const type = extractType(item, value); | ||
@@ -35,3 +43,3 @@ if (type !== 'undefined') { | ||
item.type | ||
}' but received type '${type}'` | ||
}' but received type '${type}'`, | ||
); | ||
@@ -38,0 +46,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5121
164