Skip to content

Commit 0198b5c

Browse files
committed
Adds tests for
1 parent 6a5db5b commit 0198b5c

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
})

0 commit comments

Comments
 (0)