mirror of
https://github.com/google/nomulus.git
synced 2025-07-24 19:48:32 +02:00
Delete all Braintree code
We never launched this, don't planning on launching it now anyway, and it's rotted over the past two years anyway. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=202993577
This commit is contained in:
parent
7023b818b7
commit
32b3563126
67 changed files with 28 additions and 3352 deletions
|
@ -1,97 +0,0 @@
|
|||
// Copyright 2017 The Nomulus Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
goog.setTestOnly();
|
||||
|
||||
goog.require('goog.dispose');
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.style');
|
||||
goog.require('goog.testing.MockControl');
|
||||
goog.require('goog.testing.asserts');
|
||||
goog.require('goog.testing.jsunit');
|
||||
goog.require('registry.registrar.BrainFrame');
|
||||
goog.require('registry.testing');
|
||||
|
||||
|
||||
var mocks = new goog.testing.MockControl();
|
||||
|
||||
var brainframe;
|
||||
var mockPostMessage;
|
||||
|
||||
|
||||
function setUp() {
|
||||
registry.testing.addToDocument('<form><div id="bf"></div></form>');
|
||||
brainframe = new registry.registrar.BrainFrame('omg', 'bf');
|
||||
mockPostMessage =
|
||||
mocks.createMethodMock(registry.registrar.BrainFrame, 'postMessage_');
|
||||
}
|
||||
|
||||
|
||||
function tearDown() {
|
||||
goog.dispose(brainframe);
|
||||
mocks.$tearDown();
|
||||
}
|
||||
|
||||
|
||||
function testRun_sendsTokenRequestToParent() {
|
||||
mockPostMessage('{"type":"token_request"}', 'omg');
|
||||
mocks.$replayAll();
|
||||
brainframe.run();
|
||||
mocks.$verifyAll();
|
||||
}
|
||||
|
||||
|
||||
function testTokenResponseMessage_callsSetup() {
|
||||
var called = false;
|
||||
goog.global.braintree = {};
|
||||
goog.global.braintree.setup = function(token, mode, args) {
|
||||
called = true;
|
||||
assertEquals('imatoken', token);
|
||||
assertEquals('dropin', mode);
|
||||
assertEquals('bf', args.container.id);
|
||||
};
|
||||
brainframe.onMessage_({
|
||||
getBrowserEvent: function() {
|
||||
return {
|
||||
source: window.parent,
|
||||
origin: 'omg',
|
||||
data: '{"type": "token_response", "token": "imatoken"}'
|
||||
};
|
||||
}
|
||||
});
|
||||
assertTrue(called);
|
||||
}
|
||||
|
||||
|
||||
function testPaymentMethodMessage_sendsInfo() {
|
||||
mockPostMessage('{"type":"payment_method","submit":false,"method":"hi"}',
|
||||
'omg');
|
||||
mocks.$replayAll();
|
||||
brainframe.onPaymentMethod_('hi');
|
||||
mocks.$verifyAll();
|
||||
}
|
||||
|
||||
|
||||
function testOnResizeTimer_sendsHeight() {
|
||||
mockPostMessage('{"type":"resize_request","height":123}', 'omg');
|
||||
mocks.$replayAll();
|
||||
goog.style.setHeight(goog.dom.getElement('bf'), 123);
|
||||
brainframe.onResizeTimer_();
|
||||
mocks.$verifyAll();
|
||||
|
||||
// But does not send height if size hasn't changed.
|
||||
mocks.$replayAll();
|
||||
brainframe.onResizeTimer_();
|
||||
mocks.$verifyAll();
|
||||
}
|
|
@ -51,7 +51,6 @@ function setUp() {
|
|||
logoutUrl: 'omg',
|
||||
isAdmin: true,
|
||||
clientId: test.testClientId,
|
||||
showPaymentLink: false,
|
||||
logoFilename: 'logo.png',
|
||||
productName: 'Nomulus',
|
||||
integrationEmail: 'integration@example.com',
|
||||
|
|
|
@ -50,7 +50,6 @@ function setUp() {
|
|||
logoutUrl: 'omg',
|
||||
isAdmin: true,
|
||||
clientId: test.testClientId,
|
||||
showPaymentLink: false,
|
||||
logoFilename: 'logo.png',
|
||||
productName: 'Nomulus',
|
||||
integrationEmail: 'integration@google.com',
|
||||
|
|
|
@ -41,7 +41,6 @@ function setUp() {
|
|||
logoutUrl: 'omg',
|
||||
isAdmin: true,
|
||||
clientId: 'daddy',
|
||||
showPaymentLink: false,
|
||||
logoFilename: 'logo.png',
|
||||
productName: 'Nomulus',
|
||||
integrationEmail: 'integration@example.com',
|
||||
|
|
|
@ -47,7 +47,6 @@ function setUp() {
|
|||
logoutUrl: 'https://justinetunney.com',
|
||||
isAdmin: true,
|
||||
clientId: 'ignore',
|
||||
showPaymentLink: false,
|
||||
logoFilename: 'logo.png',
|
||||
productName: 'Nomulus',
|
||||
integrationEmail: 'integration@example.com',
|
||||
|
|
|
@ -47,7 +47,6 @@ function setUp() {
|
|||
logoutUrl: 'https://example.com',
|
||||
isAdmin: true,
|
||||
clientId: 'ignore',
|
||||
showPaymentLink: false,
|
||||
logoFilename: 'logo.png',
|
||||
productName: 'Nomulus',
|
||||
integrationEmail: 'integration@example.com',
|
||||
|
|
|
@ -1,208 +0,0 @@
|
|||
// Copyright 2017 The Nomulus Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
goog.setTestOnly();
|
||||
|
||||
goog.require('goog.dispose');
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.dom.classlist');
|
||||
goog.require('goog.events.EventType');
|
||||
goog.require('goog.json');
|
||||
goog.require('goog.testing.PropertyReplacer');
|
||||
goog.require('goog.testing.asserts');
|
||||
goog.require('goog.testing.events');
|
||||
goog.require('goog.testing.events.Event');
|
||||
goog.require('goog.testing.jsunit');
|
||||
goog.require('goog.testing.net.XhrIo');
|
||||
goog.require('registry.registrar.Payment');
|
||||
goog.require('registry.testing');
|
||||
|
||||
|
||||
var $ = goog.dom.getRequiredElement;
|
||||
var $$ = goog.dom.getRequiredElementByClass;
|
||||
var stubs = new goog.testing.PropertyReplacer();
|
||||
|
||||
var page;
|
||||
|
||||
|
||||
function setUp() {
|
||||
registry.testing.addToDocument('<div id="reg-content"></div>');
|
||||
registry.testing.addToDocument('<div class="kd-butterbar"></div>');
|
||||
registry.testing.addToDocument('<div class="kd-butterbar-text"></div>');
|
||||
stubs.setPath('goog.net.XhrIo', goog.testing.net.XhrIo);
|
||||
page = new registry.registrar.Payment(null, '?');
|
||||
page.bindToDom();
|
||||
}
|
||||
|
||||
|
||||
function tearDown() {
|
||||
goog.dispose(page);
|
||||
stubs.reset();
|
||||
goog.testing.net.XhrIo.cleanup();
|
||||
}
|
||||
|
||||
|
||||
function testRenderForm() {
|
||||
registry.testing.assertReqMockRsp(
|
||||
'?',
|
||||
'/registrar-payment-setup',
|
||||
{},
|
||||
{
|
||||
status: 'SUCCESS',
|
||||
results: [
|
||||
{
|
||||
token: 'omg-im-a-token',
|
||||
currencies: ['LOL', 'OMG'],
|
||||
brainframe: ''
|
||||
}
|
||||
]
|
||||
});
|
||||
assertEquals('', $('amount').value);
|
||||
assertEquals('LOL', goog.dom.getTextContent($$('selected', $('currency'))));
|
||||
assertTrue(
|
||||
goog.dom.classlist.contains($$('reg-payment-form-submit'), 'disabled'));
|
||||
}
|
||||
|
||||
|
||||
function testResize() {
|
||||
testRenderForm();
|
||||
send({
|
||||
type: 'resize_request',
|
||||
height: 123
|
||||
});
|
||||
assertEquals('123', $$('reg-payment-form-method').height);
|
||||
}
|
||||
|
||||
|
||||
function testReady() {
|
||||
testRenderForm();
|
||||
send({type: 'ready'});
|
||||
assertFalse(
|
||||
goog.dom.classlist.contains($$('reg-payment-form-submit'), 'disabled'));
|
||||
}
|
||||
|
||||
|
||||
function testPaymentMethodCard() {
|
||||
testRenderForm();
|
||||
send({
|
||||
type: 'payment_method',
|
||||
method: {
|
||||
type: 'CreditCard',
|
||||
nonce: 'omg-im-a-nonce',
|
||||
details: {
|
||||
cardType: 'Amex',
|
||||
lastTwo: '12'
|
||||
}
|
||||
}
|
||||
});
|
||||
assertEquals(
|
||||
'American Express: xxxx xxxxxx xxx12',
|
||||
goog.dom.getTextContent($$('reg-payment-form-method-info')));
|
||||
}
|
||||
|
||||
|
||||
function testPaymentMethodPaypal() {
|
||||
testRenderForm();
|
||||
send({
|
||||
type: 'payment_method',
|
||||
method: {
|
||||
type: 'PayPalAccount',
|
||||
nonce: 'omg-im-a-nonce',
|
||||
details: {
|
||||
email: 'sparrows@nightingales.example'
|
||||
}
|
||||
}
|
||||
});
|
||||
assertEquals(
|
||||
'PayPal: sparrows@nightingales.example',
|
||||
goog.dom.getTextContent($$('reg-payment-form-method-info')));
|
||||
}
|
||||
|
||||
|
||||
function testBadAmount_displaysError() {
|
||||
testPaymentMethodCard();
|
||||
$('amount').value = '3.14';
|
||||
submit();
|
||||
registry.testing.assertReqMockRsp(
|
||||
'?',
|
||||
'/registrar-payment',
|
||||
{
|
||||
amount: '3.14',
|
||||
currency: 'LOL',
|
||||
paymentMethodNonce: 'omg-im-a-nonce'
|
||||
},
|
||||
{
|
||||
status: 'ERROR',
|
||||
message: 'gimmeh moar money',
|
||||
field: 'amount'
|
||||
});
|
||||
assertTrue(goog.dom.classlist.contains($('amount'), 'kd-formerror'));
|
||||
assertEquals('gimmeh moar money',
|
||||
goog.dom.getTextContent($$('kd-errormessage')));
|
||||
}
|
||||
|
||||
|
||||
function testGoodPayment_displaysSuccessPage() {
|
||||
testPaymentMethodCard();
|
||||
$('amount').value = '314';
|
||||
submit();
|
||||
registry.testing.assertReqMockRsp(
|
||||
'?',
|
||||
'/registrar-payment',
|
||||
{
|
||||
amount: '314',
|
||||
currency: 'LOL',
|
||||
paymentMethodNonce: 'omg-im-a-nonce'
|
||||
},
|
||||
{
|
||||
status: 'SUCCESS',
|
||||
results: [
|
||||
{
|
||||
id: 'omg-im-an-id',
|
||||
formattedAmount: '$314'
|
||||
}
|
||||
]
|
||||
});
|
||||
assertContains('Payment Processed',
|
||||
goog.dom.getTextContent($$('reg-payment')));
|
||||
assertContains('omg-im-an-id',
|
||||
goog.dom.getTextContent($$('reg-payment')));
|
||||
assertContains('$314',
|
||||
goog.dom.getTextContent($$('reg-payment')));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sends message to page.
|
||||
* @param {string} message
|
||||
*/
|
||||
function send(message) {
|
||||
page.onMessage_({
|
||||
getBrowserEvent: function() {
|
||||
return {
|
||||
source: goog.dom.getFrameContentWindow($$('reg-payment-form-method')),
|
||||
data: goog.json.serialize(message)
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/** Submits payment form. */
|
||||
function submit() {
|
||||
goog.testing.events.fireBrowserEvent(
|
||||
new goog.testing.events.Event(
|
||||
goog.events.EventType.SUBMIT,
|
||||
$$('reg-payment-form')));
|
||||
}
|
|
@ -55,7 +55,6 @@ function setUp() {
|
|||
isAdmin: true,
|
||||
xsrfToken: test.testXsrfToken,
|
||||
clientId: test.testClientId,
|
||||
showPaymentLink: false,
|
||||
logoFilename: 'logo.png',
|
||||
productName: 'Nomulus',
|
||||
integrationEmail: 'integration@example.com',
|
||||
|
|
|
@ -49,7 +49,6 @@ function setUp() {
|
|||
logoutUrl: 'omg',
|
||||
isAdmin: true,
|
||||
clientId: test.testClientId,
|
||||
showPaymentLink: false,
|
||||
logoFilename: 'logo.png',
|
||||
productName: 'Nomulus',
|
||||
integrationEmail: 'integration@example.com',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue