Skip to content

Commit

Permalink
refactor: improve schema
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Dec 9, 2019
1 parent d155dd0 commit 8b13bc3
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/options.json
Expand Up @@ -37,7 +37,17 @@
"type": "boolean"
},
"ignore": {
"type": "array"
"type": "array",
"items": {
"anyOf": [
{
"type": "string"
},
{
"type": "object"
}
]
}
},
"flatten": {
"type": "boolean"
Expand Down
22 changes: 22 additions & 0 deletions test/__snapshots__/validate-options.test.js.snap
Expand Up @@ -45,6 +45,28 @@ options.0 should match some schema in anyOf
"
`;

exports[`validate options should throw an error on the "patterns" option with "[{"from":"test.txt","to":"dir","context":"context","ignore":["test.txt",true]}]" value 1`] = `
"CopyPlugin Invalid Options
options.0 should be string
options.0.ignore.1 should be string
options.0.ignore.1 should be object
options.0.ignore.1 should match some schema in anyOf
options.0 should match some schema in anyOf
"
`;

exports[`validate options should throw an error on the "patterns" option with "[{"from":"test.txt","to":"dir","context":"context","ignore":[true]}]" value 1`] = `
"CopyPlugin Invalid Options
options.0 should be string
options.0.ignore.0 should be string
options.0.ignore.0 should be object
options.0.ignore.0 should match some schema in anyOf
options.0 should match some schema in anyOf
"
`;

exports[`validate options should throw an error on the "patterns" option with "[{"from":"test.txt","to":"dir","context":"context","ignore":true}]" value 1`] = `
"CopyPlugin Invalid Options
Expand Down
25 changes: 24 additions & 1 deletion test/validate-options.test.js
Expand Up @@ -55,7 +55,14 @@ describe('validate options', () => {
toType: 'file',
test: /test/,
force: true,
ignore: ['ignore-1', 'ignore-2'],
ignore: [
'ignore-1',
'ignore-2',
{
dot: false,
glob: '**/*',
},
],
flatten: true,
cache: true,
transform: () => {},
Expand Down Expand Up @@ -179,6 +186,22 @@ describe('validate options', () => {
ignore: true,
},
],
[
{
from: 'test.txt',
to: 'dir',
context: 'context',
ignore: [true],
},
],
[
{
from: 'test.txt',
to: 'dir',
context: 'context',
ignore: ['test.txt', true],
},
],
[
{
from: 'test.txt',
Expand Down

0 comments on commit 8b13bc3

Please sign in to comment.