-
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: move getValue tests to express lib
- Loading branch information
1 parent
5d9ca79
commit e04f43f
Showing
3 changed files
with
36 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { getValue } from './ts-rest-express'; | ||
|
||
describe('getValue', () => { | ||
it('should get one level deep', () => { | ||
const obj = { | ||
title: 'Title', | ||
}; | ||
|
||
const value = getValue(obj, 'title'); | ||
|
||
expect(value).toBe('Title'); | ||
}); | ||
|
||
it('should get one level deep with nullable', () => { | ||
const obj = { | ||
title: 'Title', | ||
}; | ||
|
||
const value = getValue(obj, 'test', null); | ||
|
||
expect(value).toBe(null); | ||
}); | ||
|
||
it('should get two levels deep', () => { | ||
const obj = { | ||
sub: { | ||
text: 'text', | ||
}, | ||
}; | ||
|
||
const value = getValue(obj, 'sub.text'); | ||
|
||
expect(value).toBe('text'); | ||
}); | ||
}); |