mirror of
https://github.com/kennethnym/aris.git
synced 2026-03-20 17:11:17 +00:00
refactor: make fetchContext required on FeedSource
Sources that cannot provide context now return null instead of omitting the method. The engine checks the return value rather than method existence. Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
@@ -27,11 +27,11 @@ describe("LocationSource", () => {
|
||||
expect(items).toEqual([])
|
||||
})
|
||||
|
||||
test("fetchContext returns empty when no location", async () => {
|
||||
test("fetchContext returns null when no location", async () => {
|
||||
const source = new LocationSource()
|
||||
|
||||
const context = await source.fetchContext()
|
||||
expect(context).toEqual({})
|
||||
expect(context).toBeNull()
|
||||
})
|
||||
|
||||
test("fetchContext returns location when available", async () => {
|
||||
|
||||
@@ -73,11 +73,11 @@ export class LocationSource implements FeedSource {
|
||||
}
|
||||
}
|
||||
|
||||
async fetchContext(): Promise<Partial<Context>> {
|
||||
async fetchContext(): Promise<Partial<Context> | null> {
|
||||
if (this.lastLocation) {
|
||||
return { [LocationKey]: this.lastLocation }
|
||||
}
|
||||
return {}
|
||||
return null
|
||||
}
|
||||
|
||||
async fetchItems(): Promise<[]> {
|
||||
|
||||
Reference in New Issue
Block a user