forked from ksc-fe/kpc
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
26 changed files
with
225 additions
and
203 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 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 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,46 @@ | ||
import * as React from 'react'; | ||
import * as ReactDOM from 'react-dom'; | ||
import {Component, createRef} from 'intact'; | ||
import {mount, unmount, testDemos, wait, nextFrame} from '../../../test/utils'; | ||
import {matchSnapshot} from 'chai-karma-snapshot'; | ||
import mx from '../components/diagram/mxgraph/mx'; | ||
import '../../../test/test.styl'; | ||
|
||
chai.use(matchSnapshot); | ||
|
||
mx.mxClient.IS_POINTER = false; | ||
|
||
const testsContext = require.context('../components/', true, /index\.react\.spec\.ts/); | ||
testsContext.keys().forEach(testsContext); | ||
|
||
// const reactReq = require.context('~/components/', true, /^((?!(affix|code|layout)).)*\/demos\/.*react\.tsx$/); | ||
const reactReq = require.context('~/components/', true, /^((?!(affix|code)).)*\/demos\/.*react\.tsx$/); | ||
// const reactReq = require.context('~/components/', true, /button\/demos\/.*react\.tsx$/); | ||
|
||
describe('React Demos', () => { | ||
afterEach(() => unmount()); | ||
|
||
function wrap(Demo: any) { | ||
return class extends Component { | ||
static template = '<div ref={this.elementRef}></div>'; | ||
private elementRef = createRef<HTMLElement>(); | ||
|
||
mounted() { | ||
ReactDOM.render( | ||
React.createElement(Demo), | ||
this.elementRef.value! | ||
); | ||
} | ||
|
||
beforeUnmount() { | ||
ReactDOM.unmountComponentAtNode(this.elementRef.value!); | ||
} | ||
} | ||
} | ||
|
||
testDemos(reactReq, async (Demo) => { | ||
const [instance, element] = mount(wrap(Demo as any)); | ||
await wait(); | ||
expect(element.innerHTML).to.matchSnapshot(); | ||
}); | ||
}); |
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,50 @@ | ||
const {webpackConfigReact} = require('../../../test/webpack'); | ||
const path = require('path'); | ||
const os = require('os'); | ||
|
||
// for get font files | ||
// https://github.com/ryanclark/karma-webpack/issues/498#issuecomment-790040818 | ||
const output = { | ||
path: path.join(os.tmpdir(), '_karma_webpack_') + Math.floor(Math.random() * 1000000), | ||
}; | ||
|
||
module.exports = function (config) { | ||
config.set({ | ||
browsers: process.env.UPDATE || process.env.CI ? ['MyChromeHeadless'] : undefined, | ||
customLaunchers: { | ||
'MyChromeHeadless': { | ||
base: 'ChromeHeadless', | ||
flags: ['--window-size=1920,1080'], | ||
} | ||
}, | ||
frameworks: ['webpack', 'mocha', 'sinon-chai', 'snapshot', 'mocha-snapshot'], | ||
reporters: ['mocha'], | ||
files: [ | ||
'./index.ts', | ||
// '**/__snapshots__/**/*.md', | ||
], | ||
preprocessors: { | ||
'./index.ts': ['webpack', 'sourcemap'], | ||
// '**/__snapshots__/**/*.md': ['snapshot'], | ||
}, | ||
webpack: {...webpackConfigReact().toConfig(), output}, | ||
webpackMiddleware: { | ||
// noInfo: true | ||
}, | ||
// autoWatch: true, | ||
mochaReporter: { | ||
showDiff: true, | ||
}, | ||
client: { | ||
mocha: { | ||
reporter: 'html', | ||
ui: 'bdd', | ||
} | ||
}, | ||
// snapshot: { | ||
// update: process.env.UPDATE === '1', | ||
// }, | ||
// logLevel: config.LOG_INFO, | ||
// singleRun: true, | ||
}); | ||
}; |
Oops, something went wrong.