-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactors helpers Refactors and cleans up tests
- Loading branch information
1 parent
9ebdc15
commit f8a1575
Showing
13 changed files
with
245 additions
and
268 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
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
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
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
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
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
const setupOmnitableFixture = (omnitableFixtureName, data, callback) => { | ||
const omnitable = fixture(omnitableFixtureName); | ||
omnitable.data = data; | ||
if (omnitable.visibleColumns != null && omnitable.visibleColumns.length) { | ||
callback(omnitable); | ||
} else { | ||
// In Polymer 1.x, the visible-columns-changed event will be fire multiple times, | ||
// causing done to be called multiple times, which mocha does not allow. | ||
// So using a flag to prevent multiple calls to done. | ||
const onVisible = () => { | ||
const columns = omnitable.visibleColumns; | ||
if (Array.isArray(columns) && columns.length > 0) { | ||
omnitable.removeEventListener('visible-columns-changed', onVisible); | ||
Polymer.Base.async(() => callback(omnitable), 60); | ||
} | ||
}; | ||
|
||
omnitable.addEventListener('visible-columns-changed', onVisible); | ||
} | ||
|
||
omnitable.notifyResize(); | ||
return omnitable; | ||
}; | ||
|
||
// Detect dom type: dom=shadow vs wc-shadydom=true | ||
const getDomType = () => { | ||
// match GET parameter named 'dom' | ||
let param = window.location.search.match(/(\?|&)dom\=([^&]*)/), // eslint-disable-line no-useless-escape | ||
dom; | ||
if (Array.isArray(param) && param.length > 0) { | ||
dom = decodeURIComponent(param[2]); | ||
} | ||
const domType = dom && dom === 'shadow' ? ' | Using shadow DOM' : ' | Using shady DOM'; | ||
return domType; | ||
}; | ||
|
||
const onColumnReady = (omnitable, columnIndex, done) => { | ||
const checkReady = () => { | ||
const {visibleColumns: visible, columns} = omnitable; | ||
if (visible && visible.length > 0) { | ||
omnitable.removeEventListener('visible-columns-changed', checkReady); | ||
Polymer.Base.async(() => done(columns[columnIndex]), 30); | ||
} | ||
}; | ||
omnitable.addEventListener('visible-columns-changed', checkReady); | ||
omnitable.notifyResize(); | ||
checkReady(); | ||
}; | ||
|
||
Object.assign(window, {setupOmnitableFixture, getDomType, onColumnReady}); | ||
}()); | ||
|
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
Oops, something went wrong.