import { TestHelper, ContextService } from "@dms";
import * as fs from "fs";
import * as sinon from "sinon";
import { MyView} from "../../src/Views/MyView";
let sandbox: sinon.SinonSandbox;
describe("MyView Task", () => {
//reset sandbox before each test
if (!sandbox) sandbox = sinon.createSandbox();
//reset sandbox after each test
//this is the actual test of the view
it("MyView View", async () => {
//set myVar vairable, which is required by the view
const contextService = RootDIContainer.inject(ContextService);
await contextService.set('myVar', 123);
const viewHtml = fs.readFileSync(
"./src/Views/MyView.html",
//create view instance and execute the view loading sequence
const myViewInstance = (await TestHelper.createView(
//call validate method and test the result
const validated = await myViewInstance.validate();
expect(validated).toBeTruthy();
//call commit method and test the result
const commited = await myViewInstance.confirm();
expect(commited).toBeTruthy();
//call other view method and test the result
const value = await myViewInstance.getValue();
expect(commited).toBe(123);