Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
existentialism committed Aug 5, 2020
1 parent f8e9f34 commit bf958cd
Showing 1 changed file with 46 additions and 0 deletions.
Expand Up @@ -261,6 +261,14 @@ ruleTester.run("dry-error-messages", rule, {
code: "this.raise(loc);",
options: [{ errorModule: ERRORS_MODULE }],
},

// Support ternary as second argument
{
filename: FILENAME,
code:
"import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, a ? Errors.someErrorMessage : Errors.someOtherErrorMessage);",
options: [{ errorModule: ERRORS_MODULE }],
},
],
invalid: [
{
Expand Down Expand Up @@ -691,5 +699,43 @@ ruleTester.run("dry-error-messages", rule, {
},
],
},

// Should error if either part of a ternary isn't from error module
{
filename: FILENAME,
code:
"import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, a ? Errors.someErrorMessage : 'hello');",
options: [{ errorModule: ERRORS_MODULE }],
errors: [
{
messageId: "mustBeImported",
data: { errorModule: ERRORS_MODULE },
},
],
},
{
filename: FILENAME,
code:
"import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, a ? 'hello' : Errors.someErrorMessage);",
options: [{ errorModule: ERRORS_MODULE }],
errors: [
{
messageId: "mustBeImported",
data: { errorModule: ERRORS_MODULE },
},
],
},
{
filename: FILENAME,
code:
"import Errors, { NotErrors } from 'errorsModule'; this.raise(loc, a ? 'hello' : 'world');",
options: [{ errorModule: ERRORS_MODULE }],
errors: [
{
messageId: "mustBeImported",
data: { errorModule: ERRORS_MODULE },
},
],
},
],
});

0 comments on commit bf958cd

Please sign in to comment.