Skip to content

Commit

Permalink
Remove tests for supportedTypes from payment handler (#13860)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres authored Nov 1, 2018
1 parent a6322a0 commit 5d4871b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 39 deletions.
23 changes: 0 additions & 23 deletions payment-handler/basic-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,6 @@ self.addEventListener('paymentrequest', event => {
return;
}

const supportedTypes = methodData.data.supportedTypes;
if (!supportedTypes) {
const msg = 'Expected supported types in payment method specific data';
event.respondWith(Promise.reject(new Error(msg)));
return;
}

if (supportedTypes.length !== 1) {
const msg = `Expected one supported type, but got ${
supportedTypes.length
} instead`;
event.respondWith(Promise.reject(new Error(msg)));
return;
}

const supportedType = supportedTypes[0];
const expectedSupportedType = 'prepaid';
if (supportedType !== expectedSupportedType) {
const msg = `Expected supported type "${expectedSupportedType}", but got "${supportedType}"`;
event.respondWith(Promise.reject(new Error(msg)));
return;
}

if (methodData.displayItems) {
const msg = 'Expected no display items';
event.respondWith(Promise.reject(new Error(msg)));
Expand Down
7 changes: 0 additions & 7 deletions payment-handler/can-make-payment-event.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,12 @@
promise_test(async t => {
const methodName = 'basic-card';
await registerApp(methodName);
const cardType = 'prepaid';
const cardNetwork = 'mir';
const request = new PaymentRequest(
[
{
supportedMethods: methodName,
data: {
supportedTypes: [cardType],
supportedNetworks: [cardNetwork],
},
},
Expand Down Expand Up @@ -305,14 +303,12 @@

promise_test(async t => {
const methodName = 'basic-card';
const cardType = 'prepaid';
const cardNetwork = 'mir';
const registration = await registerApp(methodName);
await registration.paymentManager.instruments.set(instrumentKey, {
name: 'Test Payment Method',
method: methodName,
capabilities: {
supportedTypes: [cardType],
supportedNetworks: [cardNetwork],
},
});
Expand All @@ -321,7 +317,6 @@
{
supportedMethods: methodName,
data: {
supportedTypes: [cardType],
supportedNetworks: [cardNetwork],
},
},
Expand Down Expand Up @@ -355,14 +350,12 @@

promise_test(async t => {
const methodName = 'basic-card';
const cardType = 'prepaid';
const cardNetwork = 'mir';
const registration = await registerApp(methodName);
await registration.paymentManager.instruments.set(instrumentKey, {
name: 'Test Payment Method',
method: methodName,
capabilities: {
supportedTypes: [cardType],
supportedNetworks: [cardNetwork],
},
});
Expand Down
10 changes: 4 additions & 6 deletions payment-handler/payment-instruments.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
},
],
method: 'basic-card',
capabilities: {supportedNetworks: ['mir'], supportedTypes: ['prepaid']},
capabilities: {supportedNetworks: ['mir']},
},
);
const result = await registration.paymentManager.instruments.get(
Expand All @@ -104,7 +104,7 @@
{src: '/images/green-16x16.png', sizes: '16x16', type: 'image/png'},
],
method: 'basic-card',
capabilities: {supportedNetworks: ['mir'], supportedTypes: ['prepaid']},
capabilities: {supportedNetworks: ['mir']},
},
);
let result = await registration.paymentManager.instruments.get(
Expand All @@ -120,7 +120,6 @@
assert_equals(result.icons[0].type, 'image/png');
assert_equals(result.method, 'basic-card');
assert_array_equals(result.capabilities.supportedNetworks, ['mir']);
assert_array_equals(result.capabilities.supportedTypes, ['prepaid']);
await registration.paymentManager.instruments.set(
'existing-instrument-key',
{
Expand All @@ -133,7 +132,7 @@
},
],
method: 'basic-card',
capabilities: {supportedNetworks: ['visa'], supportedTypes: ['credit']},
capabilities: {supportedNetworks: ['visa']},
},
);
result = await registration.paymentManager.instruments.get(
Expand All @@ -149,7 +148,6 @@
assert_equals(result.icons[0].type, 'image/png');
assert_equals(result.method, 'basic-card');
assert_array_equals(result.capabilities.supportedNetworks, ['visa']);
assert_array_equals(result.capabilities.supportedTypes, ['credit']);
}, 'Resetting an existing instrument updates the instrument');

promise_test(async t => {
Expand All @@ -166,7 +164,7 @@
},
],
method: 'basic-card',
capabilities: {supportedNetworks: ['mir'], supportedTypes: ['prepaid']},
capabilities: {supportedNetworks: ['mir']},
},
);
await registration.paymentManager.instruments.clear();
Expand Down
6 changes: 3 additions & 3 deletions payment-handler/payment-request-event.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{src: '/images/rgrg-256x256.png', sizes: '256x256', type: 'image/png'},
],
method: 'basic-card',
capabilities: {supportedNetworks: ['mir'], supportedTypes: ['prepaid']},
capabilities: {supportedNetworks: ['mir']},
});
runTests();
}
Expand All @@ -25,7 +25,7 @@
promise_test(async t => {
const response = await new PaymentRequest(
[
{supportedMethods: 'basic-card', data: {supportedTypes: ['prepaid']}},
{supportedMethods: 'basic-card', data: {}},
{supportedMethods: 'interledger', data: {supportedNetworks: ['mir']}},
],
{
Expand Down Expand Up @@ -60,7 +60,7 @@
},
{
supportedMethods: 'interledger',
data: {supportedTypes: ['prepaid']},
data: {},
total: {
label: 'Prepaid total',
amount: {currency: 'USD', value: '0.0097'},
Expand Down

0 comments on commit 5d4871b

Please sign in to comment.