Skip to content

Commit

Permalink
fix: fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
1fabiopereira committed Jun 19, 2023
1 parent d35a614 commit 9ec79c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/chains/__tests__/Chain.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ jest.mock('../core/ChainLink');
describe('Chain', () => {
it('Should call exec method', async () => {
const chain = new Chain([]);
const ctx = jest.fn();
const chainSpy = jest.spyOn(chain, 'exec');

await chain.exec('any-string', ctx);
await chain.exec('any-string');

expect(chainSpy).toBeCalledTimes(1);
});
Expand All @@ -29,12 +28,11 @@ describe('Chain', () => {
it('Should call ChainLink handle when exec runs', async () => {
const chainLinkOne = new ChainLink(jest.fn());
const chainLinkTwo = new ChainLink(jest.fn());
const ctx = jest.fn();

const chain = new Chain([chainLinkOne, chainLinkTwo]);
const chainSpy = jest.spyOn(chain, 'exec');

await chain.exec('any-string', ctx);
await chain.exec('any-string');

expect(chainLinkOne.handle).toBeCalledTimes(1);
expect(chainSpy).toBeCalledTimes(1);
Expand Down
8 changes: 4 additions & 4 deletions src/patterns/__tests__/Patterns.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe('Patterns', () => {
describe('Common', () => {
describe('Email', () => {
const cases = Patterns.Common.Email.map(
(_, index): [string, string, boolean][] => {
(_, index): [string, RegExp, boolean][] => {
return [
['match', Patterns.Common.Email[index], true],
['not match', Patterns.Common.Email[index], false],
Expand All @@ -13,7 +13,7 @@ describe('Patterns', () => {
).flat();
it.each(cases)(
'Should %s string with pattern %s',
(_: string, __: string, value: boolean) => {
(_: string, __: RegExp, value: boolean) => {
const email = value
? '[email protected]'
: 'email.provedor.com';
Expand Down Expand Up @@ -47,7 +47,7 @@ describe('Patterns', () => {
];

const cases = Patterns.Brazil.BankSlip.map(
(_, index): [string, string, boolean, number][] => {
(_, index): [string, RegExp, boolean, number][] => {
return [
['match', Patterns.Brazil.BankSlip[index], true, index],
['not match', Patterns.Brazil.BankSlip[index], false, index],
Expand All @@ -57,7 +57,7 @@ describe('Patterns', () => {

it.each(cases)(
'Should %s string with pattern %s',
(_: string, __: string, value: boolean, index: number) => {
(_: string, __: RegExp, value: boolean, index: number) => {
const data = value ? formats[index] : wrongFormats[index];
const patterns = Patterns.Brazil.BankSlip.map(
(pattern) => new RegExp(pattern)
Expand Down

0 comments on commit 9ec79c0

Please sign in to comment.