8000 test(consumer): the browser contract requires the error code by adityamukho · Pull Request #12 · project-minigraf/minigraf-wasm · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions consumer-test/browser/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@ async function run() {
const rows = JSON.parse(await mem.execute('(query [:find ?n ?a :where [?e :name ?n] [?e :age ?a]])')).results
check(JSON.stringify(rows) === '[["Alice",30]]', 'in-memory transact and query')

// Error type: a rejected promise with a string reason. It should carry the
// error code ("[PRS-001] ..."), but BrowserDb drops it (minigraf#673); check
// for the code once the pinned core has the fix.
// Error type: a rejected promise whose reason starts with the error code,
// as on every other API ("[PRS-011] Unknown command: nosuchcommand").
let reason
try {
await mem.execute('(nosuchcommand [])')
} catch (e) {
reason = e
}
check(typeof reason === 'string' && /nosuchcommand/.test(reason), `an invalid command rejects with its message (${reason})`)
check(typeof reason === 'string' && /^\[PRS-011\] .*nosuchcommand/.test(reason), `the error carries its code (${reason})`)

// IndexedDB-backed: survives a page reload.
const db = await BrowserDb.open('contract')
Expand Down
Loading
0