"server": "npx http-server ./ -d",
"test": "npx karma start .config/karma.conf.js",
"test:ci": "karma start .config/karma.conf.saucelabs.js",
- "test:svgdom": "node -r esm ./spec/run.js || true",
+ "test:svgdom": "node -r esm ./spec/runSVGDomTest.js || true",
"test:es6": "npx karma start .config/karma.es6.js --single-run",
"prepublishOnly": "npm run build && npm run build:polyfills && npm test",
"postPublish": "echo Please upload a zip to the github release containing the dist, license and changelog"
+++ /dev/null
-import Jasmine from 'jasmine'
-import svgdom from 'svgdom'
-
-import { buildCanvas, buildFixtures, clear } from './helpers.js'
-import { registerWindow } from '../src/main.js'
-
-const jasmine = new Jasmine()
-
-//jasmine.loadConfigFile('spec/support/jasmine.json')
-
-jasmine.loadConfig({
- "spec_dir": "spec/spec",
- "spec_files": [
- "types/*.js",
- // "!(helpers).js"
- ],
- "helpers": [
- // "helpers.js"
- ]
-})
-
-jasmine.jasmine.currentEnv_.beforeEach(() => {
- let win = /*new*/ svgdom
- registerWindow(win, win.document)
- buildCanvas()
- buildFixtures()
- global.container = win.document.getElementById('canvas')
-})
-
-jasmine.jasmine.currentEnv_.afterEach(() => {
- clear()
- global.container = null
- registerWindow()
-})
-
-jasmine.execute()
--- /dev/null
+/*
+ This file has to be run with esm because node does not understand imports yet:
+ node -r esm ./spec/runSvgdomTest.js || true
+
+ Without "|| true" node reports a super long error when a test fails
+ */
+
+import Jasmine from 'jasmine'
+const jasmine = new Jasmine()
+
+jasmine.loadConfig({
+ "spec_dir": "spec/",
+ "spec_files": [
+ "spec/types/*.js",
+ "spec/utils/*.js"
+ ],
+ "helpers": [
+ "setupSVGDom.js"
+ ]
+})
+
+jasmine.execute()
--- /dev/null
+import svgdom from 'svgdom'
+
+import { buildCanvas, buildFixtures, clear } from './helpers.js'
+import { registerWindow } from '../src/main.js'
+
+function setup () {
+ let win = /*new*/ svgdom
+ registerWindow(win, win.document)
+ buildCanvas()
+ buildFixtures()
+ global.container = win.document.getElementById('canvas')
+}
+
+function teardown () {
+ clear()
+ global.container = null
+ registerWindow()
+}
+
+beforeEach(setup)
+afterEach(teardown)
root
} from '../../../src/main.js'
-import { getWindow } from '../../../src/utils/window.js'
import { mockAdopt } from '../../../src/utils/adopter.js'
import { buildFixtures } from '../../helpers.js'
-
-const Node = getWindow().Node
+import { globals } from '../../../src/utils/window.js'
describe('Adopter.js', () => {
+ let Node
+
+ beforeEach(() => {
+ Node = globals.window.Node
+ })
+
describe('makeNode()', () => {
it('creates a node of the specified type', () => {
let rect = makeNode('rect')
it('searches for element in dom if selector given', () => {
buildFixtures()
- let path = getWindow().document.getElementById('lineAB')
+ let path = globals.window.document.getElementById('lineAB')
makeInstance('#lineAB')
makeInstance('#doesNotExist')
})
it('returns the node if one is passed', () => {
- let div = document.createElement('div')
- expect(nodeOrNew('something', div)).toBe(div)
+ let div = globals.window.document.createElement('div')
+ let node = nodeOrNew('something', div)
+
+ // jasmine chucks on this when using the node directly
+ expect(node.outerHTML).toBe(div.outerHTML)
})
})