type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
ArrowFunction
()=> { it("should invoke the JcadContextManager with the JarsConnectorRefs.DELETE_CONNECTOR_REF reference", function() { sinon.assert.calledOnce(getContextSpy); sinon.assert.calledWith( getContextSpy, JarsConnectorRefs.DELETE_CONNECTOR_REF ); }); it("should invoke the DecoratorConnectorManager with the JarsConnectorRefs.DELETE_CONNECTOR_REF reference and the correct JCAD context", function() { sinon.assert.calledOnce(getDecoratorSpy); sinon.assert.calledWith( getDecoratorSpy, JarsConnectorRefs.DELETE_CONNECTOR_REF, context ); }); it("should invoke the annotation decorator with the right parameters", function() { sinon.assert.calledOnce(annotationSpy); //sinon.assert.calledWith(getDecoratorSpy, params.HTTP_METHOD_PARAMS); }); it("should invoke the registered decorator with the right method name and parameters", function() { sinon.assert.calledOnce(decorateSpy); //sinon.assert.calledWith(getDecoratorSpy, params.HTTP_METHOD_PARAMS); }); }
jec-project/jec-jars
test/com/jec/jars/annotations/DELETETest.ts
TypeScript
ArrowFunction
(region: string, options?: any) => { let regionInfo: RegionInfo | undefined = undefined; switch (region) { // First, try to match exact region names. case "af-south-1": regionInfo = { hostname: "route53resolver.af-south-1.amazonaws.com", partition: "aws", }; break; case "ap-east-1": regionInfo = { hostname: "route53resolver.ap-east-1.amazonaws.com", partition: "aws", }; break; case "ap-northeast-1": regionInfo = { hostname: "route53resolver.ap-northeast-1.amazonaws.com", partition: "aws", }; break; case "ap-northeast-2": regionInfo = { hostname: "route53resolver.ap-northeast-2.amazonaws.com", partition: "aws", }; break; case "ap-northeast-3": regionInfo = { hostname: "route53resolver.ap-northeast-3.amazonaws.com", partition: "aws", }; break; case "ap-south-1": regionInfo = { hostname: "route53resolver.ap-south-1.amazonaws.com", partition: "aws", }; break; case "ap-southeast-1": regionInfo = { hostname: "route53resolver.ap-southeast-1.amazonaws.com", partition: "aws", }; break; case "ap-southeast-2": regionInfo = { hostname: "route53resolver.ap-southeast-2.amazonaws.com", partition: "aws", }; break; case "ca-central-1": regionInfo = { hostname: "route53resolver.ca-central-1.amazonaws.com", partition: "aws", }; break; case "cn-north-1": regionInfo = { hostname: "route53resolver.cn-north-1.amazonaws.com.cn", partition: "aws-cn", }; break; case "cn-northwest-1": regionInfo = { hostname: "route53resolver.cn-northwest-1.amazonaws.com.cn", partition: "aws-cn", }; break; case "eu-central-1": regionInfo = { hostname: "route53resolver.eu-central-1.amazonaws.com", partition: "aws", }; break; case "eu-north-1": regionInfo = { hostname: "route53resolver.eu-north-1.amazonaws.com", partition: "aws", }; break; case "eu-south-1": regionInfo = { hostname: "route53resolver.eu-south-1.amazonaws.com", partition: "aws", }; break; case "eu-west-1": regionInfo = { hostname: "route53resolver.eu-west-1.amazonaws.com", partition: "aws", }; break; case "eu-west-2": regionInfo = { hostname: "route53resolver.eu-west-2.amazonaws.com", partition: "aws", }; break; case "eu-west-3": regionInfo = { hostname: "route53resolver.eu-west-3.amazonaws.com", partition: "aws", }; break; case "me-south-1": regionInfo = { hostname: "route53resolver.me-south-1.amazonaws.com", partition: "aws", }; break; case "sa-east-1": regionInfo = { hostname: "route53resolver.sa-east-1.amazonaws.com", partition: "aws", }; break; case "us-east-1": regionInfo = { hostname: "route53resolver.us-east-1.amazonaws.com", partition: "aws", }; break; case "us-east-2": regionInfo = { hostname: "route53resolver.us-east-2.amazonaws.com", partition: "aws", }; break; case "us-gov-east-1": regionInfo = { hostname: "route53resolver.us-gov-east-1.amazonaws.com", partition: "aws-us-gov", }; break; case "us-gov-west-1": regionInfo = { hostname: "route53resolver.us-gov-west-1.amazonaws.com", partition: "aws-us-gov", }; break; case "us-west-1": regionInfo = { hostname: "route53resolver.us-west-1.amazonaws.com", partition: "aws", }; break; case "us-west-2": regionInfo = { hostname: "route53resolver.us-west-2.amazonaws.com", partition: "aws", }; break; // Next, try to match partition endpoints. default: if (AWS_REGIONS.has(region)) { regionInfo = { hostname: AWS_TEMPLATE.replace("{region}", region), partition: "aws", }; } if (AWS_CN_REGIONS.has(region)) { regionInfo = { hostname: AWS_CN_TEMPLATE.replace("{region}", region), partition: "aws-cn", }; } if (AWS_ISO_REGIONS.has(region)) { regionInfo = { hostname: AWS_ISO_TEMPLATE.replace("{region}", region), partition: "aws-iso", }; } if (AWS_ISO_B_REGIONS.has(region)) { regionInfo = { hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), partition: "aws-iso-b", }; } if (AWS_US_GOV_REGIONS.has(region)) { regionInfo = { hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), partition: "aws-us-gov", }; } // Finally, assume it's an AWS partition endpoint. if (regionInfo === undefined) { regionInfo = { hostname: AWS_TEMPLATE.replace("{region}", region), partition: "aws", }; } } return Promise.resolve({ signingService: "route53resolver", ...regionInfo }); }
Acium-Global/aws-sdk-js-v3
clients/client-route53resolver/endpoints.ts
TypeScript
ArrowFunction
() => { const history = useHistory(); const location = useLocation(); const loadedUser = useSelector((state: ReduxState) => state.users.loadedUser); const authenticated = useSelector((state: ReduxState) => state.users.authenticated); const dispatch = useDispatch(); const dispatchLoadUser = React.useCallback(() => dispatch(_users.loadSession()), [dispatch]); /** * Automatically redirect based on authentication */ React.useEffect(() => { if (!loadedUser) { dispatchLoadUser(); } else { if (!authenticated) { history.push("/login"); } else if (location.pathname === "/login") { history.push("/"); } } }, [authenticated, dispatchLoadUser, history, loadedUser, location.pathname]); return ( <Switch> <Route path="/login" component={LoginPage} /> <Route path="/" component={App} /> </Switch>
Nashoba-EMS/emt-desktop
src/EntryPoint.tsx
TypeScript
ArrowFunction
(state: ReduxState) => state.users.loadedUser
Nashoba-EMS/emt-desktop
src/EntryPoint.tsx
TypeScript
ArrowFunction
(state: ReduxState) => state.users.authenticated
Nashoba-EMS/emt-desktop
src/EntryPoint.tsx
TypeScript
ArrowFunction
() => dispatch(_users.loadSession())
Nashoba-EMS/emt-desktop
src/EntryPoint.tsx
TypeScript
ArrowFunction
() => { if (!loadedUser) { dispatchLoadUser(); } else { if (!authenticated) { history.push("/login"); } else if (location.pathname === "/login") { history.push("/"); } } }
Nashoba-EMS/emt-desktop
src/EntryPoint.tsx
TypeScript
ArrowFunction
(a: Attachment) => a.type === attachmentType
navikt/foreldrepengesoknad
src/app/components/skjema/vedleggSpørsmål/VedleggSpørsmål.tsx
TypeScript
ClassDeclaration
class VedleggSpørsmål extends React.Component<Props> { constructor(props: Props) { super(props); this.updateVedleggList = this.updateVedleggList.bind(this); this.updateVedleggItem = this.updateVedleggItem.bind(this); this.deleteVedleggItem = this.deleteVedleggItem.bind(this); } updateVedleggItem(vedleggItem: Attachment) { const { vedlegg } = this.props; let vedleggList: Attachment[] = vedlegg || []; const index = vedleggList.indexOf(vedleggItem); if (index >= 0) { vedleggList[index] = vedleggItem; } else { vedleggList = [vedleggItem]; } this.updateVedleggList(vedleggList); } deleteVedleggItem(vedleggItem: Attachment) { const { vedlegg } = this.props; const vedleggList: Attachment[] = vedlegg || []; const index = vedleggList.indexOf(vedleggItem); vedleggList.splice(index, 1); this.updateVedleggList(vedleggList); } updateVedleggList(vedlegg: Attachment[]) { this.props.onChange(vedlegg); } render() { const { vedlegg, skjemanummer, attachmentType } = this.props; return ( <AttachmentsUploader attachments={vedlegg ? vedlegg.filter((a: Attachment) => a.type === attachmentType) : []} onFilesUploadStart={(nyeVedlegg) => { this.updateVedleggList([...(vedlegg || []), ...nyeVedlegg]); }} onFileUploadFinish={this.updateVedleggItem} onFileDelete={this.deleteVedleggItem} attachmentType={attachmentType} skjemanummer={skjemanummer} /> ); }
navikt/foreldrepengesoknad
src/app/components/skjema/vedleggSpørsmål/VedleggSpørsmål.tsx
TypeScript
InterfaceDeclaration
interface OwnProps { vedlegg?: Attachment[]; attachmentType: AttachmentType; onChange: (vedlegg: Attachment[]) => void; skjemanummer: Skjemanummer; intl: IntlShape; }
navikt/foreldrepengesoknad
src/app/components/skjema/vedleggSpørsmål/VedleggSpørsmål.tsx
TypeScript
TypeAliasDeclaration
type Props = OwnProps;
navikt/foreldrepengesoknad
src/app/components/skjema/vedleggSpørsmål/VedleggSpørsmål.tsx
TypeScript
MethodDeclaration
updateVedleggItem(vedleggItem: Attachment) { const { vedlegg } = this.props; let vedleggList: Attachment[] = vedlegg || []; const index = vedleggList.indexOf(vedleggItem); if (index >= 0) { vedleggList[index] = vedleggItem; } else { vedleggList = [vedleggItem]; } this.updateVedleggList(vedleggList); }
navikt/foreldrepengesoknad
src/app/components/skjema/vedleggSpørsmål/VedleggSpørsmål.tsx
TypeScript
MethodDeclaration
deleteVedleggItem(vedleggItem: Attachment) { const { vedlegg } = this.props; const vedleggList: Attachment[] = vedlegg || []; const index = vedleggList.indexOf(vedleggItem); vedleggList.splice(index, 1); this.updateVedleggList(vedleggList); }
navikt/foreldrepengesoknad
src/app/components/skjema/vedleggSpørsmål/VedleggSpørsmål.tsx
TypeScript
MethodDeclaration
updateVedleggList(vedlegg: Attachment[]) { this.props.onChange(vedlegg); }
navikt/foreldrepengesoknad
src/app/components/skjema/vedleggSpørsmål/VedleggSpørsmål.tsx
TypeScript
MethodDeclaration
render() { const { vedlegg, skjemanummer, attachmentType } = this.props; return ( <AttachmentsUploader attachments={vedlegg ? vedlegg.filter((a: Attachment) => a.type === attachmentType) : []} onFilesUploadStart={(nyeVedlegg) => { this.updateVedleggList([...(vedlegg || []), ...nyeVedlegg]); }}
navikt/foreldrepengesoknad
src/app/components/skjema/vedleggSpørsmål/VedleggSpørsmål.tsx
TypeScript
FunctionDeclaration
export function setStore(s: Store) { store = s const state = s.getState() onStoreStartedListeners.forEach(l => l(state)) }
cancerberoSgx/jsx-alone
jsx-explorer/src/store/store.ts
TypeScript
FunctionDeclaration
export function onStoreStarted(l: (s: State) => void) { onStoreStartedListeners.push(l) }
cancerberoSgx/jsx-alone
jsx-explorer/src/store/store.ts
TypeScript
FunctionDeclaration
export function onAfterActionDispatch<T extends AllActions['type']>(type: T, listener: OnActionDispatchListener<T>) { onAfterActionDispatchListeners.push({ type, listener }) }
cancerberoSgx/jsx-alone
jsx-explorer/src/store/store.ts
TypeScript
FunctionDeclaration
export function onBeforeActionDispatch<T extends AllActions['type']>(type: T, listener: OnActionDispatchListener<T>) { onBeforeActionDispatchListeners.push({ type, listener }) }
cancerberoSgx/jsx-alone
jsx-explorer/src/store/store.ts
TypeScript
FunctionDeclaration
export function getState(): State { return store.getState() }
cancerberoSgx/jsx-alone
jsx-explorer/src/store/store.ts
TypeScript
FunctionDeclaration
export function dispatch(action: AllActions) { const state = store.getState() onBeforeActionDispatchListeners!.filter(i => i.type === action.type).forEach(l => l.listener(action, state)) store.dispatch(action) const state2 = store.getState() onAfterActionDispatchListeners!.filter(i => i.type === action.type).forEach(l => l.listener(action, state2)) }
cancerberoSgx/jsx-alone
jsx-explorer/src/store/store.ts
TypeScript
ArrowFunction
l => l(state)
cancerberoSgx/jsx-alone
jsx-explorer/src/store/store.ts
TypeScript
ArrowFunction
i => i.type === action.type
cancerberoSgx/jsx-alone
jsx-explorer/src/store/store.ts
TypeScript
ArrowFunction
l => l.listener(action, state)
cancerberoSgx/jsx-alone
jsx-explorer/src/store/store.ts
TypeScript
ArrowFunction
l => l.listener(action, state2)
cancerberoSgx/jsx-alone
jsx-explorer/src/store/store.ts
TypeScript
TypeAliasDeclaration
export type ActionForType<T extends AllActions['type']> = AllActions extends infer R ? R extends AllActions ? T extends R['type'] ? R : never : never : never
cancerberoSgx/jsx-alone
jsx-explorer/src/store/store.ts
TypeScript
TypeAliasDeclaration
type OnActionDispatchListener<T extends AllActions['type']= AllActions['type']> = (action: ActionForType<T>, state: State) => void
cancerberoSgx/jsx-alone
jsx-explorer/src/store/store.ts
TypeScript
TypeAliasDeclaration
export type AllActions = RequestCodeChangeAction | EditorModelChangedAction | PushLogAction | ChangeAutoApply | SelectExplorer | SetWorking | ChangeThemeAction | FetchCompiledAction | RenderCompiledAction | ErrorCompiledAction | JSXColorsActions
cancerberoSgx/jsx-alone
jsx-explorer/src/store/store.ts
TypeScript
FunctionDeclaration
function createIntlMock() { const intlProvider = new IntlProvider({ locale: 'en-US', messages: messagesMap['en-US'] }, {}); const { intl } = intlProvider.getChildContext(); return intl; }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
FunctionDeclaration
function getResponse(response: string, delay: number): Promise<string> { return new Promise((resolve) => { setTimeout(() => resolve(response), delay); }); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
FunctionDeclaration
function fetchVisObject(uri: string): Promise<VisualizationObject.IVisualizationObject> { const visObj = charts.find(chart => chart.visualizationObject.meta.uri === uri); if (!visObj) { throw new Error(`Unknown uri ${uri}`); } return Promise.resolve(visObj.visualizationObject); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
FunctionDeclaration
function fetchVisualizationClass(visualizationClassUri: string): Promise<VisualizationClass.IVisualizationClass> { const visClass = visualizationClasses.find(vc => vc.visualizationClass.meta.uri === visualizationClassUri); if (!visClass) { throw new Error(`Unknown uri ${visualizationClassUri}`); } return Promise.resolve(visClass.visualizationClass); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
FunctionDeclaration
// tslint:disable-next-line:variable-name function uriResolver(_projectId: string, uri: string, identifier: string): Promise<string> { if (identifier === TABLE_IDENTIFIER || uri === TABLE_URI) { return getResponse(TABLE_URI, FAST); } if (identifier === CHART_IDENTIFIER || uri === CHART_URI) { return getResponse(CHART_URI, SLOW); } return Promise.reject('Unknown identifier'); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
(resolve) => { setTimeout(() => resolve(response), delay); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
() => resolve(response)
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
chart => chart.visualizationObject.meta.uri === uri
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
vc => vc.visualizationClass.meta.uri === visualizationClassUri
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
() => { it('should construct and provide intl', () => { const wrapper = mount( <Visualization projectId={projectId} identifier={CHART_IDENTIFIER} fetchVisObject={fetchVisObject} fetchVisualizationClass={fetchVisualizationClass} uriResolver={uriResolver} BaseChartComponent={BaseChart} /> ); return delay(FAST + 1).then(() => { expect(wrapper.find(IntlWrapper).length).toBe(1); expect(wrapper.find(IntlVisualization).length).toBe(1); }); }); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
() => { const wrapper = mount( <Visualization projectId={projectId} identifier={CHART_IDENTIFIER} fetchVisObject={fetchVisObject} fetchVisualizationClass={fetchVisualizationClass} uriResolver={uriResolver} BaseChartComponent={BaseChart} /> ); return delay(FAST + 1).then(() => { expect(wrapper.find(IntlWrapper).length).toBe(1); expect(wrapper.find(IntlVisualization).length).toBe(1); }); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
() => { expect(wrapper.find(IntlWrapper).length).toBe(1); expect(wrapper.find(IntlVisualization).length).toBe(1); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
() => { const intl = createIntlMock(); it('should render chart', () => { const wrapper = mount( <VisualizationWrapped projectId={projectId} identifier={CHART_IDENTIFIER} fetchVisObject={fetchVisObject} fetchVisualizationClass={fetchVisualizationClass} uriResolver={uriResolver} BaseChartComponent={BaseChart} intl={intl} /> ); return delay(SLOW + 1).then(() => { expect(wrapper.find(BaseChart).length).toBe(1); }); }); it('should render table', () => { const wrapper = mount( <VisualizationWrapped projectId={projectId} identifier={TABLE_IDENTIFIER} fetchVisObject={fetchVisObject} fetchVisualizationClass={fetchVisualizationClass} uriResolver={uriResolver} intl={intl} /> ); const expectedResultSpec: AFM.IResultSpec = { dimensions: [ { itemIdentifiers: ['a1'], totals: [ { attributeIdentifier: 'a1', measureIdentifier: 'm1', type: 'avg' } ] }, { itemIdentifiers: ['measureGroup'] } ], sorts: [ { attributeSortItem: { attributeIdentifier: 'a1', direction: 'asc' } } ] }; const expectedTotals: VisualizationObject.IVisualizationTotal[] = [ { type: 'avg', alias: 'average', measureIdentifier: 'm1', attributeIdentifier: 'a1' } ]; return delay(SLOW).then(() => { expect(wrapper.find(SortableTable).length).toBe(1); expect(wrapper.state('type')).toEqual(VisualizationTypes.TABLE); expect(wrapper.state('dataSource')).not.toBeNull(); expect(wrapper.state('resultSpec')).toEqual(expectedResultSpec); expect(wrapper.state('totals')).toEqual(expectedTotals); }); }); it('should render with uri', () => { const wrapper = mount( <VisualizationWrapped projectId={projectId} uri={CHART_URI} fetchVisObject={fetchVisObject} fetchVisualizationClass={fetchVisualizationClass} uriResolver={uriResolver} BaseChartComponent={BaseChart} intl={intl} /> ); return delay(SLOW + 1).then(() => { expect(wrapper.find(BaseChart).length).toBe(1); }); }); it('should trigger error in case of given uri is not valid', (done) => { const errorHandler = (value: { status: string }) => { expect(value.status).toEqual(ErrorStates.NOT_FOUND); done(); }; mount( <VisualizationWrapped projectId={projectId} uri={'/invalid/url'} onError={errorHandler} intl={intl} /> ); }); it('should handle slow requests', () => { // Response from first request comes back later that from the second one const wrapper = mount( <VisualizationWrapped projectId={projectId} identifier={CHART_IDENTIFIER} uriResolver={uriResolver} fetchVisObject={fetchVisObject} fetchVisualizationClass={fetchVisualizationClass} BaseChartComponent={BaseChart} TableComponent={Table} intl={intl} /> ); wrapper.setProps({ identifier: TABLE_IDENTIFIER }); return delay(SLOW + 1).then(() => { expect(wrapper.find(Table).length).toBe(1); }); }); it('should handle set state on unmounted component', () => { const wrapper = mount( <VisualizationWrapped projectId={projectId} identifier={TABLE_IDENTIFIER} uriResolver={uriResolver} fetchVisObject={fetchVisObject} fetchVisualizationClass={fetchVisualizationClass} BaseChartComponent={BaseChart} TableComponent={Table} intl={intl} /> ); const spy = jest.spyOn(wrapper.instance(), 'setState'); // Would throw an error if not handled properly wrapper.unmount(); return delay(FAST + 1).then(() => { expect(spy).not.toHaveBeenCalled(); spy.mockRestore(); }); }); it('should pass LoadingComponent and ErrorComponent to TableComponent', () => { const wrapper = mount( <VisualizationWrapped projectId={projectId} identifier={TABLE_IDENTIFIER} uriResolver={uriResolver} fetchVisObject={fetchVisObject} fetchVisualizationClass={fetchVisualizationClass} BaseChartComponent={BaseChart} TableComponent={Table} LoadingComponent={LoadingComponent} ErrorComponent={ErrorComponent} intl={intl} /> ); return delay(SLOW + 1).then(() => { expect(wrapper.find(Table).length).toBe(1); const TableElement = wrapper.find(Table).get(0); expect(TableElement.props.LoadingComponent).toBe(LoadingComponent); expect(TableElement.props.ErrorComponent).toBe(ErrorComponent); }); }); it('should pass LoadingComponent and ErrorComponent to BaseChart', () => { const wrapper = mount( <VisualizationWrapped projectId={projectId} identifier={CHART_IDENTIFIER} uriResolver={uriResolver} fetchVisObject={fetchVisObject} fetchVisualizationClass={fetchVisualizationClass} BaseChartComponent={BaseChart} TableComponent={Table} LoadingComponent={LoadingComponent} ErrorComponent={ErrorComponent} intl={intl} /> ); return delay(SLOW + 1).then(() => { expect(wrapper.find(BaseChart).length).toBe(1); const BaseChartElement = wrapper.find(BaseChart).get(0); expect(BaseChartElement.props.LoadingComponent).toBe(LoadingComponent); expect(BaseChartElement.props.ErrorComponent).toBe(ErrorComponent); }); }); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
() => { const wrapper = mount( <VisualizationWrapped projectId={projectId} identifier={CHART_IDENTIFIER} fetchVisObject={fetchVisObject} fetchVisualizationClass={fetchVisualizationClass} uriResolver={uriResolver} BaseChartComponent={BaseChart} intl={intl} /> ); return delay(SLOW + 1).then(() => { expect(wrapper.find(BaseChart).length).toBe(1); }); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
() => { expect(wrapper.find(BaseChart).length).toBe(1); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
() => { const wrapper = mount( <VisualizationWrapped projectId={projectId} identifier={TABLE_IDENTIFIER} fetchVisObject={fetchVisObject} fetchVisualizationClass={fetchVisualizationClass} uriResolver={uriResolver} intl={intl} /> ); const expectedResultSpec: AFM.IResultSpec = { dimensions: [ { itemIdentifiers: ['a1'], totals: [ { attributeIdentifier: 'a1', measureIdentifier: 'm1', type: 'avg' } ] }, { itemIdentifiers: ['measureGroup'] } ], sorts: [ { attributeSortItem: { attributeIdentifier: 'a1', direction: 'asc' } } ] }; const expectedTotals: VisualizationObject.IVisualizationTotal[] = [ { type: 'avg', alias: 'average', measureIdentifier: 'm1', attributeIdentifier: 'a1' } ]; return delay(SLOW).then(() => { expect(wrapper.find(SortableTable).length).toBe(1); expect(wrapper.state('type')).toEqual(VisualizationTypes.TABLE); expect(wrapper.state('dataSource')).not.toBeNull(); expect(wrapper.state('resultSpec')).toEqual(expectedResultSpec); expect(wrapper.state('totals')).toEqual(expectedTotals); }); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
() => { expect(wrapper.find(SortableTable).length).toBe(1); expect(wrapper.state('type')).toEqual(VisualizationTypes.TABLE); expect(wrapper.state('dataSource')).not.toBeNull(); expect(wrapper.state('resultSpec')).toEqual(expectedResultSpec); expect(wrapper.state('totals')).toEqual(expectedTotals); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
() => { const wrapper = mount( <VisualizationWrapped projectId={projectId} uri={CHART_URI} fetchVisObject={fetchVisObject} fetchVisualizationClass={fetchVisualizationClass} uriResolver={uriResolver} BaseChartComponent={BaseChart} intl={intl} /> ); return delay(SLOW + 1).then(() => { expect(wrapper.find(BaseChart).length).toBe(1); }); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
(done) => { const errorHandler = (value: { status: string }) => { expect(value.status).toEqual(ErrorStates.NOT_FOUND); done(); }; mount( <VisualizationWrapped projectId={projectId} uri={'/invalid/url'} onError={errorHandler} intl={intl} /> ); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
(value: { status: string }) => { expect(value.status).toEqual(ErrorStates.NOT_FOUND); done(); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
() => { // Response from first request comes back later that from the second one const wrapper = mount( <VisualizationWrapped projectId={projectId} identifier={CHART_IDENTIFIER} uriResolver={uriResolver} fetchVisObject={fetchVisObject} fetchVisualizationClass={fetchVisualizationClass} BaseChartComponent={BaseChart} TableComponent={Table} intl={intl} /> ); wrapper.setProps({ identifier: TABLE_IDENTIFIER }); return delay(SLOW + 1).then(() => { expect(wrapper.find(Table).length).toBe(1); }); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
() => { expect(wrapper.find(Table).length).toBe(1); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
() => { const wrapper = mount( <VisualizationWrapped projectId={projectId} identifier={TABLE_IDENTIFIER} uriResolver={uriResolver} fetchVisObject={fetchVisObject} fetchVisualizationClass={fetchVisualizationClass} BaseChartComponent={BaseChart} TableComponent={Table} intl={intl} /> ); const spy = jest.spyOn(wrapper.instance(), 'setState'); // Would throw an error if not handled properly wrapper.unmount(); return delay(FAST + 1).then(() => { expect(spy).not.toHaveBeenCalled(); spy.mockRestore(); }); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
() => { expect(spy).not.toHaveBeenCalled(); spy.mockRestore(); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
() => { const wrapper = mount( <VisualizationWrapped projectId={projectId} identifier={TABLE_IDENTIFIER} uriResolver={uriResolver} fetchVisObject={fetchVisObject} fetchVisualizationClass={fetchVisualizationClass} BaseChartComponent={BaseChart} TableComponent={Table} LoadingComponent={LoadingComponent} ErrorComponent={ErrorComponent} intl={intl} /> ); return delay(SLOW + 1).then(() => { expect(wrapper.find(Table).length).toBe(1); const TableElement = wrapper.find(Table).get(0); expect(TableElement.props.LoadingComponent).toBe(LoadingComponent); expect(TableElement.props.ErrorComponent).toBe(ErrorComponent); }); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
() => { expect(wrapper.find(Table).length).toBe(1); const TableElement = wrapper.find(Table).get(0); expect(TableElement.props.LoadingComponent).toBe(LoadingComponent); expect(TableElement.props.ErrorComponent).toBe(ErrorComponent); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
() => { const wrapper = mount( <VisualizationWrapped projectId={projectId} identifier={CHART_IDENTIFIER} uriResolver={uriResolver} fetchVisObject={fetchVisObject} fetchVisualizationClass={fetchVisualizationClass} BaseChartComponent={BaseChart} TableComponent={Table} LoadingComponent={LoadingComponent} ErrorComponent={ErrorComponent} intl={intl} /> ); return delay(SLOW + 1).then(() => { expect(wrapper.find(BaseChart).length).toBe(1); const BaseChartElement = wrapper.find(BaseChart).get(0); expect(BaseChartElement.props.LoadingComponent).toBe(LoadingComponent); expect(BaseChartElement.props.ErrorComponent).toBe(ErrorComponent); }); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
() => { expect(wrapper.find(BaseChart).length).toBe(1); const BaseChartElement = wrapper.find(BaseChart).get(0); expect(BaseChartElement.props.LoadingComponent).toBe(LoadingComponent); expect(BaseChartElement.props.ErrorComponent).toBe(ErrorComponent); }
jakub-sterba/gooddata-react-components
src/components/uri/tests/Visualization.spec.tsx
TypeScript
ArrowFunction
async () => { const a = tf.tensor1d([3, -1, 0, 100, -7, 2]); const r = tf.max(a); expectArraysClose(await r.data(), 100); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const a = tf.tensor1d([3, 3, 3]); const r = tf.max(a); expectArraysClose(await r.data(), 3); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const aData = new Float32Array(1000); aData[0] = 1; const a = tf.tensor1d(aData); const r = tf.max(a); expectArraysClose(await r.data(), 1); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { expectArraysClose(await tf.max([3, NaN, 2]).data(), NaN); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const a = tf.tensor2d([3, -1, 0, 100, -7, 2], [2, 3]); expectArraysClose(await tf.max(a).data(), 100); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const a = tf.tensor2d([3, -1, 0, 100, -7, 2], [2, 3]); expectArraysClose(await tf.max(a, [0, 1]).data(), 100); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const a = tf.tensor2d([3, -1, 0, 100, -7, 2], [2, 3]); const r = tf.max(a, [0]); expect(r.shape).toEqual([3]); expectArraysClose(await r.data(), [100, -1, 2]); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const a = tf.tensor2d([3, -1, 0, 100, -7, 2], [2, 3]); const r = tf.max(a, [0], true /* keepDims */); expect(r.shape).toEqual([1, 3]); expectArraysClose(await r.data(), [100, -1, 2]); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const a = tf.tensor2d([3, 2, 5, 100, -7, 2], [2, 3]); const r = tf.max(a, 1); expectArraysClose(await r.data(), [5, 100]); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const a = tf.tensor2d([3, 2, 5, 100, -7, 2], [2, 3]); const r = tf.max(a, -1); expectArraysClose(await r.data(), [5, 100]); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const a = tf.tensor2d([3, 2, 5, 100, -7, 2], [2, 3]); const r = tf.max(a, [1]); expectArraysClose(await r.data(), [5, 100]); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const a = tf.range(0, 64).reshape([2, 2, 2, 2, 2, 2]); const r = tf.max(a, [5]); const expectedResult = [ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63 ]; expectArraysClose(await r.data(), expectedResult); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const input = tf.tensor2d([3, -1, 0, 100, -7, 2], [2, 3]); const inputDataBefore = await input.data(); tf.max(input, [1, 0]); const inputDataAfter = await input.data(); expectArraysClose(inputDataBefore, inputDataAfter); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
() => { expect(() => tf.max({} as tf.Tensor)) .toThrowError(/Argument 'x' passed to 'max' must be a Tensor/); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
() => tf.max({} as tf.Tensor)
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const r = tf.max([3, -1, 0, 100, -7, 2]); expectArraysClose(await r.data(), 100); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const a = tf.tensor2d([3, -1, 0, 100, -7, 2], [2, 3], 'int32'); expect(a.dtype).toEqual('int32'); expectArraysClose(await tf.max(a).data(), 100); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const x = tf.scalar(42); const dy = tf.scalar(-1); const gradients = tf.grad(v => tf.max(v))(x, dy); expectArraysClose(await gradients.data(), [-1]); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
v => tf.max(v)
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const x = tf.scalar(42); const dy = tf.scalar(-1); const gradients = tf.grad(v => tf.max(v.clone()).clone())(x, dy); expectArraysClose(await gradients.data(), [-1]); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
v => tf.max(v.clone()).clone()
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const x = tf.tensor1d([1, 3, 7, 7]); const dy = tf.scalar(-1); const gradients = tf.grad(v => tf.max(v))(x, dy); expectArraysClose(await gradients.data(), [0, 0, -1, -1]); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const x = tf.tensor2d([[0, 20, 10], [-10, -30, -20]]); const dy = tf.tensor1d([-1, -1]); const axis = -1; const gradients = tf.grad(v => tf.max(v, axis))(x, dy); expectArraysClose(await gradients.data(), [0, -1, 0, -1, 0, 0]); expect(gradients.shape).toEqual([2, 3]); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
v => tf.max(v, axis)
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const x = tf.tensor2d([[0, 20, 20], [-10, -30, -10]]); const dy = tf.tensor1d([-1, -1]); const axis = -1; const gradients = tf.grad(v => tf.max(v, axis))(x, dy); expectArraysClose(await gradients.data(), [0, -1, -1, -1, 0, -1]); expect(gradients.shape).toEqual([2, 3]); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const x = tf.tensor2d([[0, 20, 10], [-10, -30, 20]]); const dy = tf.tensor1d([-1, -1, -1]); const axis = 0; const gradients = tf.grad(v => tf.max(v, axis))(x, dy); expectArraysClose(await gradients.data(), [-1, -1, 0, 0, 0, -1]); expect(gradients.shape).toEqual([2, 3]); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const x = tf.tensor2d([[0, 20, 10], [-10, -30, -20]]); const dy = tf.tensor2d([[-1], [-1]]); const axis = -1; const keepDims = true; const gradients = tf.grad(v => tf.max(v, axis, keepDims))(x, dy); expectArraysClose(await gradients.data(), [0, -1, 0, -1, 0, 0]); expect(gradients.shape).toEqual([2, 3]); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
v => tf.max(v, axis, keepDims)
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const x = tf.tensor2d([[0, 20, 10], [-10, -30, 20]]); const dy = tf.tensor2d([[-1, -1, -1]]); const axis = 0; const keepDims = true; const gradients = tf.grad(v => tf.max(v, axis, keepDims))(x, dy); expectArraysClose(await gradients.data(), [-1, -1, 0, 0, 0, -1]); expect(gradients.shape).toEqual([2, 3]); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const x = tf.ones([2, 1, 250]); const axis = 1; const gradients = tf.grad(v => tf.max(v, axis))(x); expect(gradients.shape).toEqual(x.shape); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const x = tf.tensor3d([[[0, 20], [10, 15]], [[-10, -30], [-20, -15]]]); const dy = tf.tensor1d([-1, -1]); const axis = [1, 2]; const gradients = tf.grad(v => tf.max(v, axis))(x, dy); expectArraysClose(await gradients.data(), [0, -1, 0, 0, -1, 0, 0, 0]); expect(gradients.shape).toEqual([2, 2, 2]); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const x = tf.tensor3d([[[0, 20], [20, 20]], [[-10, -30], [-10, -15]]]); const dy = tf.tensor1d([-1, -1]); const axis = [1, 2]; const gradients = tf.grad(v => tf.max(v, axis))(x, dy); expectArraysClose(await gradients.data(), [0, -1, -1, -1, -1, 0, -1, 0]); expect(gradients.shape).toEqual([2, 2, 2]); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const x = tf.tensor3d([[[0, 20], [10, 15]], [[-10, -30], [-20, -15]]]); const dy = tf.tensor2d([[-1, -1], [-1, -1]]); const axis = 2; const gradients = tf.grad(v => tf.max(v, axis))(x, dy); expectArraysClose(await gradients.data(), [0, -1, 0, -1, -1, 0, 0, -1]); expect(gradients.shape).toEqual([2, 2, 2]); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const x = tf.tensor3d([[[0, 20], [10, 15]], [[-10, -30], [-20, -15]]]); const dy = tf.tensor3d([[[-1], [-1]], [[-1], [-1]]]); const axis = 2; const keepDims = true; const gradients = tf.grad(v => tf.max(v, axis, keepDims))(x, dy); expectArraysClose(await gradients.data(), [0, -1, 0, -1, -1, 0, 0, -1]); expect(gradients.shape).toEqual([2, 2, 2]); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const x = tf.tensor4d([ [[[0, 20], [20, 20]], [[-10, -30], [-10, -30]]], [[[0, -20], [-20, -20]], [[10, 30], [10, 30]]] ]); const dy = tf.tensor1d([-1, -1]); const axis = [1, 2, 3]; const gradients = tf.grad(v => tf.max(v, axis))(x, dy); expectArraysClose( await gradients.data(), [0, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1]); expect(gradients.shape).toEqual([2, 2, 2, 2]); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
async () => { const x = tf.tensor4d([ [[[0, 20], [20, 20]], [[-10, -30], [-10, -30]]], [[[0, -20], [-20, -20]], [[10, 30], [10, 30]]] ]); const dy = tf.tensor4d([[[[-1]], [[-2]]], [[[-3]], [[-4]]]]); const axis = [2, 3]; const keepDims = true; const gradients = tf.grad(v => tf.max(v, axis, keepDims))(x, dy); expectArraysClose( await gradients.data(), [0, -1, -1, -1, -2, 0, -2, 0, -3, 0, 0, 0, 0, -4, 0, -4]); expect(gradients.shape).toEqual([2, 2, 2, 2]); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
() => { expect(() => tf.max(['a'])) .toThrowError(/Argument 'x' passed to 'max' must be numeric tensor/); }
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
ArrowFunction
() => tf.max(['a'])
AlexShafir/tfjs
tfjs-core/src/ops/max_test.ts
TypeScript
InterfaceDeclaration
export interface Student { firstName:string; lastName:string; studentEmail:string; course:string; yearOfStudy: bigint; registrationNumber:string; }
vintage-coder/Event-Booking-System
EBSystemUI/src/app/Models/student.ts
TypeScript
ClassDeclaration
export default class GameNode { id: string; state: any; }
thetinyspark/barista
dist/sdk/common/model/node/GameNode.d.ts
TypeScript
ClassDeclaration
export class AbstractTrieNode<T> implements TrieNode { /** * @override */ public kind: TrieNodeKind; private children_: {[key: string]: TrieNode} = {}; /** * @param constraint The constraint the node represents. * @param test The constraint test of this node. */ constructor( public constraint: string, public test: ((p1: T) => boolean)|null) { this.kind = TrieNodeKind.ROOT; } /** * @override */ public getConstraint() { return this.constraint; } /** * @override */ public getKind() { return this.kind; } /** * @override */ public applyTest(object: T) { return this.test(object); } /** * @override */ public addChild(node: TrieNode) { let constraint = node.getConstraint(); let child = this.children_[constraint]; this.children_[constraint] = node; return child; } /** * @override */ public getChild(constraint: string) { return this.children_[constraint]; } /** * @override */ public getChildren() { let children = []; for (let key in this.children_) { children.push(this.children_[key]); } return children; } /** * @override */ public findChildren(object: T) { let children = []; for (let key in this.children_) { let child = this.children_[key]; if (child.applyTest(object)) { children.push(child); } } return children; } /** * @override */ public removeChild(constraint: string) { delete this.children_[constraint]; } /** * @override */ public toString() { return this.constraint; } }
zorkow/speech-rule-engine
ts/indexing/abstract_trie_node.ts
TypeScript
ClassDeclaration
export class StaticTrieNode extends AbstractTrieNode<Node> { private rule_: SpeechRule|null = null; /** * @param constraint The constraint the node represents. * @param test The constraint test of this node. */ constructor(constraint: string, test: ((p1: Node) => boolean)|null) { super(constraint, test); this.kind = TrieNodeKind.STATIC; } /** * @return The speech rule of the node. */ public getRule(): SpeechRule|null { return this.rule_; } /** * @param rule speech rule of the node. */ public setRule(rule: SpeechRule) { if (this.rule_) { Debugger.getInstance().output( 'Replacing rule ' + this.rule_ + ' with ' + rule); } this.rule_ = rule; } /** * @override */ public toString() { let rule = this.getRule(); return rule ? this.constraint + '\n' + '==> ' + this.getRule().action : this.constraint; } }
zorkow/speech-rule-engine
ts/indexing/abstract_trie_node.ts
TypeScript
MethodDeclaration
/** * @override */ public getConstraint() { return this.constraint; }
zorkow/speech-rule-engine
ts/indexing/abstract_trie_node.ts
TypeScript
MethodDeclaration
/** * @override */ public getKind() { return this.kind; }
zorkow/speech-rule-engine
ts/indexing/abstract_trie_node.ts
TypeScript