view web/rdfdb-synced-graph_test.html @ 2405:69ca2b2fc133

overcomplicated attempt at persisting the pane layout in the rdf graph this was hard because we have to somehow wait for the graph to load before config'ing the panes
author drewp@bigasterisk.com
date Fri, 17 May 2024 16:58:26 -0700
parents 4556eebe5d73
children
line wrap: on
line source

<!doctype html>
<html>
  <head>
    <title>rdfdb-synced-graph test</title>
    <meta charset="utf-8">
    <script src="/node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js"></script>
    <script src="/node_modules/mocha/mocha.js"></script>
    <script src="/node_modules/chai/chai.js"></script>
    <link rel="stylesheet" media="all" href="/node_modules/mocha/mocha.css">
    <link rel="import" href="/lib/polymer/lib/elements/dom-bind.html">

    <link rel="import" href="rdfdb-synced-graph.html">
  </head>
  <body>
    <div id="mocha"><p><a href=".">Index</a></p></div>
    <div id="messages"></div>
    <div id="fixtures">
      <dom-bind>
        <template>
          <rdfdb-synced-graph id="graph" test-graph="true" graph="{{graph}}"></rdfdb-synced-graph>
        </template>
      </dom-bind>
    </div>
    
    <script>
     mocha.setup('bdd');
     const assert = chai.assert;
     
     describe("rdfdb-synced-graph", () => {
       let elem, U;
       beforeEach(() => {
         elem = document.querySelector("#graph");
         window.g = elem;
         elem.graph.clearGraph();
         U = elem.graph.Uri.bind(elem.graph);
       });
       it("makes a node", () => {
         assert.equal(elem.tagName, "RDFDB-SYNCED-GRAPH");
       });
       it("loads trig", (done) => {
         elem.graph.loadTrig(`
                       @prefix : <http://light9.bigasterisk.com/> .
                       :a :b :c :d .
                     `, () => {
                       assert.equal(elem.graph.quads().length, 1);
                       done();
                     });
       });
       describe("floatValue read call", () => {
         it("loads two values without confusing them in a cache", (done) => {
           elem.graph.loadTrig(`
               @prefix : <http://light9.bigasterisk.com/> .
               :s :a 1 :g .
               :s :b 2 :g .
             `, () => {
               assert.equal(elem.graph.floatValue(U(":s"), U(":a")), 1);
               assert.equal(elem.graph.floatValue(U(":s"), U(":b")), 2);
               assert.equal(elem.graph.floatValue(U(":s"), U(":a")), 1);
               done();
             });
         });
       });
     }); 
     mocha.run();
    </script>
  </body>
</html>