Home page in desktop, separate file support (#252)
* Bugfix: don't toast on every change of defaultDir * Refactor app to live under /file/:id * Stub out Tauri-only home page * home reads and writes blank files to defaultDir * Fix initial directory creation * Make file names editable * Refactor onboarding to use normal fns for load issues * Feature: load and write files to and from disk * Feature: Add file deletion, break out FileCard component * Fix settings close URLs to be relative, button types * Add filename and link to AppHeader * Style tweaks: scrollbar, header name, card size * Style: add header, empty state to Home * Refactor: load file in route loader * Move makePathRelative to lib to fix tests * Fix App test * Use '$nnn' default name scheme * Fix type error on ActionButton * Fix type error on ActionButton * @adamchalmers review * Fix merge mistake * Refactor: rename all things "file" to "project" * Feature: migrate to <project-name>/main.kcl setup * Fix tsc test * @Irev-Dev review part 1: renames and imports * @Irev-Dev review pt 2: simplify file list refresh * @Irev-Dev review pt 3: filter out non-projects * @Irev-review pt 4: folder conventions + home auth * Add sort functionality to new welcome page (#255) * Add todo for Sentry
This commit is contained in:
48
src/lib/tauriFS.test.ts
Normal file
48
src/lib/tauriFS.test.ts
Normal file
@ -0,0 +1,48 @@
|
||||
import {
|
||||
MAX_PADDING,
|
||||
getNextProjectIndex,
|
||||
interpolateProjectNameWithIndex,
|
||||
} from './tauriFS'
|
||||
|
||||
describe('Test file utility functions', () => {
|
||||
it('interpolates a project name without an index', () => {
|
||||
expect(interpolateProjectNameWithIndex('test', 1)).toBe('test')
|
||||
})
|
||||
|
||||
it('interpolates a project name with an index and no padding', () => {
|
||||
expect(interpolateProjectNameWithIndex('test-$n', 2)).toBe('test-2')
|
||||
})
|
||||
|
||||
it('interpolates a project name with an index and padding', () => {
|
||||
expect(interpolateProjectNameWithIndex('test-$nnn', 12)).toBe('test-012')
|
||||
})
|
||||
|
||||
it('interpolates a project name with an index and max padding', () => {
|
||||
expect(interpolateProjectNameWithIndex('test-$nnnnnnnnnnn', 3)).toBe(
|
||||
`test-${'0'.repeat(MAX_PADDING)}3`
|
||||
)
|
||||
})
|
||||
|
||||
const testFiles = [
|
||||
{
|
||||
name: 'new-project-04.kcl',
|
||||
path: '/projects/new-project-04.kcl',
|
||||
},
|
||||
{
|
||||
name: 'new-project-007.kcl',
|
||||
path: '/projects/new-project-007.kcl',
|
||||
},
|
||||
{
|
||||
name: 'new-project-05.kcl',
|
||||
path: '/projects/new-project-05.kcl',
|
||||
},
|
||||
{
|
||||
name: 'new-project-0.kcl',
|
||||
path: '/projects/new-project-0.kcl',
|
||||
},
|
||||
]
|
||||
|
||||
it('gets the correct next project index', () => {
|
||||
expect(getNextProjectIndex('new-project-$n', testFiles)).toBe(8)
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user