Skip to content

Instantly share code, notes, and snippets.

@alex-taxiera
Last active February 21, 2020 00:15
Show Gist options
  • Save alex-taxiera/bad95f4e5f7acd8c5f062e06e51112d9 to your computer and use it in GitHub Desktop.
Save alex-taxiera/bad95f4e5f7acd8c5f062e06e51112d9 to your computer and use it in GitHub Desktop.
Just an Azure DevOps meme...
class Project {
private _workItems: WorkItem[] = [];
public get workItems(): WorkItem[] {
return this._workItems;
}
public addWorkItem(item: WorkItem): number {
const id = this._workItems.push(item);
item.id = id;
return id;
}
}
type State = 'New' | 'Active' | 'Resolved' | 'QA' | 'Closed';
type BugRootCause = 'Unknown' | 'Coding Error' | 'Communication Error'
| 'Design Error' | 'Specification Error';
interface User {
name: string;
}
interface Comment {
content: string;
author: User;
timestamp: string;
}
abstract class WorkItem {
public id: number;
public state: State = 'New';
private _children: number[] = [];
private _comments: Comment[] = [];
public readonly createdAt: string = Date.now().toString();
public get children() {
return this._children;
}
public get comments() {
return this._comments;
}
constructor (
public assignedTo?: User,
public priority?: 1 | 2 | 3 | 4,
) {}
public get isItDone(): boolean {
return ['Resolved', 'QA', 'Closed'].includes(this.state);
}
public get isItDoneDone(): boolean {
return this.state === 'Closed';
}
public addChild(id: number): number {
return this._children.push(id);
}
public addComment(comment: Comment) {
this._comments.push(comment);
}
}
class UserStory extends WorkItem {
constructor (
public assignedTo?: User,
public priority?: 1 | 2 | 3 | 4,
public points?: 1 | 3 | 5,
public acceptanceCriteria?: string,
) { super(assignedTo, priority); }
}
class Bug extends WorkItem {
public rootCause: BugRootCause;
public type: string;
constructor (
public assignedTo?: User,
public priority?: 1 | 2 | 3 | 4,
public severity?: 1 | 2 | 3 | 4,
public reproSteps?: string,
) { super(assignedTo, priority); }
}
class Task extends WorkItem {}
const project = new Project();
const story = new UserStory(
{ name: 'Alex Garcia' },
1,
5,
'Given Alex Garcia has this ticket\nWhen he completes it\nThen it will be "Done Done"',
);
project.addWorkItem(story);
console.log('is it done?', story.isItDone);
console.log('is it "Done Done"?', story.isItDoneDone);
console.log('Opening PR...');
story.state = 'Resolved';
console.log('is it done?', story.isItDone);
console.log('is it "Done Done"?', story.isItDoneDone);
console.log('Merging Dev to UAT...');
story.state = 'QA';
console.log('is it done?', story.isItDone);
console.log('is it "Done Done"?', story.isItDoneDone);
console.log('QA Verified!');
story.state = 'Closed';
console.log('is it done?', story.isItDone);
console.log('is it "Done Done"?', story.isItDoneDone);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment