mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 23:23:28 +00:00
migrate tests to new html runner
This commit is contained in:
@@ -37,31 +37,6 @@ pub const pre =
|
|||||||
;
|
;
|
||||||
|
|
||||||
const testing = @import("../../testing.zig");
|
const testing = @import("../../testing.zig");
|
||||||
test "Browser.webcomponents" {
|
test "Browser: Polyfill.WebComponents" {
|
||||||
var runner = try testing.jsRunner(testing.tracking_allocator, .{ .html = "<div id=main></div>" });
|
try testing.htmlRunner("polyfill/webcomponents.html");
|
||||||
defer runner.deinit();
|
|
||||||
|
|
||||||
try @import("polyfill.zig").preload(testing.allocator, runner.page.main_context);
|
|
||||||
|
|
||||||
try runner.testCases(&.{
|
|
||||||
.{
|
|
||||||
\\ class LightPanda extends HTMLElement {
|
|
||||||
\\ constructor() {
|
|
||||||
\\ super();
|
|
||||||
\\ }
|
|
||||||
\\ connectedCallback() {
|
|
||||||
\\ this.append('connected');
|
|
||||||
\\ }
|
|
||||||
\\ }
|
|
||||||
\\ window.customElements.define("lightpanda-test", LightPanda);
|
|
||||||
\\ const main = document.getElementById('main');
|
|
||||||
\\ main.appendChild(document.createElement('lightpanda-test'));
|
|
||||||
,
|
|
||||||
null,
|
|
||||||
},
|
|
||||||
|
|
||||||
.{ "main.innerHTML", "<lightpanda-test>connected</lightpanda-test>" },
|
|
||||||
.{ "document.createElement('lightpanda-test').dataset", "[object DataSet]" },
|
|
||||||
.{ "document.createElement('lightpanda-test.x').dataset", "[object DataSet]" },
|
|
||||||
}, .{});
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -208,29 +208,11 @@ pub const Bottle = struct {
|
|||||||
// -----
|
// -----
|
||||||
|
|
||||||
const testing = @import("../../testing.zig");
|
const testing = @import("../../testing.zig");
|
||||||
test "Browser.Storage.LocalStorage" {
|
test "Browser: Storage.LocalStorage" {
|
||||||
var runner = try testing.jsRunner(testing.tracking_allocator, .{});
|
try testing.htmlRunner("storage/local_storage.html");
|
||||||
defer runner.deinit();
|
|
||||||
|
|
||||||
try runner.testCases(&.{
|
|
||||||
.{ "localStorage.length", "0" },
|
|
||||||
|
|
||||||
.{ "localStorage.setItem('foo', 'bar')", "undefined" },
|
|
||||||
.{ "localStorage.length", "1" },
|
|
||||||
.{ "localStorage.getItem('foo')", "bar" },
|
|
||||||
.{ "localStorage.removeItem('foo')", "undefined" },
|
|
||||||
.{ "localStorage.length", "0" },
|
|
||||||
|
|
||||||
// .{ "localStorage['foo'] = 'bar'", "undefined" },
|
|
||||||
// .{ "localStorage['foo']", "bar" },
|
|
||||||
// .{ "localStorage.length", "1" },
|
|
||||||
|
|
||||||
.{ "localStorage.clear()", "undefined" },
|
|
||||||
.{ "localStorage.length", "0" },
|
|
||||||
}, .{});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test "storage bottle" {
|
test "Browser: Storage.Bottle" {
|
||||||
var bottle = Bottle.init(std.testing.allocator);
|
var bottle = Bottle.init(std.testing.allocator);
|
||||||
defer bottle.deinit();
|
defer bottle.deinit();
|
||||||
|
|
||||||
|
|||||||
22
src/tests/polyfill/webcomponents.html
Normal file
22
src/tests/polyfill/webcomponents.html
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<script src="../testing.js"></script>
|
||||||
|
|
||||||
|
<div id=main></div>
|
||||||
|
|
||||||
|
<script id=webcomponents>
|
||||||
|
class LightPanda extends HTMLElement {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
connectedCallback() {
|
||||||
|
this.append('connected');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.customElements.define("lightpanda-test", LightPanda);
|
||||||
|
const main = document.getElementById('main');
|
||||||
|
main.appendChild(document.createElement('lightpanda-test'));
|
||||||
|
|
||||||
|
testing.expectEqual('<lightpanda-test>connected</lightpanda-test>', main.innerHTML)
|
||||||
|
testing.expectEqual('[object DataSet]', document.createElement('lightpanda-test').dataset.toString());
|
||||||
|
testing.expectEqual('[object DataSet]', document.createElement('lightpanda-test.x').dataset.toString());
|
||||||
|
</script>
|
||||||
25
src/tests/storage/local_storage.html
Normal file
25
src/tests/storage/local_storage.html
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<script src="../testing.js"></script>
|
||||||
|
|
||||||
|
<script id=localstorage>
|
||||||
|
testing.expectEqual(0, localStorage.length);
|
||||||
|
testing.expectEqual(null, localStorage.getItem('foo'));
|
||||||
|
|
||||||
|
localStorage.setItem('foo', 'bar');
|
||||||
|
testing.expectEqual(1, localStorage.length)
|
||||||
|
testing.expectEqual('bar', localStorage.getItem('foo'));
|
||||||
|
|
||||||
|
localStorage.removeItem('foo');
|
||||||
|
testing.expectEqual(0, localStorage.length)
|
||||||
|
testing.expectEqual(null, localStorage.getItem('foo'));
|
||||||
|
|
||||||
|
localStorage['foo'] = 'bar';
|
||||||
|
testing.expectEqual(1, localStorage.length);
|
||||||
|
testing.expectEqual('bar', localStorage['foo']);
|
||||||
|
|
||||||
|
localStorage.setItem('a', '1');
|
||||||
|
localStorage.setItem('b', '2');
|
||||||
|
localStorage.setItem('c', '3');
|
||||||
|
testing.expectEqual(3, localStorage.length)
|
||||||
|
localStorage.clear();
|
||||||
|
localStorage.length", "0" },
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user