mirror of
https://github.com/bringout/oca-ocb-report.git
synced 2026-04-23 20:22:07 +02:00
19.0 vanilla
This commit is contained in:
parent
62d197ac8b
commit
184bb0e321
667 changed files with 691406 additions and 239886 deletions
|
|
@ -0,0 +1,53 @@
|
|||
// @ts-check
|
||||
|
||||
import { stores } from "@odoo/o-spreadsheet";
|
||||
import { createModelWithDataSource } from "@spreadsheet/../tests/helpers/model";
|
||||
|
||||
const { ModelStore, NotificationStore, DependencyContainer } = stores;
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @typedef {import("@odoo/o-spreadsheet").StoreConstructor<T>} StoreConstructor<T>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {import("@spreadsheet").OdooSpreadsheetModel} OdooSpreadsheetModel
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {StoreConstructor<T>} Store
|
||||
* @param {any[]} args
|
||||
* @return {Promise<{ store: T, container: InstanceType<DependencyContainer>, model: OdooSpreadsheetModel }>}
|
||||
*/
|
||||
export async function makeStore(Store, ...args) {
|
||||
const { model } = await createModelWithDataSource();
|
||||
return makeStoreWithModel(model, Store, ...args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {import("@odoo/o-spreadsheet").Model} model
|
||||
* @param {StoreConstructor<T>} Store
|
||||
* @param {any[]} args
|
||||
* @return {{ store: T, container: InstanceType<DependencyContainer>, model: OdooSpreadsheetModel }}
|
||||
*/
|
||||
export function makeStoreWithModel(model, Store, ...args) {
|
||||
const container = new DependencyContainer();
|
||||
container.inject(ModelStore, model);
|
||||
container.inject(NotificationStore, makeTestNotificationStore());
|
||||
return {
|
||||
store: container.instantiate(Store, ...args),
|
||||
container,
|
||||
// @ts-ignore
|
||||
model: container.get(ModelStore),
|
||||
};
|
||||
}
|
||||
|
||||
function makeTestNotificationStore() {
|
||||
return {
|
||||
notifyUser: () => {},
|
||||
raiseError: () => {},
|
||||
askConfirmation: () => {},
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue