ValidationTests.ts (vaadin-flow-4.0.5) | : | ValidationTests.ts (vaadin-flow-4.0.6) | ||
---|---|---|---|---|
skipping to change at line 121 | skipping to change at line 121 | |||
(binder as any)[methodName](); | (binder as any)[methodName](); | |||
expect(binder.invalid).to.be.false; | expect(binder.invalid).to.be.false; | |||
expect(binder.for(binder.model.customer.fullName).invalid).to.be.false; | expect(binder.for(binder.model.customer.fullName).invalid).to.be.false; | |||
}); | }); | |||
}); | }); | |||
}); | }); | |||
suite('submitTo', () => { | suite('submitTo', () => { | |||
test("should be able to call submit() if onSubmit is pre configured", async () => { | test("should be able to call submit() if onSubmit is pre configured", async () => { | |||
const binder = new Binder(view, OrderModel, { | const binder = new Binder(view, TestModel, { | |||
onSubmit: async () => {} | onSubmit: async () => {} | |||
}); | }); | |||
const binderSubmitToSpy = sinon.spy(binder, 'submitTo'); | const binderSubmitToSpy = sinon.spy(binder, 'submitTo'); | |||
await binder.submit(); | await binder.submit(); | |||
sinon.assert.calledOnce(binderSubmitToSpy); | sinon.assert.calledOnce(binderSubmitToSpy); | |||
}); | }); | |||
test("should return the result of the endpoint call when calling submit()", | ||||
async () => { | ||||
const binder = new Binder(view, TestModel, {onSubmit: async (testEntity) = | ||||
> testEntity}); | ||||
const result = await binder.submit(); | ||||
assert.deepEqual(result, binder.value); | ||||
}) | ||||
test("should throw on validation failure", async () => { | test("should throw on validation failure", async () => { | |||
try { | try { | |||
await binder.submitTo(async() => {}); | await binder.submitTo(async() => {}); | |||
expect.fail(); | expect.fail(); | |||
} catch (error) { | } catch (error) { | |||
expect(error.errors.length).to.gt(0); | expect(error.errors.length).to.gt(0); | |||
} | } | |||
}); | }); | |||
test("should re-throw on server failure", async () => { | test("should re-throw on server failure", async () => { | |||
End of changes. 2 change blocks. | ||||
1 lines changed or deleted | 9 lines changed or added |