-
-
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.
test: add tests for internal util evaluateAbellBlock
- Loading branch information
1 parent
4d55982
commit 42aa849
Showing
3 changed files
with
87 additions
and
48 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 |
---|---|---|
@@ -1,49 +1,48 @@ | ||
// import { test, describe, expect } from 'vitest'; | ||
// import { makeRoutesFromGlobImport } from '../api'; | ||
// import { prefix } from './test-utils'; | ||
import { test, describe, expect } from 'vitest'; | ||
import { makeRoutesFromGlobImport } from '../api'; | ||
|
||
// describe('makeRoutesFromGlobImport()', () => { | ||
// test('should return relative abell files', () => { | ||
// const abellPages = { | ||
// './src/index.abell': { | ||
// default: () => 'hehe' | ||
// }, | ||
// './src/about.abell': { | ||
// default: () => 'hehe' | ||
// }, | ||
// './src/nested/index.abell': { | ||
// default: () => 'hehe' | ||
// } | ||
// }; | ||
// expect(findAbellFileFromURL('/', abellPages)).toBe('./src/index.abell'); | ||
// expect(findAbellFileFromURL('/about', abellPages)).toBe( | ||
// './src/about.abell' | ||
// ); | ||
// expect(findAbellFileFromURL('/nested', abellPages)).toBe( | ||
// './src/nested/index.abell' | ||
// ); | ||
// }); | ||
describe('makeRoutesFromGlobImport()', () => { | ||
const abellPages = { | ||
'./src/index.abell': { | ||
default: () => 'index' | ||
}, | ||
'./src/about.abell': { | ||
default: () => 'about' | ||
}, | ||
'./src/nested/index.abell': { | ||
default: () => 'nested' | ||
}, | ||
'./src/_components/navbar.abell': { | ||
default: () => 'nav' | ||
}, | ||
'./src/components/_navbar.abell': { | ||
default: () => 'nav2' | ||
} | ||
}; | ||
|
||
// test('should return absolute abell files', () => { | ||
// const abellPages = { | ||
// [prefix('./src/index.abell')]: { | ||
// default: () => 'hehe' | ||
// }, | ||
// [prefix('./src/about.abell')]: { | ||
// default: () => 'hehe' | ||
// }, | ||
// [prefix('./src/nested/index.abell')]: { | ||
// default: () => 'hehe' | ||
// } | ||
// }; | ||
// expect(findAbellFileFromURL('/', abellPages)).toBe( | ||
// prefix('./src/index.abell') | ||
// ); | ||
// expect(findAbellFileFromURL('/about', abellPages)).toBe( | ||
// prefix('./src/about.abell') | ||
// ); | ||
// expect(findAbellFileFromURL('/nested', abellPages)).toBe( | ||
// prefix('./src/nested/index.abell') | ||
// ); | ||
// }); | ||
// }); | ||
test('should return routes object based on abellPages', () => { | ||
const routes = makeRoutesFromGlobImport(abellPages); | ||
const paths = routes.map((route) => route.path); | ||
const renderOutputs = routes.map((route) => route.render()); | ||
expect(routes[0]).toHaveProperty('path'); | ||
expect(routes[0]).toHaveProperty('render'); | ||
expect(paths).toEqual(['/', '/about', '/nested']); | ||
expect(renderOutputs).toEqual(['index', 'about', 'nested']); | ||
}); | ||
|
||
test('should allow underscore routes with ignoreUnderScoreURLs false', () => { | ||
const routes = makeRoutesFromGlobImport(abellPages, { | ||
ignoreUnderscoreURLs: false | ||
}); | ||
const paths = routes.map((route) => route.path); | ||
const renderOutputs = routes.map((route) => route.render()); | ||
expect(paths).toEqual([ | ||
'/', | ||
'/about', | ||
'/nested', | ||
'/_components/navbar', | ||
'/components/_navbar' | ||
]); | ||
expect(renderOutputs).toEqual(['index', 'about', 'nested', 'nav', 'nav2']); | ||
}); | ||
}); |
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