Skip to content

Commit

Permalink
fix: Split event and provider types
Browse files Browse the repository at this point in the history
  • Loading branch information
jlacivita committed May 22, 2024
1 parent cf6f29f commit 32415d9
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 29 deletions.
54 changes: 49 additions & 5 deletions src/openrpc/content.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"result": {
"name": "interest",
"schema": {
"$ref": "https://meta.comcast.com/firebolt/discovery#/definitions/Interest"
"$ref": "#/components/schemas/InterestResult"
},
"summary": "The EntityDetails data."
},
Expand Down Expand Up @@ -109,7 +109,7 @@
"result": {
"name": "interest",
"schema": {
"$ref": "https://meta.comcast.com/firebolt/discovery#/definitions/Interest"
"$ref": "#/components/schemas/InterestEvent"
},
"summary": "The EntityDetails data."
},
Expand Down Expand Up @@ -149,6 +149,50 @@
}
}
]
}
]
}
}
],
"components": {
"schemas": {
"InterestResult": {
"title": "InterestResult",
"type": "object",
"properties": {
"appId": {
"type": "string"
},
"entity": {
"$ref": "https://meta.comcast.com/firebolt/entity#/definitions/EntityDetails"
}
},
"required": [
"appId",
"entity"
]
},
"InterestEvent": {
"title": "InterestEvent",
"type": "object",
"properties": {
"appId": {
"type": "string"
},
"type": {
"$ref": "https://meta.comcast.com/firebolt/discovery#/definitions/InterestType"
},
"reason": {
"$ref": "https://meta.comcast.com/firebolt/discovery#/definitions/InterestReason"
},
"entity": {
"$ref": "https://meta.comcast.com/firebolt/entity#/definitions/EntityDetails"
}
},
"required": [
"appId",
"entity",
"type",
"reason"
]
}
}
}
}
24 changes: 1 addition & 23 deletions src/schemas/discovery.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,28 +74,6 @@
"reaction",
"recording"
]
},
"Interest": {
"title": "Interest",
"type": "object",
"properties": {
"appId": {
"type": "string"
},
"type": {
"$ref": "#/definitions/InterestType"
},
"reason": {
"$ref": "#/definitions/InterestReason"
},
"entity": {
"$ref": "https://meta.comcast.com/firebolt/entity#/definitions/EntityDetails"
}
},
"required": [
"appId",
"entity"
]
}
}
}
}
15 changes: 14 additions & 1 deletion src/sdks/discovery/test/suite/content.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,24 @@ import { test, expect } from "@jest/globals";
import { Content } from "../../build/javascript/src/firebolt-discovery";

test("Content.requestUserInterest()", () => {
return Content.requestUserInterest(Content.InterestType.INTEREST, Content.InterestReason.PLAYLIST).then((interest: Content.Interest) => {
return Content.requestUserInterest(Content.InterestType.INTEREST, Content.InterestReason.PLAYLIST).then((interest: Content.InterestResult) => {
const entity = interest.entity
const appId = interest.appId
expect(appId).toBeDefined()
expect(entity).toBeDefined()
expect(entity.info.title).toBe("Cool Runnings")
})
});

test("Content.onUserInterest()", () => {
return Content.listen('userInterest', (interest: Content.InterestEvent) => {
const entity = interest.entity
const appId = interest.appId
const reason = interest.reason
expect(interest['type']).toBeDefined()
expect(reason).toBeDefined()
expect(appId).toBeDefined()
expect(entity).toBeDefined()
expect(entity.info.title).toBe("Cool Runnings")
})
});

0 comments on commit 32415d9

Please sign in to comment.