mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-23 10:16:32 -05:00
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:
parent
9258863dbd
commit
01b53d3858
3 changed files with 6 additions and 6 deletions
|
@ -54,7 +54,7 @@ export class Alias {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||||
private constructor() {}
|
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();
|
const alias = new Alias();
|
||||||
alias.name = name;
|
alias.name = name;
|
||||||
alias.primary = primary;
|
alias.primary = primary;
|
||||||
|
|
|
@ -140,7 +140,7 @@ describe('AliasService', () => {
|
||||||
it('with an already used name', async () => {
|
it('with an already used name', async () => {
|
||||||
jest
|
jest
|
||||||
.spyOn(aliasRepo, 'findOne')
|
.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(
|
await expect(service.addAlias(note, alias2)).rejects.toThrow(
|
||||||
AlreadyInDBError,
|
AlreadyInDBError,
|
||||||
);
|
);
|
||||||
|
@ -159,7 +159,7 @@ describe('AliasService', () => {
|
||||||
const user = User.create('hardcoded', 'Testy') as User;
|
const user = User.create('hardcoded', 'Testy') as User;
|
||||||
describe('removes one alias correctly', () => {
|
describe('removes one alias correctly', () => {
|
||||||
const note = Note.create(user, alias) as Note;
|
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 () => {
|
it('with two aliases', async () => {
|
||||||
jest
|
jest
|
||||||
.spyOn(noteRepo, 'save')
|
.spyOn(noteRepo, 'save')
|
||||||
|
@ -189,7 +189,7 @@ describe('AliasService', () => {
|
||||||
});
|
});
|
||||||
describe('does not remove one alias', () => {
|
describe('does not remove one alias', () => {
|
||||||
const note = Note.create(user, alias) as Note;
|
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 () => {
|
it('if the alias is unknown', async () => {
|
||||||
await expect(service.removeAlias(note, 'non existent')).rejects.toThrow(
|
await expect(service.removeAlias(note, 'non existent')).rejects.toThrow(
|
||||||
NotInDBError,
|
NotInDBError,
|
||||||
|
@ -208,7 +208,7 @@ describe('AliasService', () => {
|
||||||
const aliasName = 'testAlias';
|
const aliasName = 'testAlias';
|
||||||
const note = Note.create(user, aliasName) as Note;
|
const note = Note.create(user, aliasName) as Note;
|
||||||
const alias = Alias.create(aliasName, note, true) as Alias;
|
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);
|
note.aliases.push(alias2);
|
||||||
it('mark the alias as primary', async () => {
|
it('mark the alias as primary', async () => {
|
||||||
jest
|
jest
|
||||||
|
|
|
@ -66,7 +66,7 @@ export class AliasService {
|
||||||
// the first alias is automatically made the primary alias
|
// the first alias is automatically made the primary alias
|
||||||
newAlias = Alias.create(alias, note, true);
|
newAlias = Alias.create(alias, note, true);
|
||||||
} else {
|
} else {
|
||||||
newAlias = Alias.create(alias, note);
|
newAlias = Alias.create(alias, note, false);
|
||||||
}
|
}
|
||||||
note.aliases.push(newAlias as Alias);
|
note.aliases.push(newAlias as Alias);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue