Skip to content

Commit b4378e8

Browse files
committed
refactor: downgrading version and fixing tests
1 parent bef0dc8 commit b4378e8

File tree

6 files changed

+39
-22
lines changed

6 files changed

+39
-22
lines changed

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"iso8601-duration": "^1.3.0",
6565
"lodash-es": "^4.17.21",
6666
"mixpanel-browser": "^2.42.0",
67-
"ngx-color": "^7.3.3",
67+
"ngx-color": "7.0.0",
6868
"rxjs": "~6.6.7",
6969
"tslib": "^2.3.1",
7070
"uuid": "^8.3.2",

projects/components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"d3-scale": "^3.3.0",
2929
"d3-selection": "^1.4.2",
3030
"d3-shape": "^1.3.5",
31-
"ngx-color": "^7.3.3"
31+
"ngx-color": "7.0.0"
3232
},
3333
"devDependencies": {
3434
"@hypertrace/test-utils": "^0.0.0"
Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
1+
import { CommonModule } from '@angular/common';
2+
import { fakeAsync } from '@angular/core/testing';
13
import { IconType } from '@hypertrace/assets-library';
4+
import { Color, NavigationService } from '@hypertrace/common';
25
import { IconComponent } from '@hypertrace/components';
36
import { createHostFactory, mockProvider, Spectator } from '@ngneat/spectator/jest';
4-
import { ColorPickerComponent } from './color-picker.component';
7+
import { MockComponent } from 'ng-mocks';
58
import { SketchComponent } from 'ngx-color/sketch';
6-
import { PopoverModule } from '../popover/popover.module';
9+
import { NEVER, Observable } from 'rxjs';
710
import { NotificationService } from '../notification/notification.service';
8-
import { CommonModule } from '@angular/common';
9-
import { Observable } from 'rxjs';
10-
import { MockComponent } from 'ng-mocks';
11+
import { PopoverModule } from '../popover/popover.module';
12+
import { ColorPickerComponent } from './color-picker.component';
1113

1214
describe('Color Picker component', () => {
1315
let spectator: Spectator<ColorPickerComponent>;
1416

1517
const createHost = createHostFactory({
1618
component: ColorPickerComponent,
1719
imports: [CommonModule, PopoverModule],
18-
providers: [mockProvider(NotificationService, { withNotification: (x: Observable<unknown>) => x })],
19-
declareComponent: false,
20+
providers: [
21+
mockProvider(NotificationService, { withNotification: (x: Observable<unknown>) => x }),
22+
mockProvider(NavigationService, {
23+
navigation$: NEVER
24+
})
25+
],
2026
declarations: [MockComponent(SketchComponent), MockComponent(IconComponent)]
2127
});
2228

23-
test('should render color picker with default colors', () => {
29+
test('should render color picker with default colors', fakeAsync(() => {
2430
const onSelectionChangeSpy = jest.fn();
2531
spectator = createHost(
2632
`<ht-color-picker (selectedChange)="onSelectionChange($event)">
@@ -32,7 +38,17 @@ describe('Color Picker component', () => {
3238
}
3339
);
3440

35-
expect(spectator.queryAll('.color-picker .color').length).toBe(7);
41+
const colors = spectator.queryAll('.color-picker .color');
42+
expect(colors.length).toBe(7);
3643
expect(spectator.query(IconComponent)?.icon).toBe(IconType.Add);
37-
});
44+
45+
spectator.click(colors[1]);
46+
expect(spectator.component.selected).toEqual(Color.Blue3);
47+
expect(onSelectionChangeSpy).toHaveBeenCalledWith(Color.Blue3);
48+
49+
spectator.click('.add-icon');
50+
spectator.tick();
51+
52+
expect(spectator.query('.color-sketch', { root: true })).toExist();
53+
}));
3854
});

projects/components/src/color-picker/color-picker.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { IconSize } from '../icon/icon-size';
2626
></div>
2727
<ht-popover>
2828
<ht-popover-trigger>
29-
<ht-icon icon="${IconType.Add}" size="${IconSize.Small}"></ht-icon>
29+
<ht-icon class="add-icon" icon="${IconType.Add}" size="${IconSize.Small}"></ht-icon>
3030
</ht-popover-trigger>
3131
<ht-popover-content>
3232
<div class="container">

tsconfig.base.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"noUnusedLocals": true,
1717
"noUnusedParameters": true,
1818
"downlevelIteration": true,
19+
"allowJs": true,
1920
"lib": ["es2015", "es2016", "es2017", "esnext.string", "esnext.array", "esnext.asynciterable", "dom"],
2021
"paths": {
2122
"@hypertrace/assets-library": ["projects/assets-library/src/public-api.ts"],

0 commit comments

Comments
 (0)