AW-3441 another fix...
All checks were successful
FarmMaps/FarmMapsLib/pipeline/head This commit looks good
All checks were successful
FarmMaps/FarmMapsLib/pipeline/head This commit looks good
This commit is contained in:
parent
33f322424e
commit
122563a0bd
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "farmmaps-lib-app",
|
"name": "farmmaps-lib-app",
|
||||||
"version": "1.1.9",
|
"version": "1.1.10",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "ng serve",
|
"start": "ng serve",
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { AppMenuComponent } from './app-menu.component';
|
|
||||||
|
|
||||||
describe('AppMenuComponent', () => {
|
|
||||||
let component: AppMenuComponent;
|
|
||||||
let fixture: ComponentFixture<AppMenuComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [ AppMenuComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(AppMenuComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,25 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { AvatarComponent } from './avatar.component';
|
|
||||||
|
|
||||||
describe('AvatarComponent', () => {
|
|
||||||
let component: AvatarComponent;
|
|
||||||
let fixture: ComponentFixture<AvatarComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [ AvatarComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(AvatarComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,25 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { EditImageModalComponent } from './edit-image-modal.component';
|
|
||||||
|
|
||||||
describe('EditImageModalComponent', () => {
|
|
||||||
let component: EditImageModalComponent;
|
|
||||||
let fixture: ComponentFixture<EditImageModalComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [ EditImageModalComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(EditImageModalComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,25 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { GradientSelectComponent } from './gradient-select.component';
|
|
||||||
|
|
||||||
describe('GradientSelectComponent', () => {
|
|
||||||
let component: GradientSelectComponent;
|
|
||||||
let fixture: ComponentFixture<GradientSelectComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [ GradientSelectComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(GradientSelectComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,25 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { GradientComponent } from './gradient.component';
|
|
||||||
|
|
||||||
describe('GradientComponent', () => {
|
|
||||||
let component: GradientComponent;
|
|
||||||
let fixture: ComponentFixture<GradientComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [ GradientComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(GradientComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,11 +1,13 @@
|
|||||||
import {Directive, Input, OnDestroy, TemplateRef, ViewContainerRef} from '@angular/core';
|
import {AfterViewInit, Directive, Input, OnDestroy, TemplateRef, ViewContainerRef} from '@angular/core';
|
||||||
import {Subscription} from 'rxjs';
|
import {Subscription} from 'rxjs';
|
||||||
import {PackageService} from '../../services/package.service';
|
import {PackageService} from '../../services/package.service';
|
||||||
|
import * as appCommonReducer from '../../reducers/app-common.reducer';
|
||||||
|
import {Store} from '@ngrx/store';
|
||||||
|
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: '[fmHasPackage]',
|
selector: '[fmHasPackage]',
|
||||||
})
|
})
|
||||||
export class HasPackageDirective implements OnDestroy {
|
export class HasPackageDirective implements OnDestroy, AfterViewInit {
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
set fmHasPackage(packageIdentifier: string) {
|
set fmHasPackage(packageIdentifier: string) {
|
||||||
@ -31,8 +33,14 @@ export class HasPackageDirective implements OnDestroy {
|
|||||||
private packSub: Subscription;
|
private packSub: Subscription;
|
||||||
|
|
||||||
constructor(private hostTemplateRef: TemplateRef<any>, private viewContainerRef: ViewContainerRef,
|
constructor(private hostTemplateRef: TemplateRef<any>, private viewContainerRef: ViewContainerRef,
|
||||||
private packageService: PackageService) {
|
private store: Store<appCommonReducer.State>, private packageService: PackageService) {
|
||||||
this.thenTemplate = hostTemplateRef;
|
this.thenTemplate = hostTemplateRef;
|
||||||
|
this.packSub = this.store.select(appCommonReducer.SelectGetUserPackages).subscribe((_) => {
|
||||||
|
this.updateView();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ngAfterViewInit() {
|
||||||
this.updateView();
|
this.updateView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { HelpMenuComponent } from './help-menu.component';
|
|
||||||
|
|
||||||
describe('HelpMenuComponent', () => {
|
|
||||||
let component: HelpMenuComponent;
|
|
||||||
let fixture: ComponentFixture<HelpMenuComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [ HelpMenuComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(HelpMenuComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,25 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { NotificationMenuComponent } from './notification-menu.component';
|
|
||||||
|
|
||||||
describe('NotificationMenuComponent', () => {
|
|
||||||
let component: NotificationMenuComponent;
|
|
||||||
let fixture: ComponentFixture<NotificationMenuComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [ NotificationMenuComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(NotificationMenuComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,25 +0,0 @@
|
|||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { UserMenuComponent } from './user-menu.component';
|
|
||||||
|
|
||||||
describe('UserMenuComponent', () => {
|
|
||||||
let component: UserMenuComponent;
|
|
||||||
let fixture: ComponentFixture<UserMenuComponent>;
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
declarations: [ UserMenuComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(UserMenuComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@ -8,7 +8,7 @@ import { createSelector, createFeatureSelector, ActionReducerMap } from '@ngrx/s
|
|||||||
|
|
||||||
import { MODULE_NAME } from '../module-name';
|
import { MODULE_NAME } from '../module-name';
|
||||||
import { IItem } from '../models/item';
|
import { IItem } from '../models/item';
|
||||||
import {isValidPackage} from '../services/package.service';
|
import {getValidPackages, isValidPackage} from '../services/package.service';
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
openedModalName: string,
|
openedModalName: string,
|
||||||
@ -208,19 +208,7 @@ export const SelectGetMenuVisible = createSelector(selectAppCommonState,getMenuV
|
|||||||
export const SelectGetUser = createSelector(selectAppCommonState,getUser);
|
export const SelectGetUser = createSelector(selectAppCommonState,getUser);
|
||||||
export const SelectGetUserPackages = createSelector(selectAppCommonState,getUserPackages);
|
export const SelectGetUserPackages = createSelector(selectAppCommonState,getUserPackages);
|
||||||
export const SelectGetValidUserPackages = createSelector(SelectGetUserPackages, (packageMap) => {
|
export const SelectGetValidUserPackages = createSelector(SelectGetUserPackages, (packageMap) => {
|
||||||
const keys = Object.keys(packageMap);
|
return getValidPackages(packageMap);
|
||||||
return keys.filter(k => {
|
|
||||||
const packages = packageMap[k]
|
|
||||||
.filter((p) => isValidPackage(p));
|
|
||||||
|
|
||||||
return packages.length > 0;
|
|
||||||
}).reduce((map, key) => {
|
|
||||||
const packages = packageMap[key];
|
|
||||||
return {
|
|
||||||
...map,
|
|
||||||
key: packages[0]
|
|
||||||
};
|
|
||||||
}, {});
|
|
||||||
});
|
});
|
||||||
export const SelectGetUserSettingsRoot = createSelector(selectAppCommonState,getUserSettingsRoot);
|
export const SelectGetUserSettingsRoot = createSelector(selectAppCommonState,getUserSettingsRoot);
|
||||||
export const SelectGetAccountMenuVisible = createSelector(selectAppCommonState,getAccountMenuVisible);
|
export const SelectGetAccountMenuVisible = createSelector(selectAppCommonState,getAccountMenuVisible);
|
||||||
@ -232,3 +220,4 @@ export const SelectgetUnreadNotifications = createSelector(selectAppCommonState,
|
|||||||
export const SelectGetIsOnline = createSelector(selectAppCommonState,getIsOnline);
|
export const SelectGetIsOnline = createSelector(selectAppCommonState,getIsOnline);
|
||||||
export const SelectGetIsPageMode = createSelector(selectAppCommonState,getIsPageMode);
|
export const SelectGetIsPageMode = createSelector(selectAppCommonState,getIsPageMode);
|
||||||
|
|
||||||
|
|
||||||
|
87
projects/common/src/fm/services/package.service.spec.ts
Normal file
87
projects/common/src/fm/services/package.service.spec.ts
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
import {isValidPackage, PackageService} from './package.service';
|
||||||
|
import {MockStore, provideMockStore} from '@ngrx/store/testing';
|
||||||
|
import {TestBed} from '@angular/core/testing';
|
||||||
|
import * as appCommonReducer from '../reducers/app-common.reducer';
|
||||||
|
import {reducer, State} from '../reducers/app-common.reducer';
|
||||||
|
import * as appCommonActions from '../actions/app-common.actions';
|
||||||
|
import {IItem} from '../models/item';
|
||||||
|
|
||||||
|
describe('PackageService', () => {
|
||||||
|
const initialState = {userPackages: {}} as State;
|
||||||
|
let serviceUnderTest: PackageService;
|
||||||
|
let items;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [
|
||||||
|
provideMockStore({
|
||||||
|
initialState,
|
||||||
|
selectors: [
|
||||||
|
{
|
||||||
|
selector: appCommonReducer.SelectGetValidUserPackages,
|
||||||
|
value: {
|
||||||
|
'vnd.farmmaps.package.zoning': {
|
||||||
|
id: 'vnd.farmmaps.package.zoning',
|
||||||
|
name: 'zoning package',
|
||||||
|
dataDate: '2022-01-25T00:00:00.000000Z'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
const store = TestBed.inject(MockStore);
|
||||||
|
serviceUnderTest = new PackageService(store, null, null);
|
||||||
|
|
||||||
|
items = [
|
||||||
|
{
|
||||||
|
code: '123132',
|
||||||
|
dataDate: '2022-01-25T00:00:00.000000Z',
|
||||||
|
data: {
|
||||||
|
id: 'vnd.farmmaps.package.zoning'
|
||||||
|
}
|
||||||
|
} as IItem,
|
||||||
|
{
|
||||||
|
code: '1231325',
|
||||||
|
dataDate: '2021-01-25T00:00:00.000000Z',
|
||||||
|
data: {
|
||||||
|
id: 'vnd.farmmaps.package.zoning'
|
||||||
|
}
|
||||||
|
} as IItem,
|
||||||
|
{
|
||||||
|
code: '1231325',
|
||||||
|
dataDate: '2022-01-25T00:00:00.000000Z',
|
||||||
|
dataEndDate: '2022-05-25T00:00:00.000000Z',
|
||||||
|
data: {
|
||||||
|
id: 'vnd.farmmaps.package.tipstar'
|
||||||
|
}
|
||||||
|
} as IItem
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Does not have a tipstar package', () => {
|
||||||
|
const hasPackage = serviceUnderTest.hasPackage('vnd.farmmaps.package.tipstar');
|
||||||
|
expect(hasPackage).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Does have a zoning package', () => {
|
||||||
|
const hasPackage = serviceUnderTest.hasPackage('vnd.farmmaps.package.zoning');
|
||||||
|
expect(hasPackage).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('reducer.INITUSERPACKAGESSUCCESS alter state correctly', () => {
|
||||||
|
const action = new appCommonActions.InitUserPackagesSuccess(items);
|
||||||
|
|
||||||
|
expect(Object.keys(initialState.userPackages).length).toBe(0);
|
||||||
|
const state = reducer(initialState, action);
|
||||||
|
expect(Object.keys(state.userPackages).length).toBe(2);
|
||||||
|
expect(state.userPackages['vnd.farmmaps.package.zoning'].length).toBe(2);
|
||||||
|
expect(state.userPackages['vnd.farmmaps.package.tipstar'].length).toBe(1);
|
||||||
|
|
||||||
|
expect(isValidPackage(state.userPackages['vnd.farmmaps.package.tipstar'][0])).toBe(true);
|
||||||
|
expect(isValidPackage(state.userPackages['vnd.farmmaps.package.zoning'][0])).toBe(true);
|
||||||
|
expect(isValidPackage(state.userPackages['vnd.farmmaps.package.zoning'][1])).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
@ -1,7 +1,7 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {Store} from '@ngrx/store';
|
import {Store} from '@ngrx/store';
|
||||||
import * as appCommonReducer from '../reducers/app-common.reducer';
|
import * as appCommonReducer from '../reducers/app-common.reducer';
|
||||||
import {IPackage} from '../models/package';
|
import {IPackage, IPackages} from '../models/package';
|
||||||
|
|
||||||
import {IItem} from '../models/item';
|
import {IItem} from '../models/item';
|
||||||
import {IItemTask} from '../models/itemTask';
|
import {IItemTask} from '../models/itemTask';
|
||||||
@ -35,6 +35,22 @@ export class PackageService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getValidPackages(packageMap: IPackages): {[key: string]: IPackage} {
|
||||||
|
const keys = Object.keys(packageMap);
|
||||||
|
return keys.filter(k => {
|
||||||
|
const packages = packageMap[k]
|
||||||
|
.filter((p) => isValidPackage(p));
|
||||||
|
|
||||||
|
return packages.length > 0;
|
||||||
|
}).reduce((map, key) => {
|
||||||
|
const packages = packageMap[key];
|
||||||
|
return {
|
||||||
|
...map,
|
||||||
|
key: packages[0]
|
||||||
|
};
|
||||||
|
}, {});
|
||||||
|
}
|
||||||
|
|
||||||
export function isValidPackage(pack: IPackage): boolean {
|
export function isValidPackage(pack: IPackage): boolean {
|
||||||
const today = new Date(new Date(Date.now()).toUTCString()).setHours(0, 0, 0, 0);
|
const today = new Date(new Date(Date.now()).toUTCString()).setHours(0, 0, 0, 0);
|
||||||
return pack !== null && new Date(pack.dataDate).getTime() <= today
|
return pack !== null && new Date(pack.dataDate).getTime() <= today
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { TestComponent } from './landingpage.component';
|
|
||||||
|
|
||||||
describe('TestComponent', () => {
|
|
||||||
let component: TestComponent;
|
|
||||||
let fixture: ComponentFixture<TestComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [ TestComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(TestComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,25 +0,0 @@
|
|||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { MenuComponent } from './menu.component';
|
|
||||||
|
|
||||||
describe('MenuComponent', () => {
|
|
||||||
let component: MenuComponent;
|
|
||||||
let fixture: ComponentFixture<MenuComponent>;
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
declarations: [ MenuComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(MenuComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,25 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { TestComponent } from './test.component';
|
|
||||||
|
|
||||||
describe('TestComponent', () => {
|
|
||||||
let component: TestComponent;
|
|
||||||
let fixture: ComponentFixture<TestComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [ TestComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(TestComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
Loading…
Reference in New Issue
Block a user