Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ jobs:
- name: Install deps
run: yarn

# lint.yaml runs the unit tests on Linux only; path handling differs on Windows and macOS.
- name: Unit tests
run: yarn test

- name: Download binaries
run: npm run download-binaries

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ jobs:
- name: Typecheck
run: yarn typecheck

- name: Page render test
run: yarn react-test
- name: Unit tests
run: yarn test
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"scripts": {
"start": "electron-vite dev",
"test": "vitest run",
"react-test": "vitest run",
"verify": "yarn -s lint && yarn -s typecheck && yarn -s test",
"test:e2e": "yarn build && node node_modules/playwright/cli.js test --config e2e/playwright.config.js",
"test:e2e:update-fixtures": "yarn build && node e2e/updateFixtures.js",
"test:docs": "node node_modules/playwright/cli.js test --config e2e/docs/playwright.config.js",
Expand Down
21 changes: 19 additions & 2 deletions src/main/parseAlignment.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import path from 'path';
import { expect, it } from 'vitest';
import { parseAlignment } from './parseAlignment';
import type { Alignment } from './parseAlignment';
Expand Down Expand Up @@ -80,11 +81,11 @@ it( 'parseAlignment reports the written file when it renames a taxon', async ()
} ) );

expect( written ).toEqual( {
filePath: '/data/primates_modified.fasta',
filePath: path.join( '/data', 'primates_modified.fasta' ),
taxon: 'A_B',
} );
expect( parsed.change ).toEqual( {
newFilePath: '/data/primates_modified.fasta',
newFilePath: path.join( '/data', 'primates_modified.fasta' ),
format: 'fasta',
converted: undefined,
modified: true,
Expand All @@ -94,6 +95,22 @@ it( 'parseAlignment reports the written file when it renames a taxon', async ()
} );
} );

it.each( [
[ '/tmp/abc/abc.fas', path.join( '/tmp/abc', 'abc_modified.fas' ) ],
[ '/tmp/abc ML/abc.fas', path.join( '/tmp/abc ML', 'abc_modified.fas' ) ],
] )( 'parseAlignment writes the modified file beside %s when a parent folder contains its base name', async ( filePath, expected ) => {
const alignment = { sequences: [ { taxon: 'A B', code: 'AAAA' } ] };
let writtenPath;
const parsed = await parseAlignment( 'align-1', filePath, tools( async () => alignment as Alignment, {
write: async ( writePath ) => {
writtenPath = writePath;
},
} ) );

expect( writtenPath ).toBe( expected );
expect( parsed.change?.newFilePath ).toBe( expected );
} );

it( 'parseAlignment numbers a repeated taxon name', async () => {
const alignment = {
sequences: [
Expand Down
4 changes: 2 additions & 2 deletions src/main/parseAlignment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ export async function parseAlignment(
taxons.set( sequence.taxon, index );
} );
if ( modified ) {
const baseName = path.basename( actualPath, path.extname( actualPath ) );
newFilePath = actualPath.replace( baseName, `${baseName}_modified` );
const { dir, name, ext } = path.parse( actualPath );
newFilePath = path.join( dir, `${name}_modified${ext}` );
await write( newFilePath, alignment );
}
const change = newFilePath
Expand Down
Loading