Skip to content

Instantly share code, notes, and snippets.

@frogcat
Created June 21, 2016 06:16
Show Gist options
  • Save frogcat/113a408b1b29f68f71f59b5143e1a24b to your computer and use it in GitHub Desktop.
Save frogcat/113a408b1b29f68f71f59b5143e1a24b to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Standard Area Code RDFSchema Test</title>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.0.0.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="https://code.jquery.com/qunit/qunit-2.0.0.js"></script>
<script>
function sparql(query) {
return fetch("http://data.e-stat.go.jp/lod/sparql/query", {
method: "POST",
body: "query=" + encodeURIComponent(
["PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>",
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>",
"PREFIX sacs: <http://data.e-stat.go.jp/lod/terms/sacs#>",
query
].join(" ")
),
headers: {
"Accept": "application/sparql-results+json",
"Content-Type": "application/x-www-form-urlencoded"
}
}).then(a => a.json());
}
var tests = [
"ASK { ?s a sacs:CodeChangeEvent, sacs:StandardAreaCode. }",
"ASK { sacs:reasonForChange rdfs:domain sacs:StandardAreaCode. }",
"ASK { sacs:CodeChangeEvent a rdf:Class. }"
];
QUnit.test("a test", function(assert) {
var done = assert.async();
Promise.all(tests.map(a => sparql(a))).then(a => {
a.forEach((b, i) => {
assert.notOk(b.boolean, tests[i] + " must be false.");
});
done();
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment