Skip to content

Commit

Permalink
unit test error path
Browse files Browse the repository at this point in the history
  • Loading branch information
dherman committed Feb 2, 2025
1 parent e735e08 commit e8c195a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/napi/lib/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,21 @@ describe("container", function () {
it("can produce and consume a RefCell", function () {
const cell = addon.createStringRefCell("my sekret mesij");
const s = addon.readStringRefCell(cell);
assert.strictEqual("my sekret mesij", s);
assert.strictEqual(s, "my sekret mesij");
});

it("concatenates a RefCell<String> with a String", function () {
const cell = addon.createStringRefCell("hello");
const s = addon.stringRefCellConcat(cell, " world");
assert.strictEqual("hello world", s);
assert.strictEqual(s, "hello world");
});

it("fails with a type error when not given a RefCell", function () {
try {
addon.stringRefCellConcat("hello", " world");
} catch (err) {
assert.instanceOf(err, TypeError);
assert.strictEqual(err.message, "expected std::cell::RefCell");
}
});
});

0 comments on commit e8c195a

Please sign in to comment.