Skip to content

Commit 458e89a

Browse files
author
Leo Vo
committed
Fix build.
1 parent 8723ca7 commit 458e89a

File tree

7 files changed

+59
-37
lines changed

7 files changed

+59
-37
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ngx-treeview",
3-
"version": "0.0.6",
3+
"version": "1.0.5",
44
"license": "MIT",
55
"description": "An Angular treeview component with checkbox",
66
"scripts": {
@@ -11,8 +11,8 @@
1111
"test-coverage": "ng test --code-coverage",
1212
"test-ci": "ng test --watch=false --code-coverage --single-run=true",
1313
"e2e": "ng e2e",
14-
"build:lib": "rimraf dist/lib && ngc -p tsconfig-lib.json && gulp && rollup -c rollup.config.js && copyfiles package.json README.md LICENSE dist/lib",
15-
"build:demo": "npm run build:lib && rimraf dist/demo && ng build --app demo --prod",
14+
"build:lib": "rimraf dist/lib && ngc -p tsconfig-lib.json && gulp && copyfiles package.json README.md LICENSE dist/lib",
15+
"build:demo": "npm run build:lib && rimraf dist/demo && ng build --app demo",
1616
"build": "rimraf dist && npm run build:demo",
1717
"pub:demo": "npm run build:demo -- --base-href /ngx-treeview/ && gh-pages -d dist/demo",
1818
"pub:lib": "npm run build:lib && npm publish dist/lib",
@@ -42,7 +42,7 @@
4242
},
4343
"main": "./bundles/ngx-treeview.umd.js",
4444
"module": "./src/index.js",
45-
"jsnext:main": "src/index.js",
45+
"jsnext:main": "./src/index.js",
4646
"typings": "./src/index.d.ts",
4747
"private": false,
4848
"peerDependencies": {

rollup.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export default {
22
entry: 'dist/lib/src/index.js',
33
dest: 'dist/lib/bundles/ngx-treeview.umd.js',
44
sourceMap: true,
5-
format: 'umd',
5+
format: 'iife',
66
onwarn: function (warning) {
77
// Skip certain warnings
88

@@ -20,9 +20,9 @@ export default {
2020
'lodash'
2121
],
2222
globals: {
23-
'@angular/common': 'ng.common',
24-
'@angular/core': 'ng.core',
25-
'@angular/forms': 'ng.forms',
23+
'@angular/common': '_angular_common',
24+
'@angular/core': '_angular_core',
25+
'@angular/forms': 'angular_form',
2626
'lodash': 'lodash'
2727
}
2828
}

src/lib/dropdown-treeview.component.spec.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ const createTestComponent = (html: string) =>
4242

4343
describe('DropdownTreeviewComponent', () => {
4444
// tslint:disable-next-line:max-line-length
45-
const template = '<ngx-dropdown-treeview [items]="items" [config]="config" (selectedChange)="selectedChange($event)"></ngx-dropdown-treeview>';
45+
const template = '<ngx-dropdown-treeview [items]="items" (selectedChange)="selectedChange($event)"></ngx-dropdown-treeview>';
4646
let spy: jasmine.Spy;
47+
let button: DebugElement;
4748

4849
beforeEach(() => {
4950
TestBed.configureTestingModule({
@@ -66,24 +67,26 @@ describe('DropdownTreeviewComponent', () => {
6667
spy = spyOn(fakeData, 'selectedChange');
6768
});
6869

70+
beforeEach(fakeAsync(() => {
71+
spy.calls.reset();
72+
fakeData.items = [new TreeviewItem({ text: '1', value: 1 })];
73+
const fixture = createTestComponent(template);
74+
fixture.detectChanges();
75+
tick();
76+
button = fixture.debugElement.query(By.css('button'));
77+
}));
78+
6979
it('should initialize with default config', () => {
7080
const defaultConfig = new TreeviewConfig();
7181
const component = TestBed.createComponent(DropdownTreeviewComponent).componentInstance;
7282
expect(component.config).toEqual(defaultConfig);
7383
});
7484

75-
describe('selectedChange', () => {
76-
beforeEach(fakeAsync(() => {
77-
spy.calls.reset();
78-
fakeData.config = new TreeviewConfig();
79-
fakeData.items = [new TreeviewItem({ text: '1', value: 1 })];
80-
const fixture = createTestComponent(template);
81-
fixture.detectChanges();
82-
tick();
83-
}));
85+
it('should raise event selectedChange when initializing', () => {
86+
expect(spy.calls.any()).toBeTruthy();
87+
});
8488

85-
it('should raise event selectedChange', () => {
86-
expect(spy.calls.any()).toBeTruthy();
87-
});
89+
it('should display button text "All"', () => {
90+
expect(button.nativeElement).toHaveTrimmedText('All');
8891
});
8992
});

src/lib/treeview.component.html

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,31 @@
99
</label>
1010
</div>
1111
</ng-template>
12-
<div [ngSwitch]="hasFilterItems">
13-
<div *ngSwitchCase="true" class="treeview-header">
14-
<div *ngIf="config.isShowFilter" class="row">
15-
<div class="col-12">
16-
<input class="form-control" type="text" [placeholder]="i18n.filterPlaceholder()" [(ngModel)]="filterText" (ngModelChange)="onFilterTextChange()"
17-
/>
18-
</div>
12+
<div class="treeview-header">
13+
<div *ngIf="config.isShowFilter" class="row">
14+
<div class="col-12">
15+
<input class="form-control" type="text" [placeholder]="i18n.filterPlaceholder()" [(ngModel)]="filterText" (ngModelChange)="onFilterTextChange()"
16+
/>
1917
</div>
20-
<div *ngIf="hasFilterItems">
21-
<div *ngIf="config.isShowAllCheckBox || config.isShowCollapseExpand" class="row">
22-
<div class="col-12" [class.row-margin]="config.isShowFilter && (config.isShowAllCheckBox || config.isShowCollapseExpand)">
23-
<label *ngIf="config.isShowAllCheckBox" class="form-check-label label-item-all">
18+
</div>
19+
<div *ngIf="hasFilterItems">
20+
<div *ngIf="config.isShowAllCheckBox || config.isShowCollapseExpand" class="row">
21+
<div class="col-12" [class.row-margin]="config.isShowFilter && (config.isShowAllCheckBox || config.isShowCollapseExpand)">
22+
<label *ngIf="config.isShowAllCheckBox" class="form-check-label label-item-all">
2423
<input type="checkbox" class="form-check-input"
2524
[(ngModel)]="allItem.checked" (ngModelChange)="onAllCheckedChange($event)" />
2625
{{i18n.allCheckboxText()}}
2726
</label>
28-
<label *ngIf="config.isShowCollapseExpand" class="pull-right label-collapse-expand" (click)="toggleCollapseExpand()">
27+
<label *ngIf="config.isShowCollapseExpand" class="pull-right label-collapse-expand" (click)="toggleCollapseExpand()">
2928
<i [title]="i18n.tooltipCollapseExpand(allItem.collapsed)" aria-hidden="true"
3029
class="fa" [class.fa-expand]="allItem.collapsed" [class.fa-compress]="!allItem.collapsed"></i>
3130
</label>
32-
</div>
3331
</div>
34-
<div *ngIf="config.isShowFilter || config.isShowAllCheckBox || config.isShowCollapseExpand" class="divider"></div>
3532
</div>
33+
<div *ngIf="config.isShowFilter || config.isShowAllCheckBox || config.isShowCollapseExpand" class="divider"></div>
3634
</div>
35+
</div>
36+
<div [ngSwitch]="hasFilterItems">
3737
<div *ngSwitchCase="true" class="treeview-container" [style.max-height.px]="maxHeight">
3838
<ngx-treeview-item *ngFor="let item of filterItems" [item]="item" [template]="template || tpl" (checkedChange)="onItemCheckedChange(item, $event)">
3939
</ngx-treeview-item>

src/lib/treeview.component.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,11 @@ describe('TreeviewComponent', () => {
694694
tick();
695695
}));
696696

697+
it('should display filter', () => {
698+
const filterInput = fixture.debugElement.query(By.css('input[type="text"]'));
699+
expect(filterInput).not.toBeNull();
700+
});
701+
697702
it('should not display any items', () => {
698703
const texts = queryItemTexts(fixture.debugElement);
699704
expect(texts).toEqual([]);
@@ -702,7 +707,7 @@ describe('TreeviewComponent', () => {
702707
it('should display a text "No items found"', () => {
703708
const textElement = fixture.debugElement.query(By.css('.treeview-text'));
704709
expect(textElement.nativeElement.textContent.trim()).toBe('No items found');
705-
})
710+
});
706711
});
707712
});
708713
});

src/testing/jasmine-matchers.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ export interface NgMatchers extends jasmine.Matchers {
4848
*/
4949
toHaveText(expected: string): boolean;
5050

51+
toHaveTrimmedText(expected: string): boolean;
52+
5153
/**
5254
* Expect the element to have the given CSS class.
5355
*
@@ -173,6 +175,18 @@ _global.beforeEach(function () {
173175
};
174176
},
175177

178+
toHaveTrimmedText: function () {
179+
return {
180+
compare: function (actual: any, expectedText: string) {
181+
const actualText = elementText(actual).trim();
182+
return {
183+
pass: actualText === expectedText,
184+
get message() { return 'Expected ' + actualText + ' to be equal to ' + expectedText; }
185+
};
186+
}
187+
};
188+
},
189+
176190
toHaveCssClass: function () {
177191
return { compare: buildError(false), negativeCompare: buildError(true) };
178192

tsconfig-lib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
],
2424
"angularCompilerOptions": {
2525
"skipTemplateCodegen": true,
26-
"skipMetadataEmit": true
26+
"strictMetadataEmit": true
2727
}
2828
}

0 commit comments

Comments
 (0)