| 1 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 2 |
import cockpit from 'cockpit'; |
| 3 |
import QUnit from 'qunit-tests'; |
| 4 |
|
| 5 |
function as_str(value: string | number): string { |
| 6 |
cockpit.assert(typeof value === "string"); |
| 7 |
return value; // only (statically) possible because of the assert |
| 8 |
} |
| 9 |
|
| 10 |
QUnit.test("cockpit.assert success", function(assert) { |
| 11 |
as_str("abc"); |
| 12 |
assert.ok(true); |
| 13 |
}); |
| 14 |
|
| 15 |
QUnit.test("cockpit.assert fail", function(assert) { |
| 16 |
assert.throws(function() { |
| 17 |
as_str(123); |
| 18 |
}); |
| 19 |
assert.ok(true); |
| 20 |
}); |
| 21 |
|
| 22 |
QUnit.start(); |