-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fd-stable-vite-plugins' into fd-preset-virtual-routes
- Loading branch information
Showing
26 changed files
with
457 additions
and
167 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import {describe, it, expect} from 'vitest'; | ||
import {fileURLToPath} from 'node:url'; | ||
import path from 'node:path'; | ||
import type {RemixConfig} from '@remix-run/dev/dist/config.js'; | ||
import { | ||
addVirtualRoutes, | ||
VIRTUAL_ROOT, | ||
VIRTUAL_ROUTES_DIR, | ||
} from './virtual-routes.js'; | ||
|
||
const appDirectory = path.join( | ||
path.dirname(fileURLToPath(import.meta.url)), | ||
'virtual-test', | ||
); | ||
|
||
describe('virtual routes', () => { | ||
it('adds virtual routes', async () => { | ||
const config = { | ||
appDirectory, | ||
routes: {}, | ||
} as RemixConfig; | ||
|
||
await addVirtualRoutes(config); | ||
|
||
expect(config.routes[VIRTUAL_ROOT]).toMatchObject({ | ||
path: '', | ||
id: VIRTUAL_ROOT, | ||
file: expect.stringContaining('virtual-routes/virtual-root.jsx'), | ||
}); | ||
|
||
expect(config.routes[VIRTUAL_ROUTES_DIR + '/index']).toMatchObject({ | ||
parentId: VIRTUAL_ROOT, | ||
path: undefined, | ||
file: expect.stringContaining(VIRTUAL_ROUTES_DIR + '/index.tsx'), | ||
}); | ||
|
||
expect(config.routes[VIRTUAL_ROUTES_DIR + '/graphiql']).toMatchObject({ | ||
parentId: VIRTUAL_ROOT, | ||
path: 'graphiql', | ||
file: expect.stringContaining(VIRTUAL_ROUTES_DIR + '/graphiql.tsx'), | ||
}); | ||
}); | ||
|
||
it('skips existing routes', async () => { | ||
const existingIndexRoute = { | ||
id: 'routes/index', | ||
index: true, | ||
parentId: 'root', | ||
path: undefined, | ||
file: 'user-app/routes/index.tsx', | ||
}; | ||
|
||
const config = { | ||
appDirectory, | ||
routes: { | ||
[existingIndexRoute.id]: existingIndexRoute, | ||
}, | ||
} as unknown as RemixConfig; | ||
|
||
await addVirtualRoutes(config); | ||
|
||
expect(config.routes[existingIndexRoute.id]).toMatchObject( | ||
existingIndexRoute, | ||
); | ||
|
||
expect(config.routes[VIRTUAL_ROUTES_DIR + '/index']).toBeFalsy(); | ||
|
||
expect(Object.values(config.routes).length).toBeGreaterThan(2); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
/// <reference types="@shopify/remix-oxygen" /> | ||
|
||
import {hashKey} from '../utils/hash.js'; | ||
import { | ||
CacheShort, | ||
|
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
Oops, something went wrong.