-
Notifications
You must be signed in to change notification settings - Fork 717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests to cli.ts #171
Add tests to cli.ts #171
Conversation
package.json
Outdated
@@ -7,7 +7,8 @@ | |||
"scripts": { | |||
"ava": "ava", | |||
"build": "npm run clean && npm-run-all build:*", | |||
"build:assets": "cpx \"./{src,tests}/**/*.!(ts)\" dist", | |||
"build:assets": "cpx \"./{src,tests}/**/{,*}.!(ts)\" dist", | |||
"build:fixtures": "cpx \"./{src,tests}/**/fixtures/**\" dist", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixtures
should be copied with the previous line, or do you want to copy only the fixtures
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the problem is that build:assets
doesn't copy the files without extensions, but I'll try some other combinations jejeje
tests/lib/cli.ts
Outdated
t.context.config.load.restore(); | ||
}); | ||
|
||
test.serial('if version option is defined should print the current version and return the exit code 0', async (t) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If version option is defined, it should print the current version and return with exit code 0
tests/lib/cli.ts
Outdated
t.is(exitCode, 0); | ||
}); | ||
|
||
test.serial('if help option is defined should print the help and return the exit code 0', async (t) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If help option is defined, it should print the help and return with exit code 0
tests/lib/cli.ts
Outdated
t.is(exitCode, 0); | ||
}); | ||
|
||
test.serial('if config is not defined should get the config file from a directory', async (t) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If config is not defined, it should get the config file from a directory
Not really clear what a directory
means. The current directory? A random directory?
tests/lib/cli.ts
Outdated
}); | ||
|
||
test.serial('if config is not defined should get the config file from a directory', async (t) => { | ||
// We just want to test that we are calling to the config.getFilenameForDirectory method we are returning false validating to avoid to stub more functions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// We just want to test
config.getFilenameForDirectory
. To avoid unneededstubs
, we returnfalse
invalidateConfig
tests/lib/config/config-validator.ts
Outdated
}; | ||
const invalidConfig = { formatter: 'json' }; | ||
|
||
test('if config has an invalid schema should return false', (t) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If config has an invalid schema, it should return false
tests/lib/config/config-validator.ts
Outdated
t.false(valid); | ||
}); | ||
|
||
test(`if there is a rule in the config that doesn't exist should return false`, (t) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is a rule in the config that doesn't exist, it should return false
tests/lib/config/config-validator.ts
Outdated
t.false(valid); | ||
}); | ||
|
||
test(`if rule severity isn't valid should return false`, (t) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If rule severity isn't valid, it should return false
tests/lib/config/config-validator.ts
Outdated
t.false(valid); | ||
}); | ||
|
||
test(`if rule schema isn't valid should return false`, (t) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If rule schema isn't valid, it should return false
tests/lib/config/config-validator.ts
Outdated
t.false(valid); | ||
}); | ||
|
||
test('if config is valid should return true', (t) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If config is valid, it should return true
Add tests to config.ts Add tests to config-validator.ts Fix #9
@molant done! |
Add tests to config.ts
Add tests to config-validator.ts
Fix #9