From 1c072e7caf016e930d54204e2c6a5b11ea90cd45 Mon Sep 17 00:00:00 2001 From: Resi Respati Date: Wed, 20 Feb 2019 11:20:33 +0700 Subject: [PATCH] [next] remove tests already migrated to `next-server` --- types/next/test/imports/no-default.tsx | 7 -- types/next/test/imports/with-default.tsx | 11 --- types/next/test/next-constants-tests.ts | 30 ------- types/next/test/next-dynamic-tests.tsx | 81 ----------------- types/next/test/next-head-tests.tsx | 11 --- types/next/test/next-link-tests.tsx | 23 ----- types/next/test/next-router-tests.tsx | 110 ----------------------- types/next/tsconfig.json | 9 +- 8 files changed, 1 insertion(+), 281 deletions(-) delete mode 100644 types/next/test/imports/no-default.tsx delete mode 100644 types/next/test/imports/with-default.tsx delete mode 100644 types/next/test/next-constants-tests.ts delete mode 100644 types/next/test/next-dynamic-tests.tsx delete mode 100644 types/next/test/next-head-tests.tsx delete mode 100644 types/next/test/next-link-tests.tsx delete mode 100644 types/next/test/next-router-tests.tsx diff --git a/types/next/test/imports/no-default.tsx b/types/next/test/imports/no-default.tsx deleted file mode 100644 index 1f406a3fe3..0000000000 --- a/types/next/test/imports/no-default.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import * as React from "react"; - -interface Props { - foo: string; -} - -export const MyComponent: React.SFC = ({ foo: text }) => {text}; diff --git a/types/next/test/imports/with-default.tsx b/types/next/test/imports/with-default.tsx deleted file mode 100644 index f448a16680..0000000000 --- a/types/next/test/imports/with-default.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import * as React from "react"; - -interface Props { - foo: boolean; -} - -export default class MyComponent extends React.Component { - render() { - return this.props.foo ?
: null; - } -} diff --git a/types/next/test/next-constants-tests.ts b/types/next/test/next-constants-tests.ts deleted file mode 100644 index 64413ea97c..0000000000 --- a/types/next/test/next-constants-tests.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { - PHASE_DEVELOPMENT_SERVER, - IS_BUNDLED_PAGE_REGEX -} from "next/constants"; - -const isIndexPage = IS_BUNDLED_PAGE_REGEX.test( - "static/CjW0mFnyG80HdP4eSUiy7/pages/index.js" -); - -// Example taken from: https://github.com/cyrilwanner/next-compose-plugins/blob/a25b313899638912cc9defc0be072f4fe4a1e855/README.md -const config = (nextConfig: any = {}) => { - return { - ...nextConfig, - - // define in which phases this plugin should get applied. - // you can also use multiple phases or negate them. - // however, users can still overwrite them in their configuration if they really want to. - phases: [PHASE_DEVELOPMENT_SERVER], - - webpack(config: any, options: any) { - // do something here which only gets applied during development server phase - - if (typeof nextConfig.webpack === "function") { - return nextConfig.webpack(config, options); - } - - return config; - } - }; -}; diff --git a/types/next/test/next-dynamic-tests.tsx b/types/next/test/next-dynamic-tests.tsx deleted file mode 100644 index a291c6ae7d..0000000000 --- a/types/next/test/next-dynamic-tests.tsx +++ /dev/null @@ -1,81 +0,0 @@ -import * as React from "react"; -import dynamic, { LoadingComponentProps } from "next/dynamic"; - -// You'd typically do this via import('./MyComponent') -interface MyComponentProps { - foo: string; -} -const MyComponent: React.StatelessComponent = () =>
I'm async!
; -const asyncComponent = Promise.resolve(MyComponent); - -// Examples from -// https://github.com/zeit/next.js/#dynamic-import - -const LoadingComponent: React.StatelessComponent = ({ - isLoading, - error -}) =>

loading...

; - -// 1. Basic Usage (Also does SSR) -const DynamicComponent = dynamic(Promise.resolve(MyComponent)); -const dynamicComponentJSX = ; - -// 1.1 Basic Usage (Loader function, module shape with 'export = Component' / 'module.exports = Component') -const DynamicComponent2 = dynamic(() => Promise.resolve(MyComponent)); -const dynamicComponent2JSX = ; - -// 1.2 Basic Usage (Loader function, module shape with 'export default Component') -const DynamicComponent3 = dynamic(() => Promise.resolve({ default: MyComponent })); -const dynamicComponent3JSX = ; - -// TODO: Work with module shape 'export { Component }' - -// 2. With Custom Loading Component -const DynamicComponentWithCustomLoading = dynamic(import('./imports/with-default'), { - loading: LoadingComponent -}); -const dynamicComponentWithCustomLoadingJSX = ; - -// 2.1. With Custom Loading Component (() => import('') syntax) -const DynamicComponentWithCustomLoading2 = dynamic(() => import('./imports/with-default'), { - loading: LoadingComponent -}); -const dynamicComponentWithCustomLoading2JSX = ; - -// 3. With No SSR -const DynamicComponentWithNoSSR = dynamic(() => import('./imports/with-default'), { - ssr: false -}); - -// 4. With Multiple Modules At Once -const HelloBundle = dynamic({ - modules: () => { - const components = { - Hello1: () => import('./imports/with-default'), - Hello2: () => import('./imports/with-default') - }; - - return components; - }, - render: (props, { Hello1, Hello2 }) => ( -
-

