-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Begins splitting things apart to be more compatible with not assuming QUnit is am ambient global.
- Loading branch information
Showing
5 changed files
with
71 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import DOMAssertions from './assertions'; | ||
|
||
declare global { | ||
interface Assert { | ||
dom(target?: string | Element | null, rootElement?: Element): DOMAssertions; | ||
} | ||
} | ||
|
||
export default function (QUnit: QUnit) { | ||
QUnit.assert.dom = function ( | ||
target?: string | Element | null, | ||
rootElement?: Element | ||
): DOMAssertions { | ||
if (!isValidRootElement(rootElement)) { | ||
throw new Error(`${rootElement} is not a valid root element`); | ||
} | ||
|
||
rootElement = rootElement || this.dom.rootElement || document; | ||
|
||
if (arguments.length === 0) { | ||
target = rootElement; | ||
} | ||
|
||
return new DOMAssertions(target, rootElement, this); | ||
}; | ||
|
||
function isValidRootElement(element: any): element is Element { | ||
return ( | ||
!element || | ||
(typeof element === 'object' && | ||
typeof element.querySelector === 'function' && | ||
typeof element.querySelectorAll === 'function') | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* global QUnit */ | ||
|
||
import install from './install'; | ||
|
||
install(QUnit); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import * as QUnit from 'qunit'; | ||
import install from './install'; | ||
|
||
install(QUnit); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,38 @@ | ||
import typescript from 'rollup-plugin-typescript2'; | ||
|
||
export default { | ||
input: 'lib/qunit-dom.ts', | ||
const typescriptConfiguration = { | ||
exclude: [ | ||
'node_modules/**', | ||
'lib/**/__tests__/**', | ||
'lib/**/*.test.ts', | ||
'lib/helpers/test-assertions.ts', | ||
], | ||
}; | ||
|
||
const iifeBundle = { | ||
input: 'lib/qunit-dom-globals.ts', | ||
|
||
external: ['qunit'], | ||
plugins: [ | ||
typescript({ | ||
exclude: [ | ||
'node_modules/**', | ||
'lib/**/__tests__/**', | ||
'lib/**/*.test.ts', | ||
'lib/helpers/test-assertions.ts', | ||
], | ||
}), | ||
], | ||
plugins: [typescript(typescriptConfiguration)], | ||
|
||
output: { | ||
file: 'dist/qunit-dom.js', | ||
format: 'iife', | ||
sourcemap: true, | ||
}, | ||
}; | ||
|
||
const esBundle = { | ||
input: 'lib/qunit-dom-modules.ts', | ||
|
||
external: ['qunit'], | ||
plugins: [typescript(typescriptConfiguration)], | ||
|
||
output: { | ||
file: 'dist/qunit-dom.es.js', | ||
format: 'es', | ||
sourcemap: true, | ||
}, | ||
}; | ||
|
||
export default [iifeBundle, esBundle]; |