Skip to content

Instantly share code, notes, and snippets.

View DylanCh's full-sized avatar

H Chen DylanCh

View GitHub Profile
<div class="container">
<main role="main" class="pb-3">
<environment include="Development">
<style>#mocha { display: block; }</style>
<div id="mocha"></div>
</environment>
@RenderBody()
</main>
</div>
<environment include="Development">
<!-- Add Chai and Mocha -->
<link rel="stylesheet" href="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.2.0/chai.min.js"></script>
<script src="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js"></script>
<!-- Add the test file -->
<script src="js/site.test.js"></script>
</environment>
@DylanCh
DylanCh / site.test.js
Last active July 12, 2020 18:56
mocha
'user strict';
const expect = chai.expect,
assert = chai.assert;
mocha.setup('bdd');
describe('libraries',function(){
it('should have jQuery',function(){
expect($).to.not.be.null;
expect($).to.not.equal(undefined);
<pre>{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
fetch('https://json.org/example.html')
.then( x => x.text())
.then(function(html){
var parser = new DOMParser();
var doc = parser.parseFromString(html, "text/html");
var pre = doc.querySelector('pre');
var obj = JSON.parse(pre.innerHTML);
console.log(obj.glossary.GlossDiv.GlossList.GlossEntry.GlossDef.GlossSeeAlso[0])
});
// Step 1: download chromedriver version 70-72 into the project root folder
// Step 2: include this in pom.xml
/*
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
*/
@DylanCh
DylanCh / createVideo.js
Last active May 27, 2019 13:43
document API
var video = document.createElement('video');
// internally console.log calls .toString() if the parameter is not a string.
console.log(video);
/*
output:
[object HTMLVideoElement]
*/
@DylanCh
DylanCh / createInput.js
Created May 27, 2019 13:37
document API
var input = document.createElement('input');
input.type='password';
input.name='p-word';
console.log(input.outerHTML); // <input type="password" name="p-word">
@DylanCh
DylanCh / createDiv.js
Created May 27, 2019 13:30
document API
var div = document.createElement('div');
div.id = 'abc';
div.className = 'col-md-5';
console.log(div.outerHTML); // output: <div id="abc" class="col-md-5"></div>