Added TagDeletedEvent
refs https://github.com/TryGhost/Arch/issues/60 This will be used to update collections when a tag is deleted. Like the Post events this should not be in the collections package, instead we should have these as part of the tags and posts packages. These packages don't exist right now, so I'm following the existing pattern.
This commit is contained in:
parent
acd84fe25c
commit
607ea8dcd7
15
ghost/collections/src/events/TagDeletedEvent.ts
Normal file
15
ghost/collections/src/events/TagDeletedEvent.ts
Normal file
@ -0,0 +1,15 @@
|
||||
export class TagDeletedEvent {
|
||||
id: string;
|
||||
data: {slug: string, id: string};
|
||||
timestamp: Date;
|
||||
|
||||
constructor(data: {slug: string, id: string}, timestamp: Date) {
|
||||
this.id = data.id;
|
||||
this.data = data;
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
static create(data: any, timestamp = new Date()) {
|
||||
return new TagDeletedEvent(data, timestamp);
|
||||
}
|
||||
}
|
@ -4,3 +4,4 @@ export * from './Collection';
|
||||
export * from './events/PostDeletedEvent';
|
||||
export * from './events/PostAddedEvent';
|
||||
export * from './events/PostEditedEvent';
|
||||
export * from './events/TagDeletedEvent';
|
||||
|
13
ghost/collections/test/TagDeletedEvent.test.ts
Normal file
13
ghost/collections/test/TagDeletedEvent.test.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import assert from 'assert/strict';
|
||||
import {TagDeletedEvent} from '../src';
|
||||
|
||||
describe('TagDeletedEvent', function () {
|
||||
it('should create a TagDeletedEvent', function () {
|
||||
const event = TagDeletedEvent.create({id: '1', slug: 'tag-1'});
|
||||
|
||||
const actual = event instanceof TagDeletedEvent;
|
||||
const expected = true;
|
||||
|
||||
assert.equal(actual, expected, 'TagDeletedEvent.create() did not return an instance of TagDeletedEvent');
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user