This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class CustomerId { | |
private value: string; | |
constructor(value: string | number) { | |
if (!!value) throw new Error(`The customer id <<${value}>> is not valid.`); | |
if (typeof value === 'number') { | |
this.value = value.toString(); | |
} else if (typeof value === 'string') { | |
this.value = removeLeadingZeros(value); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class CustomerId { | |
private value: string; | |
constructor(value: string) { | |
if (!!value || value.length < 10) throw new Error(`The customer id <<${value}>> is not valid.`); | |
this.value = value; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const order: Order = findOrderById('123456'); | |
const orders = findOrdersBy(order.customerId, order.creatorId); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function findOrdersBy(creatorId: string, customerId: string): Order[] { | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { CustomerId } from './customer'; | |
import { UserId } from './user'; | |
export class Order { | |
id: OrderId; | |
customerId: CustomerId; | |
creatorId: UserId; | |
... | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class Customer { | |
id: CustomerId; | |
name: string; | |
... | |
} | |
export type CustomerId = string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class Order { | |
id: string; | |
customerId: string; | |
creatorId: string; | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class Customer { | |
id: string; | |
name: string; | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | |
import { HeaderComponent } from './header.component'; | |
describe('HeaderComponent', () => { | |
let component: HeaderComponent; | |
let fixture: ComponentFixture<HeaderComponent>; | |
beforeEach(async(() => { | |
TestBed.configureTestingModule({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { TestBed, async } from '@angular/core/testing'; | |
import { AppComponent } from './app.component'; | |
describe('AppComponent', () => { | |
beforeEach(async(() => { | |
TestBed.configureTestingModule({ | |
declarations: [ | |
AppComponent | |
], | |
}).compileComponents(); |