Skip to content
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

Merged
merged 1 commit into from
May 2, 2017
Merged

Add tests to cli.ts #171

merged 1 commit into from
May 2, 2017

Conversation

sarvaje
Copy link
Contributor

@sarvaje sarvaje commented May 1, 2017

Add tests to config.ts
Add tests to config-validator.ts

Fix #9

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",
Copy link
Member

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?

Copy link
Contributor Author

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) => {
Copy link
Member

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) => {
Copy link
Member

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) => {
Copy link
Member

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
Copy link
Member

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 unneeded stubs, we return false in validateConfig

};
const invalidConfig = { formatter: 'json' };

test('if config has an invalid schema should return false', (t) => {
Copy link
Member

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

t.false(valid);
});

test(`if there is a rule in the config that doesn't exist should return false`, (t) => {
Copy link
Member

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

t.false(valid);
});

test(`if rule severity isn't valid should return false`, (t) => {
Copy link
Member

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

t.false(valid);
});

test(`if rule schema isn't valid should return false`, (t) => {
Copy link
Member

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

t.false(valid);
});

test('if config is valid should return true', (t) => {
Copy link
Member

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
@sarvaje
Copy link
Contributor Author

sarvaje commented May 2, 2017

@molant done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants