fix(alias): remove default for primary

To make the create method more consistent with the
guidelines,
this commit removes the default value from the `primary` parameter.

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2021-11-14 21:22:22 +01:00
parent 9258863dbd
commit 01b53d3858
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
3 changed files with 6 additions and 6 deletions

View file

@ -54,7 +54,7 @@ export class Alias {
// eslint-disable-next-line @typescript-eslint/no-empty-function
private constructor() {}
static create(name: string, note: Note, primary = false): Omit<Alias, 'id'> {
static create(name: string, note: Note, primary: boolean): Omit<Alias, 'id'> {
const alias = new Alias();
alias.name = name;
alias.primary = primary;

View file

@ -140,7 +140,7 @@ describe('AliasService', () => {
it('with an already used name', async () => {
jest
.spyOn(aliasRepo, 'findOne')
.mockResolvedValueOnce(Alias.create(alias2, note) as Alias);
.mockResolvedValueOnce(Alias.create(alias2, note, false) as Alias);
await expect(service.addAlias(note, alias2)).rejects.toThrow(
AlreadyInDBError,
);
@ -159,7 +159,7 @@ describe('AliasService', () => {
const user = User.create('hardcoded', 'Testy') as User;
describe('removes one alias correctly', () => {
const note = Note.create(user, alias) as Note;
note.aliases.push(Alias.create(alias2, note) as Alias);
note.aliases.push(Alias.create(alias2, note, false) as Alias);
it('with two aliases', async () => {
jest
.spyOn(noteRepo, 'save')
@ -189,7 +189,7 @@ describe('AliasService', () => {
});
describe('does not remove one alias', () => {
const note = Note.create(user, alias) as Note;
note.aliases.push(Alias.create(alias2, note) as Alias);
note.aliases.push(Alias.create(alias2, note, false) as Alias);
it('if the alias is unknown', async () => {
await expect(service.removeAlias(note, 'non existent')).rejects.toThrow(
NotInDBError,
@ -208,7 +208,7 @@ describe('AliasService', () => {
const aliasName = 'testAlias';
const note = Note.create(user, aliasName) as Note;
const alias = Alias.create(aliasName, note, true) as Alias;
const alias2 = Alias.create('testAlias2', note) as Alias;
const alias2 = Alias.create('testAlias2', note, false) as Alias;
note.aliases.push(alias2);
it('mark the alias as primary', async () => {
jest

View file

@ -66,7 +66,7 @@ export class AliasService {
// the first alias is automatically made the primary alias
newAlias = Alias.create(alias, note, true);
} else {
newAlias = Alias.create(alias, note);
newAlias = Alias.create(alias, note, false);
}
note.aliases.push(newAlias as Alias);