refactor(aio): simplify preview server build events
This commit is contained in:
parent
a98440bb85
commit
0fe685102f
|
@ -1,15 +1,8 @@
|
||||||
// Classes
|
// Classes
|
||||||
export class BuildEvent {
|
export class CreatedBuildEvent {
|
||||||
// Constructor
|
|
||||||
constructor(public type: string, public pr: number, public sha: string) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class CreatedBuildEvent extends BuildEvent {
|
|
||||||
// Properties - Public, Static
|
// Properties - Public, Static
|
||||||
public static type = 'build.created';
|
public static type = 'build.created';
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
constructor(pr: number, sha: string) {
|
constructor(public pr: number, public sha: string) {}
|
||||||
super(CreatedBuildEvent.type, pr, sha);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,7 @@
|
||||||
// Imports
|
// Imports
|
||||||
import {BuildEvent, CreatedBuildEvent} from '../../lib/upload-server/build-events';
|
import {CreatedBuildEvent} from '../../lib/upload-server/build-events';
|
||||||
|
|
||||||
// Tests
|
// Tests
|
||||||
describe('BuildEvent', () => {
|
|
||||||
let evt: BuildEvent;
|
|
||||||
|
|
||||||
beforeEach(() => evt = new BuildEvent('foo', 42, 'bar'));
|
|
||||||
|
|
||||||
|
|
||||||
it('should have a \'type\' property', () => {
|
|
||||||
expect(evt.type).toBe('foo');
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it('should have a \'pr\' property', () => {
|
|
||||||
expect(evt.pr).toBe(42);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it('should have a \'sha\' property', () => {
|
|
||||||
expect(evt.sha).toBe('bar');
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
describe('CreatedBuildEvent', () => {
|
describe('CreatedBuildEvent', () => {
|
||||||
let evt: CreatedBuildEvent;
|
let evt: CreatedBuildEvent;
|
||||||
|
|
||||||
|
@ -36,19 +13,6 @@ describe('CreatedBuildEvent', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should extend BuildEvent', () => {
|
|
||||||
expect(evt).toEqual(jasmine.any(CreatedBuildEvent));
|
|
||||||
expect(evt).toEqual(jasmine.any(BuildEvent));
|
|
||||||
|
|
||||||
expect(Object.getPrototypeOf(evt)).toBe(CreatedBuildEvent.prototype);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it('should automatically set the \'type\'', () => {
|
|
||||||
expect(evt.type).toBe(CreatedBuildEvent.type);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it('should have a \'pr\' property', () => {
|
it('should have a \'pr\' property', () => {
|
||||||
expect(evt.pr).toBe(42);
|
expect(evt.pr).toBe(42);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue