File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ import Project from "../../src/features/projects/domain/Project"
2
+ import CachingProjectDataSource from "../../src/features/projects/domain/CachingProjectDataSource"
3
+
4
+ test ( "It caches projects read from the data source" , async ( ) => {
5
+ const projects = [ {
6
+ id : "foo" ,
7
+ name : "foo" ,
8
+ versions : [ {
9
+ id : "bar" ,
10
+ name : "bar" ,
11
+ specifications : [ {
12
+ id : "baz.yml" ,
13
+ name : "baz.yml" ,
14
+ url : "https://example.com/baz.yml"
15
+ } ]
16
+ } , {
17
+ id : "hello" ,
18
+ name : "hello" ,
19
+ specifications : [ {
20
+ id : "world.yml" ,
21
+ name : "world.yml" ,
22
+ url : "https://example.com/world.yml"
23
+ } ]
24
+ } ]
25
+ } ]
26
+ let cachedProjects : Project [ ] | undefined
27
+ const sut = new CachingProjectDataSource ( {
28
+ async getProjects ( ) {
29
+ return projects
30
+ }
31
+ } , {
32
+ async getProjects ( ) {
33
+ return [ ]
34
+ } ,
35
+ async storeProjects ( projects ) {
36
+ cachedProjects = projects
37
+ } ,
38
+ async deleteProjects ( ) { }
39
+ } )
40
+ await sut . getProjects ( )
41
+ expect ( cachedProjects ) . toEqual ( projects )
42
+ } )
You can’t perform that action at this time.
0 commit comments