-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#166566930] synchronize the config from the private repo
- Loading branch information
1 parent
817791b
commit cd05064
Showing
11 changed files
with
3,685 additions
and
726 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,3 @@ | ||
last 1 chrome version | ||
last 1 firefox version | ||
last 1 safari version |
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,23 @@ | ||
module.exports = function(api) { | ||
api.cache(true); | ||
return { | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
useBuiltIns: 'usage', | ||
corejs: 3, | ||
}, | ||
], | ||
'@babel/preset-react', | ||
'@babel/preset-typescript', | ||
], | ||
plugins: [ | ||
'babel-plugin-lodash', | ||
'@babel/plugin-proposal-optional-chaining', | ||
'@babel/plugin-syntax-dynamic-import', | ||
['@babel/plugin-proposal-class-properties', { loose: true }], | ||
['@babel/plugin-transform-runtime', { corejs: 3 }], | ||
], | ||
}; | ||
}; |
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,2 @@ | ||
declare module '*.css'; | ||
declare module 'memoize-one'; |
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 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,67 @@ | ||
import React, {ComponentClass} from 'react'; | ||
|
||
let componentFakes: any[] = []; | ||
let oldCreateElement: typeof React.createElement; | ||
|
||
beforeEach(function () { | ||
oldCreateElement = React.createElement.bind(React); | ||
componentFakes = []; | ||
|
||
// @ts-ignore | ||
spyOn(React, 'createElement').and.callFake(function (type, props, ...children) { | ||
let fake = componentFakes.find(f => f.componentClass === type); | ||
if (fake) { | ||
type = fake.replacementClass; | ||
} | ||
return oldCreateElement(type, props, ...children); | ||
}); | ||
}); | ||
|
||
function name(klass: any) { | ||
return klass.displayName || klass.name || klass.toString(); | ||
} | ||
|
||
function createMockReactClass(Klass: any) { | ||
return class extends React.Component { | ||
static displayName = `Mock${name(Klass)}`; | ||
static propTypes = {...Klass.propTypes}; | ||
static contextTypes = {...Klass.contextTypes}; | ||
|
||
render() { | ||
return <div>{this.props.children}</div>; | ||
} | ||
} | ||
} | ||
|
||
function createWrappedReactClass(Klass: any) { | ||
return class extends React.Component { | ||
static displayName = `Mock${name(Klass)}`; | ||
static propTypes = {...Klass.propTypes}; | ||
static contextTypes = {...Klass.contextTypes}; | ||
|
||
render() { | ||
return oldCreateElement(Klass, this.props); | ||
} | ||
} | ||
} | ||
|
||
|
||
export function mockComponent(componentClass: any): ReturnType<typeof createMockReactClass> { | ||
const alreadyMocked = componentFakes.find(cf => cf.componentClass === componentClass); | ||
expect(alreadyMocked).toBeUndefined('This component has already been replaced'); | ||
let fakeComponentClass = createMockReactClass(componentClass); | ||
|
||
componentFakes.push({componentClass: componentClass, replacementClass: fakeComponentClass}); | ||
|
||
return fakeComponentClass; | ||
} | ||
|
||
export function wrapComponent(componentClass: any): ReturnType<typeof createWrappedReactClass> { | ||
const alreadyMocked = componentFakes.find(cf => cf.componentClass === componentClass); | ||
expect(alreadyMocked).toBeUndefined('This component has already been replaced'); | ||
let wrappedComponentClass = createWrappedReactClass(componentClass); | ||
|
||
componentFakes.push({componentClass: componentClass, replacementClass: wrappedComponentClass}); | ||
|
||
return wrappedComponentClass; | ||
} |
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,17 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"allowSyntheticDefaultImports": true, | ||
"checkJs": false, | ||
"jsx": "preserve", | ||
"module": "commonjs", | ||
"noEmit": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"target": "esnext" | ||
}, | ||
"include": [ | ||
"./bundles/**/*" | ||
], | ||
"typeRoots": ["./bundles/typings", "./node_modules/@types"] | ||
} |
Oops, something went wrong.