-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(category)!: create breadcrumbs and add
createTree
method (#2629)
BREAKING CHANGE: `DaffCategoryFactory` now requires `DaffCategoryBreadcrumbFactory` as a constructor argument. It is recommended to DI the factory
- Loading branch information
Showing
7 changed files
with
191 additions
and
35 deletions.
There are no files selected for viewing
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
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
37 changes: 37 additions & 0 deletions
37
libs/category/testing/src/factories/category-breadcrumb.factory.spec.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { DaffCategoryBreadcrumb } from '@daffodil/category'; | ||
|
||
import { DaffCategoryBreadcrumbFactory } from './category-breadcrumb.factory'; | ||
|
||
describe('@daffodil/category/testing | DaffCategoryBreadcrumbFactory', () => { | ||
let factory: DaffCategoryBreadcrumbFactory; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
providers: [DaffCategoryBreadcrumbFactory], | ||
}); | ||
|
||
factory = TestBed.inject(DaffCategoryBreadcrumbFactory); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(factory).toBeTruthy(); | ||
}); | ||
|
||
describe('create', () => { | ||
|
||
let result: DaffCategoryBreadcrumb; | ||
|
||
beforeEach(() => { | ||
result = factory.create(); | ||
}); | ||
|
||
it('should return a Category with all required fields defined', () => { | ||
expect(result.id).toBeDefined(); | ||
expect(result.url).toBeDefined(); | ||
expect(result.name).toBeDefined(); | ||
expect(result.level).toBeDefined(); | ||
}); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
libs/category/testing/src/factories/category-breadcrumb.factory.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { faker } from '@faker-js/faker/locale/en_US'; | ||
|
||
import { DaffCategoryBreadcrumb } from '@daffodil/category'; | ||
import { DaffModelFactory } from '@daffodil/core/testing'; | ||
|
||
export class MockCategoryBreadcrumb implements DaffCategoryBreadcrumb { | ||
id = faker.datatype.uuid(); | ||
name = faker.commerce.productMaterial(); | ||
level = faker.datatype.number({ min: 1, max: 5 }); | ||
url = faker.commerce.productMaterial(); | ||
} | ||
|
||
/** | ||
* A factory for creating a {@link DaffCategoryBreadcrumb}. | ||
*/ | ||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class DaffCategoryBreadcrumbFactory extends DaffModelFactory<DaffCategoryBreadcrumb, typeof MockCategoryBreadcrumb>{ | ||
constructor() { | ||
super(MockCategoryBreadcrumb); | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
export { DaffCategoryFactory } from './category.factory'; | ||
export { | ||
DaffCategoryPageMetadataFactory, | ||
MockCategoryPageMetadata, | ||
} from './category-page-metadata.factory'; | ||
export * from './category.factory'; | ||
export * from './category-breadcrumb.factory'; | ||
export * from './category-page-metadata.factory'; |