- From: Marcos Caceres <marcos@marcosc.com>
- Date: Sun, 13 Nov 2016 23:52:57 -0800
- To: public-payments-testing <public-payments-testing@w3.org>
So, I've started trying to see how testable the spec is and putting a rough test suite together (to test against a reference implementation I'm working on in JS). The spec still needs quite a bit a of work before we can lay down a proper test suite. I've been filing bugs, but already hit some snags in the PaymentRequest constructor and general architecture of the API. No deal breakers, but mostly just seeking clarification on various things right now. Instead of spending too much time on infrastructure, we should start with a fairly "throw away" set of tests to validate all the testable assertions in the spec. These would basically look like this: ```JS /** * PaymentRequest constructor * https://w3c.github.io/browser-payment-api/#paymentrequest-constructor */ try { // Smoke tests new PaymentRequest([{ supportedMethods: ["visa"] }]); } catch (err) { console.assert(false, "Unexpected exception", err); } const invalidMethods = [ [{ supportedMethods: [] }], [{ supportedMethods: ["visa", "bitcoin"] }, { supportedMethods: [] }], [{ supportedMethods: ["visa"] }, { supportedMethods: [] }, { supportedMethods: ["bitcoin"] }], ] invalidMethods.forEach(invalidMethod => { try { new PaymentRequest(invalidMethod, validDetails); console.assert(false, "For each PaymentMethodData dictionary, if the length of the supportedMethods sequence is zero, then throw a TypeError.") } catch (err) { const isTypeError = err instanceof TypeError; console.assert(isTypeError, "the exception must be an instance of TypeError"); } }); // And so on... ``` Whatever survives, we can easily migrate to Web Platform Tests. However, I suspect we will be rewriting these tests for a while, as the spec is still a bit immature. Kind regards, Marcos
Received on Monday, 14 November 2016 07:53:31 UTC