Skip to content

Commit

Permalink
fixed liniting
Browse files Browse the repository at this point in the history
  • Loading branch information
Egge21M committed Nov 12, 2023
1 parent 42fc24b commit a4233a9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};
};

Check failure on line 6 in jest.config.js

View workflow job for this annotation

GitHub Actions / build

Too many blank lines at the end of file. Max of 0 allowed
7 changes: 4 additions & 3 deletions src/Conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ class Conversation {

private relayPool: SimplePool;

private secretKeyMethod?: 'nip07' | 'throwaway' | 'localstorage' =
'throwaway';
private secretKeyMethod?: 'nip07' | 'throwaway' | 'localstorage' = 'throwaway';

private secretKey?: string;

Expand All @@ -51,6 +50,7 @@ class Conversation {
if (configObject.secretKeyMethod === 'throwaway') {
this.createAndSaveThrowawayKey();
} else if (configObject.secretKeyMethod === 'localstorage') {
// TO-DO
}
} else {
this.createAndSaveThrowawayKey();
Expand Down Expand Up @@ -195,7 +195,8 @@ class Conversation {
event.id = getEventHash(event);
event.sig = getSignature(event, this.secretKey);
return event;
} else if (this.secretKeyMethod === 'localstorage') {
}
if (this.secretKeyMethod === 'localstorage') {
return signFromLocalstorage(unsignedEvent);
}
throw new Error('No valid private key available');
Expand Down
20 changes: 14 additions & 6 deletions src/localstorage.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { describe, test, expect, afterEach } from '@jest/globals';
import { signFromLocalstorage } from './messages';
import {
describe,
test,
expect,
afterEach
} from '@jest/globals';
import { EventTemplate, generatePrivateKey } from 'nostr-tools';
import { getPublicKeyFromLocalstorage } from './localstorage';
import {
getPublicKeyFromLocalstorage,
signFromLocalstorage,
} from './localstorage';

class LocalStorageMock {
store: {
[key: string]: string;
};

constructor() {
this.store = {};
}
Expand All @@ -28,7 +36,7 @@ class LocalStorageMock {
}
}

//@ts-ignore
// @ts-ignore
global.localStorage = new LocalStorageMock();

describe('signing a message from localstorage', () => {
Expand All @@ -55,7 +63,7 @@ describe('signing a message from localstorage', () => {
tags: [],
};
expect(() => {
const signedEvent = signFromLocalstorage(unsignedEvent);
signFromLocalstorage(unsignedEvent);
}).toThrow();
});
});
Expand All @@ -71,7 +79,7 @@ describe('getting public key from local storage', () => {
});
test('assume no private key is found', () => {
expect(() => {
const publicKey = getPublicKeyFromLocalstorage();
getPublicKeyFromLocalstorage();
}).toThrow();
});
});

0 comments on commit a4233a9

Please sign in to comment.