Skip to content

Commit

Permalink
Added a simple duck test
Browse files Browse the repository at this point in the history
  • Loading branch information
anvaka committed Mar 16, 2018
1 parent 6122165 commit 6b56889
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${file}"
}
]
}
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Extensible, mobile friendly pan and zoom framework (supports DOM and SVG).",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"test": "tap test/*.js",
"build": "browserify -s panzoom ./index.js > dist/panzoom.js && uglifyjs dist/panzoom.js > dist/panzoom.min.js"
},
"keywords": [
Expand All @@ -22,5 +22,9 @@
"dependencies": {
"amator": "^1.0.1",
"wheel": "0.0.4"
},
"devDependencies": {
"jsdom": "^11.6.2",
"tap": "^11.1.2"
}
}
19 changes: 19 additions & 0 deletions test/panzoom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var test = require('tap').test;
var JSDOM = require("jsdom").JSDOM;
var globalDom = new JSDOM('', { pretendToBeVisual: true });
global.window = globalDom.window;
global.document = globalDom.window.document;
global.HTMLElement = globalDom.window.HTMLElement;
global.SVGElement = globalDom.window.SVGElement;

test('it can be created', (t) => {
// Note - have to do it after globals initialized.
var createPanzoom = require('../');
var dom = new JSDOM(`<body><div class='content'></div></body>`);
const document = dom.window.document;
var content = document.querySelector('.content');

var panzoom = createPanzoom(content);
t.ok(panzoom, 'Created');
t.end();
});

0 comments on commit 6b56889

Please sign in to comment.