Skip to content

Commit

Permalink
Windows fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ze-kel committed Apr 11, 2022
1 parent 8bab439 commit ba7acd3
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Commits making it closer to being usable are always appreciated. I may not care

### Developing

Use at least node specified in ```.nvmrc```

```npm run watch``` to run in dev mode

```npm run test``` to run e2e tests
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/renderer/src/utils/formatHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function formatHeader(opened: IOpened, rootPath: string) {
if (opened.thing === rootPath) {
return 'All Books';
}
return opened.thing.replace(rootPath + '/', '');
return opened.thing.replace(rootPath, '').replace(/[\\/]/, '');
}

if (opened.type === 'tag') {
Expand Down
3 changes: 2 additions & 1 deletion tests/2. Files & Folders Watchers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ afterEach(async () => await afterTest(electronApp, workingPath));
test('File tree watcher', async () => {
const page = await electronApp.firstWindow();
const L = getLocators(page);


await sleep(LOAD_TIMEOUT);
expect(await L.fileTreeItems.count(), 'Number of folders seen is correct').toBe(3);

const folderOneName = await L.fileTreeItems.nth(1).locator('.T-label');
Expand Down
11 changes: 8 additions & 3 deletions tests/4. File Editing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
getLocators,
LOAD_TIMEOUT,
getBookFromEditor,
removeLineTerminators,
} from './helpers';
import type { TestBookFromEditor } from './helpers';

Expand Down Expand Up @@ -146,7 +147,11 @@ test('Changes made in edtior are saved to disk', async () => {

fs.writeFileSync(path.join(originalPath, 'salkdasd.txt'), onDisk.toString());

expect(expected.toString(), 'After editing all changes are saved to disk').toEqual(
onDisk.toString(),
);
const expectedStr = removeLineTerminators(expected.toString());
const onDiskStr = removeLineTerminators(onDisk.toString());

console.log('exp', expectedStr);
console.log('ondisk', onDiskStr);

expect(expectedStr, 'After editing all changes are saved to disk').toEqual(onDiskStr);
});
5 changes: 5 additions & 0 deletions tests/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,8 @@ export const getBookFromEditor = async (

return { author, title, year, ISBN, tags, dates, rating };
};

export const removeLineTerminators = (string: string) => {
// We need this to compare files as strings and not worry about different line terminators on different OS-es
return string.replace(/\n|\r/g, '');
};
Empty file.

0 comments on commit ba7acd3

Please sign in to comment.