|
| 1 | +/** |
| 2 | + * Test that page templates have certain exports removed while other files are left alone. |
| 3 | + * |
| 4 | + * Page templates support only a default exported React component and named exports of |
| 5 | + * `config` and `getServerData`, so it's not necessary (or possible) to test other exports |
| 6 | + * in page templates. |
| 7 | + */ |
| 8 | + |
| 9 | +const config = `config exported from a non-page template module` |
| 10 | +const getServerData = `getServerData exported from a non-page template module` |
| 11 | +const helloWorld = `hello world` |
| 12 | + |
| 13 | +describe(`modifed exports`, () => { |
| 14 | + beforeEach(() => { |
| 15 | + cy.visit(`/modified-exports-ts`).waitForRouteChange() |
| 16 | + }) |
| 17 | + |
| 18 | + describe(`page templates`, () => { |
| 19 | + it(`should have exports named config removed`, () => { |
| 20 | + cy.getTestElement(`modified-exports-page-template-config`) |
| 21 | + .invoke(`text`) |
| 22 | + .should(`contain`, `undefined`) |
| 23 | + }) |
| 24 | + it(`should have exports named getServerData removed`, () => { |
| 25 | + cy.getTestElement(`modified-exports-page-template-get-server-data`) |
| 26 | + .invoke(`text`) |
| 27 | + .should(`contain`, `undefined`) |
| 28 | + }) |
| 29 | + it(`should have imported exports named config left alone`, () => { |
| 30 | + cy.getTestElement(`unmodified-exports-page-template-config`) |
| 31 | + .invoke(`text`) |
| 32 | + .should(`contain`, config) |
| 33 | + }) |
| 34 | + it(`should have imported exports named getServerData left alone`, () => { |
| 35 | + cy.getTestElement(`unmodified-exports-page-template-get-server-data`) |
| 36 | + .invoke(`text`) |
| 37 | + .should(`contain`, getServerData) |
| 38 | + }) |
| 39 | + it(`should have other imported exports left alone`, () => { |
| 40 | + cy.getTestElement(`unmodified-exports-page-template-hello-world`) |
| 41 | + .invoke(`text`) |
| 42 | + .should(`contain`, helloWorld) |
| 43 | + }) |
| 44 | + }) |
| 45 | + |
| 46 | + describe(`other JS files`, () => { |
| 47 | + it(`should have exports named config left alone`, () => { |
| 48 | + cy.getTestElement(`unmodified-exports-config`) |
| 49 | + .invoke(`text`) |
| 50 | + .should(`contain`, config) |
| 51 | + }) |
| 52 | + |
| 53 | + it(`should have exports named getServerData left alone`, () => { |
| 54 | + cy.getTestElement(`unmodified-exports-get-server-data`) |
| 55 | + .invoke(`text`) |
| 56 | + .should(`contain`, getServerData) |
| 57 | + }) |
| 58 | + |
| 59 | + it(`should have other named exports left alone`, () => { |
| 60 | + cy.getTestElement(`unmodified-exports-hello-world`) |
| 61 | + .invoke(`text`) |
| 62 | + .should(`contain`, helloWorld) |
| 63 | + }) |
| 64 | + }) |
| 65 | +}) |
0 commit comments