mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 06:43:35 +00:00
add specs for send list filters
This commit is contained in:
@@ -35,6 +35,7 @@ module.exports = {
|
|||||||
"<rootDir>/libs/tools/generator/extensions/history/jest.config.js",
|
"<rootDir>/libs/tools/generator/extensions/history/jest.config.js",
|
||||||
"<rootDir>/libs/tools/generator/extensions/legacy/jest.config.js",
|
"<rootDir>/libs/tools/generator/extensions/legacy/jest.config.js",
|
||||||
"<rootDir>/libs/tools/generator/extensions/navigation/jest.config.js",
|
"<rootDir>/libs/tools/generator/extensions/navigation/jest.config.js",
|
||||||
|
"<rootDir>/libs/tools/send/send-ui/jest.config.js",
|
||||||
"<rootDir>/libs/importer/jest.config.js",
|
"<rootDir>/libs/importer/jest.config.js",
|
||||||
"<rootDir>/libs/platform/jest.config.js",
|
"<rootDir>/libs/platform/jest.config.js",
|
||||||
"<rootDir>/libs/node/jest.config.js",
|
"<rootDir>/libs/node/jest.config.js",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"extends": "../../../../shared/tsconfig.libs",
|
"extends": "../../../../shared/tsconfig.libs",
|
||||||
"include": ["src"],
|
"include": ["src", "../../../send/send-ui/src/services/send-list-filters.service.spec.ts"],
|
||||||
"exclude": ["node_modules", "dist"]
|
"exclude": ["node_modules", "dist"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ const { compilerOptions } = require("../../../shared/tsconfig.libs");
|
|||||||
/** @type {import('jest').Config} */
|
/** @type {import('jest').Config} */
|
||||||
module.exports = {
|
module.exports = {
|
||||||
testMatch: ["**/+(*.)+(spec).+(ts)"],
|
testMatch: ["**/+(*.)+(spec).+(ts)"],
|
||||||
preset: "ts-jest",
|
preset: "jest-preset-angular",
|
||||||
testEnvironment: "jsdom",
|
setupFilesAfterEnv: ["<rootDir>/test.setup.ts"],
|
||||||
moduleNameMapper: pathsToModuleNameMapper(compilerOptions?.paths || {}, {
|
moduleNameMapper: pathsToModuleNameMapper(compilerOptions?.paths || {}, {
|
||||||
prefix: "<rootDir>/../../../",
|
prefix: "<rootDir>/../../",
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,19 +6,13 @@ import { PolicyService } from "@bitwarden/common/admin-console/abstractions/poli
|
|||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
|
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
|
||||||
import { Send } from "@bitwarden/common/tools/send/models/domain/send";
|
import { Send } from "@bitwarden/common/tools/send/models/domain/send";
|
||||||
import { SendService } from "@bitwarden/common/tools/send/services/send.service.abstraction";
|
|
||||||
|
|
||||||
import { SendListFiltersService } from "./send-list-filters.service";
|
import { SendListFiltersService } from "./send-list-filters.service";
|
||||||
|
|
||||||
describe("SendListFiltersService", () => {
|
describe("SendListFiltersService", () => {
|
||||||
let service: SendListFiltersService;
|
let service: SendListFiltersService;
|
||||||
const sends$ = new BehaviorSubject({});
|
|
||||||
const policyAppliesToActiveUser$ = new BehaviorSubject<boolean>(false);
|
const policyAppliesToActiveUser$ = new BehaviorSubject<boolean>(false);
|
||||||
|
|
||||||
const sendService = {
|
|
||||||
sends$,
|
|
||||||
} as unknown as SendService;
|
|
||||||
|
|
||||||
const i18nService = {
|
const i18nService = {
|
||||||
t: (key: string) => key,
|
t: (key: string) => key,
|
||||||
} as I18nService;
|
} as I18nService;
|
||||||
@@ -33,10 +27,6 @@ describe("SendListFiltersService", () => {
|
|||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
providers: [
|
providers: [
|
||||||
{
|
|
||||||
provide: SendService,
|
|
||||||
useValue: sendService,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
provide: I18nService,
|
provide: I18nService,
|
||||||
useValue: i18nService,
|
useValue: i18nService,
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { map, Observable, startWith } from "rxjs";
|
|||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
|
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
|
||||||
import { Send } from "@bitwarden/common/tools/send/models/domain/send";
|
import { Send } from "@bitwarden/common/tools/send/models/domain/send";
|
||||||
import { SendService } from "@bitwarden/common/tools/send/services/send.service";
|
|
||||||
import { ITreeNodeObject, TreeNode } from "@bitwarden/common/vault/models/domain/tree-node";
|
import { ITreeNodeObject, TreeNode } from "@bitwarden/common/vault/models/domain/tree-node";
|
||||||
import { ChipSelectOption } from "@bitwarden/components";
|
import { ChipSelectOption } from "@bitwarden/components";
|
||||||
|
|
||||||
@@ -33,23 +32,9 @@ export class SendListFiltersService {
|
|||||||
startWith(INITIAL_FILTERS),
|
startWith(INITIAL_FILTERS),
|
||||||
) as Observable<SendListFilter>;
|
) as Observable<SendListFilter>;
|
||||||
|
|
||||||
/**
|
|
||||||
* All available sends
|
|
||||||
**/
|
|
||||||
|
|
||||||
private sends: Send[] = [];
|
|
||||||
|
|
||||||
private sends$: Observable<Send[]> = this.sendService.sends$.pipe(
|
|
||||||
map((sends) => {
|
|
||||||
this.sends = sends;
|
|
||||||
return sends;
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
private sendService: SendService,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
1
libs/tools/send/send-ui/test.setup.ts
Normal file
1
libs/tools/send/send-ui/test.setup.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
import "jest-preset-angular/setup-jest";
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
{
|
{
|
||||||
"extends": "./tsconfig.json"
|
"extends": "./tsconfig.json",
|
||||||
|
"include": ["src"],
|
||||||
|
"files": ["./test.setup.ts"],
|
||||||
|
"exclude": ["node_modules", "dist"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user