Skip to content

Commit

Permalink
Fakes
Browse files Browse the repository at this point in the history
  • Loading branch information
barosanuemailtest committed Feb 6, 2023
1 parent 9cb21d4 commit 5d6c187
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 18 deletions.
10 changes: 10 additions & 0 deletions src/app/doubles/OtherUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@ export type stringInfo = {
extraInfo: Object | undefined
}

type LoggerServiceCallBack = (arg: string) => void;

export function calculateComplexity(stringInfo: stringInfo){
return Object.keys(stringInfo.extraInfo).length * stringInfo.length
}

export function toUpperCaseWithCb(arg: string, callBack:LoggerServiceCallBack){
if(!arg) {
callBack('Invalid argument!');
return;
}
callBack(`called function with ${arg}`)
return arg.toUpperCase();
}
30 changes: 30 additions & 0 deletions src/test/doubles/OtherUtils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { calculateComplexity, toUpperCaseWithCb } from "../../app/doubles/OtherUtils"


describe('OtherUtils test suite', ()=>{

it('ToUpperCase - calls callback for invalid argument', ()=>{
const actual = toUpperCaseWithCb('', ()=>{});
expect(actual).toBeUndefined();
})

it('ToUpperCase - calls callback for valid argument', ()=>{
const actual = toUpperCaseWithCb('abc', ()=>{});
expect(actual).toBe('ABC');
})



it('Calculates complexity', ()=>{
const someInfo = {
length: 5,
extraInfo: {
field1: 'someInfo',
field2: 'someOtherInfo'
}
}

const actual = calculateComplexity(someInfo as any);
expect(actual).toBe(10);
})
})
18 changes: 0 additions & 18 deletions src/test/doubles/OtherUtils.ts

This file was deleted.

0 comments on commit 5d6c187

Please sign in to comment.