Skip to content

Commit

Permalink
Add undefined-action test case
Browse files Browse the repository at this point in the history
  • Loading branch information
guhmerces committed Feb 4, 2022
1 parent 6390b5e commit d745c84
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/github-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function GithubProvider(this: any, _options: any) {
}

async function unknown_cmd(this: any, msg: any) {
throw new Error(`undefined cmd: ${msg.cmd}, entity: ${msg.ent.entity$}`)
throw new Error(`undefined action: ${msg.cmd}, entity: ${msg.ent.entity$}`)
}

function prepare_ents(entities: EntityMap): Array<EntData> {
Expand Down
22 changes: 22 additions & 0 deletions test/github-provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,28 @@ describe("github-entities-load", () => {
})
})

describe('undefined-action', () => {
test('throws-error-when-a-undefined-action-is-called', async() => {
const seneca = Seneca({ legacy: false })
.test()
.use("promisify")
.use("entity")
.use("provider", provider_options)
.use(GithubProvider)

let res_data = await seneca.entity("provider/github/" + 'license').load$({
license: 'mit'
})

try {
// there is no defined "save" action for license entity
const x = await res_data.save$()
} catch (e) {
expect(e.message).toBe('undefined action: save, entity: provider/github/license');
}
})
})

describe("github-entities-save", () => {
Object.keys(saves).forEach(ent_name => {
let test_data = saves[ent_name]
Expand Down

0 comments on commit d745c84

Please sign in to comment.