comparison web/rdfdb-synced-graph_test.html @ 2376:4556eebe5d73

topdir reorgs; let pdm have its src/ dir; separate vite area from light9/
author drewp@bigasterisk.com
date Sun, 12 May 2024 19:02:10 -0700
parents light9/web/rdfdb-synced-graph_test.html@4bc24f91b6f1
children
comparison
equal deleted inserted replaced
2375:623836db99af 2376:4556eebe5d73
1 <!doctype html>
2 <html>
3 <head>
4 <title>rdfdb-synced-graph test</title>
5 <meta charset="utf-8">
6 <script src="/node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js"></script>
7 <script src="/node_modules/mocha/mocha.js"></script>
8 <script src="/node_modules/chai/chai.js"></script>
9 <link rel="stylesheet" media="all" href="/node_modules/mocha/mocha.css">
10 <link rel="import" href="/lib/polymer/lib/elements/dom-bind.html">
11
12 <link rel="import" href="rdfdb-synced-graph.html">
13 </head>
14 <body>
15 <div id="mocha"><p><a href=".">Index</a></p></div>
16 <div id="messages"></div>
17 <div id="fixtures">
18 <dom-bind>
19 <template>
20 <rdfdb-synced-graph id="graph" test-graph="true" graph="{{graph}}"></rdfdb-synced-graph>
21 </template>
22 </dom-bind>
23 </div>
24
25 <script>
26 mocha.setup('bdd');
27 const assert = chai.assert;
28
29 describe("rdfdb-synced-graph", () => {
30 let elem, U;
31 beforeEach(() => {
32 elem = document.querySelector("#graph");
33 window.g = elem;
34 elem.graph.clearGraph();
35 U = elem.graph.Uri.bind(elem.graph);
36 });
37 it("makes a node", () => {
38 assert.equal(elem.tagName, "RDFDB-SYNCED-GRAPH");
39 });
40 it("loads trig", (done) => {
41 elem.graph.loadTrig(`
42 @prefix : <http://light9.bigasterisk.com/> .
43 :a :b :c :d .
44 `, () => {
45 assert.equal(elem.graph.quads().length, 1);
46 done();
47 });
48 });
49 describe("floatValue read call", () => {
50 it("loads two values without confusing them in a cache", (done) => {
51 elem.graph.loadTrig(`
52 @prefix : <http://light9.bigasterisk.com/> .
53 :s :a 1 :g .
54 :s :b 2 :g .
55 `, () => {
56 assert.equal(elem.graph.floatValue(U(":s"), U(":a")), 1);
57 assert.equal(elem.graph.floatValue(U(":s"), U(":b")), 2);
58 assert.equal(elem.graph.floatValue(U(":s"), U(":a")), 1);
59 done();
60 });
61 });
62 });
63 });
64 mocha.run();
65 </script>
66 </body>
67 </html>