Skip to content

Commit

Permalink
Adds tests for
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbs committed Oct 24, 2023
1 parent 6a5db5b commit 0198b5c
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions __test__/projects/CachingProjectDataSource.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import Project from "../../src/features/projects/domain/Project"
import CachingProjectDataSource from "../../src/features/projects/domain/CachingProjectDataSource"

test("It caches projects read from the data source", async () => {
const projects = [{
id: "foo",
name: "foo",
versions: [{
id: "bar",
name: "bar",
specifications: [{
id: "baz.yml",
name: "baz.yml",
url: "https://example.com/baz.yml"
}]
}, {
id: "hello",
name: "hello",
specifications: [{
id: "world.yml",
name: "world.yml",
url: "https://example.com/world.yml"
}]
}]
}]
let cachedProjects: Project[] | undefined
const sut = new CachingProjectDataSource({
async getProjects() {
return projects
}
}, {
async getProjects() {
return []
},
async storeProjects(projects) {
cachedProjects = projects
},
async deleteProjects() {}
})
await sut.getProjects()
expect(cachedProjects).toEqual(projects)
})

0 comments on commit 0198b5c

Please sign in to comment.