Skip to content

Commit

Permalink
chore: cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
Wendell committed May 17, 2019
1 parent e626bca commit 7c99bba
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "ng test parser",
"type": "chrome",
"request": "launch",
"url": "http://localhost:9876/debug.html",
"webRoot": "${workspaceFolder}",
"sourceMaps": true,
"sourceMapPathOverrides": {
"/./*": "${webRoot}/*",
"/src/*": "${webRoot}/*",
"/*": "*",
"/./~/*": "${webRoot}/node_modules/*"
}
}
]
}
9 changes: 5 additions & 4 deletions components/breadcrumb/nz-breadcrumb.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class NzBreadCrumbComponent implements OnInit, OnDestroy {
this.cdr.markForCheck();
});
} catch (e) {
throw new Error('[NG-ZORRO] You should import RouterModule if you want to use NzAutoGenerate');
throw new Error('[NG-ZORRO] You should import RouterModule if you want to use `NzAutoGenerate`');
}
}

Expand All @@ -126,11 +126,12 @@ export class NzBreadCrumbComponent implements OnInit, OnDestroy {
// Only parse components in primary router-outlet (in another word, router-outlet without a specific name).
// Parse this layer and generate a breadcrumb item.
const routeURL: string = child.snapshot.url.map(segment => segment.path).join('/');
const nextUrl = url.replace(/\/$/, '') + `/${routeURL}`;
const nextUrl = url + `/${routeURL}`;
const breadcrumbLabel = child.snapshot.data[NZ_ROUTE_DATA_BREADCRUMB];
// If have data, go to generate a breadcrumb for it.
if (routeURL && child.snapshot.data.hasOwnProperty(NZ_ROUTE_DATA_BREADCRUMB)) {
if (routeURL && breadcrumbLabel) {
const breadcrumb: BreadcrumbOption = {
label: child.snapshot.data[NZ_ROUTE_DATA_BREADCRUMB] || 'Breadcrumb',
label: breadcrumbLabel,
params: child.snapshot.params,
url: nextUrl
};
Expand Down
10 changes: 8 additions & 2 deletions components/breadcrumb/nz-breadcrumb.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ const routes: Routes = [
{
path: 'one',
component: NzBreadcrumbAutoGenerateDemoComponent,
data: {
breadcrumb: ''
},
children: [
{
path: 'two',
Expand All @@ -184,12 +187,15 @@ const routes: Routes = [
path: 'three',
component: NzBreadcrumbNullComponent,
data: {
breadcrumb: ''
breadcrumb: 'Layer 3'
},
children: [
{
path: 'four',
component: NzBreadcrumbNullComponent
component: NzBreadcrumbNullComponent,
data: {
breadcrumb: ''
}
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion components/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ getTestBed().initTestEnvironment(
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
const context = require.context('./', true, /breadcrumb\.spec\.ts$/);
// And load the modules.
context.keys().map(context);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"site:start": "npm run site:init && ng serve --port 0 --open",
"site": "node ./scripts/site/generate-site",
"start": "ng serve --port 0",
"test": "ng test --watch=false --code-coverage"
"test": "ng test --no-watch --no-progress"
},
"dependencies": {
"@angular/cdk": "^7.3.0",
Expand Down

0 comments on commit 7c99bba

Please sign in to comment.