-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9451137
commit 95e8006
Showing
32 changed files
with
3,013 additions
and
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
recursive: true, | ||
reporter: 'dot', | ||
require: [require.resolve('./test/utils/setup')], | ||
}; |
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,79 @@ | ||
const path = require('path'); | ||
|
||
const errorCodesPath = path.resolve(__dirname, './docs/public/static/error-codes.json'); | ||
const missingError = process.env.MUI_EXTRACT_ERROR_CODES === 'true' ? 'write' : 'annotate'; | ||
|
||
let defaultPresets; | ||
|
||
// We release a ES version of Material-UI. | ||
// It's something that matches the latest official supported features of JavaScript. | ||
// Nothing more (stage-1, etc), nothing less (require, etc). | ||
if (process.env.BABEL_ENV === 'es') { | ||
defaultPresets = []; | ||
} else { | ||
defaultPresets = [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
bugfixes: true, | ||
modules: ['esm', 'production-umd'].includes(process.env.BABEL_ENV) ? false : 'commonjs', | ||
}, | ||
], | ||
]; | ||
} | ||
|
||
const defaultAlias = { | ||
'@material-ui/x-grid': './packages/grid/x-grid/src', | ||
'@material-ui/x-grid-modules': './packages/grid/x-grid-modules/src', | ||
'@material-ui/x-license': './packages/license/src', | ||
'@material-ui/data-grid': './packages/grid/data-grid/src', | ||
}; | ||
|
||
module.exports = { | ||
presets: defaultPresets.concat(['@babel/preset-react', '@babel/preset-typescript']), | ||
plugins: [ | ||
[ | ||
'babel-plugin-macros', | ||
{ | ||
muiError: { | ||
errorCodesPath, | ||
missingError, | ||
}, | ||
}, | ||
], | ||
'babel-plugin-optimize-clsx', | ||
['@babel/plugin-proposal-class-properties', { loose: true }], | ||
['@babel/plugin-proposal-object-rest-spread', { loose: true }], | ||
// any package needs to declare 7.4.4 as a runtime dependency. default is ^7.0.0 | ||
['@babel/plugin-transform-runtime', { version: '^7.4.4' }], | ||
// for IE 11 support | ||
'@babel/plugin-transform-object-assign', | ||
], | ||
ignore: [/@babel[\\|/]runtime/], // Fix a Windows issue. | ||
env: { | ||
coverage: { | ||
plugins: [ | ||
'babel-plugin-istanbul', | ||
[ | ||
'babel-plugin-module-resolver', | ||
{ | ||
root: ['./'], | ||
alias: defaultAlias, | ||
}, | ||
], | ||
], | ||
}, | ||
test: { | ||
sourceMaps: 'both', | ||
plugins: [ | ||
[ | ||
'babel-plugin-module-resolver', | ||
{ | ||
root: ['./'], | ||
alias: defaultAlias, | ||
}, | ||
], | ||
], | ||
}, | ||
}, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import * as React from 'react'; | ||
import { createClientRender, act } from 'test/utils'; | ||
import { expect } from 'chai'; | ||
import { XGrid } from '@material-ui/x-grid'; | ||
|
||
async function sleep(duration: number) { | ||
return new Promise((resolve) => { | ||
setTimeout(() => { | ||
resolve(); | ||
}, duration); | ||
}); | ||
} | ||
|
||
describe('<XGrid />', () => { | ||
const render = createClientRender(); | ||
|
||
it('should resize the width of the columns', async function test() { | ||
if (/jsdom/.test(window.navigator.userAgent)) { | ||
// TODO: Unclear why this fails. Not important | ||
// since a browser test gives us more confidence anyway | ||
this.skip(); | ||
} | ||
|
||
function App(props) { | ||
const { width = 300 } = props; | ||
return ( | ||
<div style={{ width, height: 300 }}> | ||
<XGrid | ||
rows={[ | ||
{ | ||
brand: 'Nike', | ||
}, | ||
]} | ||
columns={[ | ||
{ field: 'id', hide: true }, | ||
{ field: 'brand', width: 100 }, | ||
]} | ||
options={{ checkboxSelection: true }} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
const { container, setProps } = render(<App />); | ||
let rect; | ||
rect = container.querySelector('[role="row"][data-rowindex="0"]').getBoundingClientRect(); | ||
expect(rect.width).to.equal(300 - 2); | ||
setProps({ width: 400 }); | ||
act(() => { | ||
window.dispatchEvent(new window.Event('resize', {})); | ||
}); | ||
await sleep(200); | ||
rect = container.querySelector('[role="row"][data-rowindex="0"]').getBoundingClientRect(); | ||
expect(rect.width).to.equal(400 - 2); | ||
}); | ||
}); |
Oops, something went wrong.