{props.foo}

- - -
- ) -}); -const helloBundleJSX = ; - -// 5. With plain Loadable options -const LoadableComponent = dynamic({ - loader: () => import('./imports/with-default'), - loading: LoadingComponent, - delay: 200, - timeout: 10000 -}); - -// 6. No loading -const DynamicComponentWithNoLoading = dynamic(asyncComponent, { - loading: () => null -}); diff --git a/types/next/test/next-head-tests.tsx b/types/next/test/next-head-tests.tsx deleted file mode 100644 index 735402ca9a..0000000000 --- a/types/next/test/next-head-tests.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import Head, * as head from "next/head"; -import * as React from "react"; - -const elements: JSX.Element[] = head.defaultHead(); -const jsx = {elements}; - -if (!Head.canUseDOM) { - Head.rewind().map(x => [x.key, x.props, x.type]); -} - -Head.peek().map(x => [x.key, x.props, x.type]); diff --git a/types/next/test/next-link-tests.tsx b/types/next/test/next-link-tests.tsx deleted file mode 100644 index 2a85fec1ad..0000000000 --- a/types/next/test/next-link-tests.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import Link from "next/link"; -import * as React from "react"; - -const links = ( -
- { - console.log("Handled error!", e); - }} - prefetch - replace - scroll - shallow - > - Gotta link to somewhere! - - - All props are optional! - -
-); diff --git a/types/next/test/next-router-tests.tsx b/types/next/test/next-router-tests.tsx deleted file mode 100644 index b06c1ad3a7..0000000000 --- a/types/next/test/next-router-tests.tsx +++ /dev/null @@ -1,110 +0,0 @@ -import Router, { withRouter, WithRouterProps } from "next/router"; -import * as React from "react"; -import * as qs from "querystring"; - -Router.readyCallbacks.push(() => { - console.log("I'll get called when the router initializes."); -}); -Router.ready(() => { - console.log( - "I'll get called immediately if the router initializes, or when it eventually does.", - ); -}); - -// Access readonly properties of the router. - -Object.keys(Router.components).forEach(key => { - const c = Router.components[key]; - c.err.isAnAny; - - return ; -}); - -function split(routeLike: string) { - routeLike.split("/").forEach(part => { - console.log("path part: ", part); - }); -} - -if (Router.asPath) { - split(Router.asPath); - split(Router.asPath); -} - -split(Router.pathname); - -const query = `?${qs.stringify(Router.query)}`; - -// Assign some callback methods. -Router.events.on('routeChangeStart', (url: string) => console.log("Route is starting to change.", url)); -Router.events.on('beforeHistoryChange', (as: string) => console.log("History hasn't changed yet.", as)); -Router.events.on('routeChangeComplete', (url: string) => console.log("Route change is complete.", url)); -Router.events.on('routeChangeError', (err: any, url: string) => console.log("Route change errored.", err, url)); - -// Call methods on the router itself. -Router.reload("/route").then(() => console.log("route was reloaded")); -Router.back(); -Router.beforePopState(({ url }) => !!url); - -Router.push("/route").then((success: boolean) => - console.log("route push success: ", success), -); -Router.push("/route", "/asRoute").then((success: boolean) => - console.log("route push success: ", success), -); -Router.push("/route", "/asRoute", { shallow: false }).then((success: boolean) => - console.log("route push success: ", success), -); - -Router.replace("/route").then((success: boolean) => - console.log("route replace success: ", success), -); -Router.replace("/route", "/asRoute").then((success: boolean) => - console.log("route replace success: ", success), -); -Router.replace("/route", "/asRoute", { - shallow: false, -}).then((success: boolean) => console.log("route replace success: ", success)); - -Router.prefetch("/route").then(Component => { - const element = ; -}); - -interface TestComponentProps { - testValue: string; -} - -class TestComponent extends React.Component { - state = { ready: false }; - - constructor(props: TestComponentProps & WithRouterProps) { - super(props); - if (props.router) { - props.router.ready(() => { - this.setState({ ready: true }); - }); - } - } - - render() { - return ( -
-

{this.state.ready ? 'Ready' : 'Not Ready'}

-

Route: {this.props.router ? this.props.router.route : ""}

-

Another prop: {this.props.testValue}

-
- ); - } -} - -withRouter(TestComponent); - -interface TestFCQuery { - test?: string; -} - -interface TestFCProps extends WithRouterProps { } - -const TestFC: React.FunctionComponent = ({ router }) => { - return
{router && router.query && router.query.test}
; -}; diff --git a/types/next/tsconfig.json b/types/next/tsconfig.json index 3dec431b0c..41f6efc969 100644 --- a/types/next/tsconfig.json +++ b/types/next/tsconfig.json @@ -30,16 +30,9 @@ "router.d.ts", "config.d.ts", "test/next-tests.ts", - "test/next-constants-tests.ts", "test/next-app-tests.tsx", "test/next-error-tests.tsx", - "test/next-head-tests.tsx", "test/next-document-tests.tsx", - "test/next-link-tests.tsx", - "test/next-dynamic-tests.tsx", - "test/next-router-tests.tsx", - "test/next-component-tests.tsx", - "test/imports/no-default.tsx", - "test/imports/with-default.tsx" + "test/next-component-tests.tsx" ] }