LibWeb/Tests: Add basic tests for {ByteLength,Counting}QueuingStrategy
This commit is contained in:
parent
f86c3ab148
commit
464e428e94
Notes:
sideshowbarker
2024-07-16 22:14:49 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/464e428e94 Pull-request: https://github.com/SerenityOS/serenity/pull/19455 Reviewed-by: https://github.com/kennethmyhra ✅ Reviewed-by: https://github.com/mattco98 ✅
2 changed files with 53 additions and 0 deletions
|
@ -0,0 +1,20 @@
|
|||
======================================
|
||||
CountQueuingStrategy
|
||||
======================================
|
||||
'{"highWaterMark":2}' => 2
|
||||
'{"highWaterMark":-1}' => -1
|
||||
'{"badKey":-1}' => Exception raised of TypeError
|
||||
'{}' => Exception raised of TypeError
|
||||
'"string instead"' => Exception raised of TypeError
|
||||
'{"highWaterMark":"wrongType"}' => NaN
|
||||
'{"highWaterMark":{}}' => NaN
|
||||
======================================
|
||||
ByteLengthQueuingStrategy
|
||||
======================================
|
||||
'{"highWaterMark":2}' => 2
|
||||
'{"highWaterMark":-1}' => -1
|
||||
'{"badKey":-1}' => Exception raised of TypeError
|
||||
'{}' => Exception raised of TypeError
|
||||
'"string instead"' => Exception raised of TypeError
|
||||
'{"highWaterMark":"wrongType"}' => NaN
|
||||
'{"highWaterMark":{}}' => NaN
|
|
@ -0,0 +1,33 @@
|
|||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
function checkHighWaterMarkForClass(cls, object) {
|
||||
try {
|
||||
const strat = new cls(object);
|
||||
println(`'${JSON.stringify(object)}' => ${strat.highWaterMark}`);
|
||||
} catch (e) {
|
||||
println(`'${JSON.stringify(object)}' => Exception raised of ${e.constructor.name}`);
|
||||
}
|
||||
}
|
||||
|
||||
for (cls of [
|
||||
CountQueuingStrategy,
|
||||
ByteLengthQueuingStrategy,
|
||||
]) {
|
||||
println("======================================")
|
||||
println(cls.name)
|
||||
println("======================================")
|
||||
for (strat of [
|
||||
{ highWaterMark: 2 },
|
||||
{ highWaterMark: -1 },
|
||||
{ badKey: -1 },
|
||||
{},
|
||||
"string instead",
|
||||
{ highWaterMark: "wrongType" },
|
||||
{ highWaterMark: {} },
|
||||
]) {
|
||||
checkHighWaterMarkForClass(cls, strat);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
Loading…
Add table
Reference in a new issue