Skip to content

Commit

Permalink
chore: test promise plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
danielc92 committed May 14, 2023
1 parent a9eb3a5 commit c3432fc
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('.eslintrc.js suite', () => {
{
ruleId: 'react/jsx-pascal-case',
severity: 1
},
}
]
},
{
Expand Down Expand Up @@ -155,6 +155,32 @@ describe('.eslintrc.js suite', () => {
}
]
},
{
testName: 'promise-plugin',
input: [ './src/testing-files/promise-plugin' ],
output: [
{
ruleId: 'promise/no-new-statics',
severity: 2
},
{
ruleId: 'promise/catch-or-return',
severity: 2
},
{
ruleId: 'promise/no-return-wrap',
severity: 2
},
{
ruleId: 'promise/param-names',
severity: 2
},
{
ruleId: 'promise/no-return-in-finally',
severity: 1
}
]
},
{
testName: 'jest-plugin',
input: [ './src/testing-files/jest-plugin' ],
Expand Down
25 changes: 25 additions & 0 deletions src/testing-files/promise-plugin/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
let myPromise = new Promise.resolve("ok")
const doSomething = () => console.log("ok")
const catchErrors = () => console.log("ok")
myPromise.then(doSomething)
myPromise.then(doSomething, catchErrors) // catch() may be a little better
function doSomethingElse() {
return myPromise.then(doSomething)
}

myPromise.then(function (val: number) {
return Promise.resolve(val * 2)
})
myPromise.then(function (val: number) {
return Promise.reject('bad thing')
})


myPromise.finally(function (val) {
return val
})


new Promise(function (reject, resolve) { console.log("ok") }) // incorrect order
new Promise(function (ok, fail) { console.log("ok")}) // non-standard parameter names
new Promise(function (_, reject) { console.log("ok")}) // a simple underscore is not allowed

0 comments on commit c3432fc

Please sign in to comment.