Skip to content

Commit

Permalink
migrated config files to their own directories
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Walsh committed Mar 8, 2017
1 parent 1b0a79d commit 560950b
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 113 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -8,3 +8,4 @@
.DS_Store
.vscode
testing_config.json
sample_app/config/config.json
15 changes: 15 additions & 0 deletions sample_app/config/example_config.json
@@ -0,0 +1,15 @@
{
"APPTYPE": "PARTNER",
"partner": {
"authorizeCallbackUrl": "https://example.com/xerocallback",
"consumerKey": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"privateKeyPath": "/some/path/to/privatekey.pem",
"userAgent": "Tester (PARTNER) - Application for testing Xero"
},
"public": {
"authorizeCallbackUrl": "https://example.com/xerocallback",
"consumerKey": "AAAAAAAAAAAAAAAAAA",
"consumerSecret": "BBBBBBBBBBBBBBBBBBBB",
"userAgent": "Tester (PUBLIC) - Application for testing Xero"
}
}
2 changes: 1 addition & 1 deletion sample_app/sample_app.js
Expand Up @@ -4,7 +4,7 @@ var express = require('express'),
LRU = require('lru-cache'),
fs = require('fs'),
nodemailer = require('nodemailer'),
metaConfig = require('../testing_config.json');
metaConfig = require('./config/config.json');

function getXeroApp(session) {
var APPTYPE = metaConfig.APPTYPE;
Expand Down
220 changes: 110 additions & 110 deletions test/accountingtests.js
Expand Up @@ -7,7 +7,7 @@ var chai = require('chai'),
Browser = require('zombie'),
uuid = require('uuid'),
fs = require('fs'),
metaConfig = require('../testing_config.json');
metaConfig = require('./config/testing_config.json');

process.on('uncaughtException', function(err) {
console.log('uncaught', err)
Expand Down Expand Up @@ -97,8 +97,8 @@ describe('get access for public or partner application', function() {

describe('submits form', function() {
var options = {
XeroUsername: config.xeroUsername,
XeroPassword: config.xeroPassword
XeroUsername: config.xeroUsername,
XeroPassword: config.xeroPassword
};

it('should login', function(done) {
Expand Down Expand Up @@ -182,47 +182,47 @@ describe('regression tests', function() {
var bankAccounts = [];

before('create a bank account', function() {
const randomString = uuid.v4();

var testAccountData = {
Code: randomString.replace(/-/g,'').substring(0, 10),
Name: 'Test account from Node SDK ' + randomString,
Type: 'BANK',
BankAccountNumber: '062-021-0000000',
};

var account = currentApp.core.accounts.newAccount(testAccountData);

return account.save()
.then(function(response) {
var account = response.entities[0];
bankAccounts.push({
account: account,
id: account.AccountID
});
});
const randomString = uuid.v4();

var testAccountData = {
Code: randomString.replace(/-/g, '').substring(0, 10),
Name: 'Test account from Node SDK ' + randomString,
Type: 'BANK',
BankAccountNumber: '062-021-0000000',
};

var account = currentApp.core.accounts.newAccount(testAccountData);

return account.save()
.then(function(response) {
var account = response.entities[0];
bankAccounts.push({
account: account,
id: account.AccountID
});
});
});

before('create another bank account', function() {
const randomString = uuid.v4();

var testAccountData = {
Code: randomString.replace(/-/g,'').substring(0, 10),
Name: 'Test account from Node SDK ' + randomString,
Type: 'BANK',
BankAccountNumber: '062-021-0000000',
};

var account = currentApp.core.accounts.newAccount(testAccountData);

return account.save()
.then(function(response) {
var account = response.entities[0];
bankAccounts.push({
account: account,
id: account.AccountID
});
});
const randomString = uuid.v4();

var testAccountData = {
Code: randomString.replace(/-/g, '').substring(0, 10),
Name: 'Test account from Node SDK ' + randomString,
Type: 'BANK',
BankAccountNumber: '062-021-0000000',
};

var account = currentApp.core.accounts.newAccount(testAccountData);

return account.save()
.then(function(response) {
var account = response.entities[0];
bankAccounts.push({
account: account,
id: account.AccountID
});
});
});

// There appears to be no way to archive a bank account via the API
Expand Down Expand Up @@ -387,7 +387,7 @@ describe('regression tests', function() {

var testAccountId = "";
var testAccountData = {
Code: randomString.replace(/-/g,'').substring(0, 10),
Code: randomString.replace(/-/g, '').substring(0, 10),
Name: 'Test account from Node SDK ' + randomString,
Type: 'EXPENSE'
};
Expand Down Expand Up @@ -586,25 +586,25 @@ describe('regression tests', function() {
var testAccount;

before('create an account to pay into', function() {
const randomString = uuid.v4();
const randomString = uuid.v4();

var testAccountData = {
Code: randomString.replace(/-/g,'').substring(0, 10),
Name: 'Test account from Node SDK ' + randomString,
Type: 'SALES',
EnablePaymentsToAccount: true
};
var testAccountData = {
Code: randomString.replace(/-/g, '').substring(0, 10),
Name: 'Test account from Node SDK ' + randomString,
Type: 'SALES',
EnablePaymentsToAccount: true
};

testAccountCode = testAccountData.Code;
testAccountCode = testAccountData.Code;

var account = currentApp.core.accounts.newAccount(testAccountData);
var account = currentApp.core.accounts.newAccount(testAccountData);

return account.save()
.then(function(response) {
var account = response.entities[0];
testAccountId = account.AccountID;
testAccount = account;
});
return account.save()
.then(function(response) {
var account = response.entities[0];
testAccountId = account.AccountID;
testAccount = account;
});
});

after('archive the test account', function() {
Expand Down Expand Up @@ -922,60 +922,60 @@ describe('regression tests', function() {
var trackingCategoryID;

return trackingCategory.save()
.then(function(response) {
trackingCategoryName = response.entities[0].Name;
trackingCategoryID = response.entities[0].TrackingCategoryID;
return response.entities[0].saveTrackingOptions([
{ Name: "North" },
{ Name: "South" },
])
})
.then(function(response) {
//Create an invoice with the sample tracking category attached to the line item on the invoice.
var invoice = currentApp.core.invoices.newInvoice({
Type: 'ACCREC',
Contact: {
Name: 'Department of Testing'
},
DueDate: new Date().toISOString().split("T")[0],
LineItems: [{
Description: 'Services',
Quantity: 2,
UnitAmount: 230,
AccountCode: '400',
Tracking: [{
TrackingCategory: {
Name: trackingCategoryName,
Option: 'North'
}
.then(function(response) {
trackingCategoryName = response.entities[0].Name;
trackingCategoryID = response.entities[0].TrackingCategoryID;
return response.entities[0].saveTrackingOptions([
{ Name: "North" },
{ Name: "South" },
])
})
.then(function(response) {
//Create an invoice with the sample tracking category attached to the line item on the invoice.
var invoice = currentApp.core.invoices.newInvoice({
Type: 'ACCREC',
Contact: {
Name: 'Department of Testing'
},
DueDate: new Date().toISOString().split("T")[0],
LineItems: [{
Description: 'Services',
Quantity: 2,
UnitAmount: 230,
AccountCode: '400',
Tracking: [{
TrackingCategory: {
Name: trackingCategoryName,
Option: 'North'
}
}]
}]
}]
});
return invoice.save()
.then(function(response) {

expect(response.entities).to.have.length.greaterThan(0);
expect(response.entities[0].InvoiceID).to.not.equal(undefined);
expect(response.entities[0].InvoiceID).to.not.equal("");

response.entities[0].LineItems.forEach(function(lineItem) {
//expect(lineItem.Tracking).to.have.length.greaterThan(0);
_.each(lineItem.Tracking, function(trackingCategory) {
expect(trackingCategory.TrackingCategoryID).to.not.equal(undefined);
expect(trackingCategory.TrackingCategoryID).to.not.equal("");
expect(trackingCategory.TrackingOptionID).to.not.equal(undefined);
expect(trackingCategory.TrackingOptionID).to.not.equal("");
expect(trackingCategory.Name).to.equal(trackingCategory.Name);
expect(trackingCategory.Option).to.equal('North');
});
return invoice.save()
.then(function(response) {

expect(response.entities).to.have.length.greaterThan(0);
expect(response.entities[0].InvoiceID).to.not.equal(undefined);
expect(response.entities[0].InvoiceID).to.not.equal("");

response.entities[0].LineItems.forEach(function(lineItem) {
//expect(lineItem.Tracking).to.have.length.greaterThan(0);
_.each(lineItem.Tracking, function(trackingCategory) {
expect(trackingCategory.TrackingCategoryID).to.not.equal(undefined);
expect(trackingCategory.TrackingCategoryID).to.not.equal("");
expect(trackingCategory.TrackingOptionID).to.not.equal(undefined);
expect(trackingCategory.TrackingOptionID).to.not.equal("");
expect(trackingCategory.Name).to.equal(trackingCategory.Name);
expect(trackingCategory.Option).to.equal('North');
});
});
});
return currentApp.core.trackingCategories.deleteTrackingCategory(trackingCategoryID)
})
.catch(function(err) {
console.log(util.inspect(err, null, null));
done(wrapError(err));
})
});
return currentApp.core.trackingCategories.deleteTrackingCategory(trackingCategoryID)
})
.catch(function(err) {
console.log(util.inspect(err, null, null));
done(wrapError(err));
})
});
});

//unfortunately this will only work on tracking categories that have been used.
Expand Down Expand Up @@ -1428,4 +1428,4 @@ function wrapError(err) {
return err;
else if (err.statusCode)
return new Error(err.statusCode + ': ' + err.exception.Message);
}
}
Expand Up @@ -5,6 +5,7 @@
"consumerKey": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"privateKeyPath": "/some/path/to/privatekey.pem",
"userAgent": "Tester (PARTNER) - Application for testing Xero",
//Only used for test purposes, not required for general usage.
"xeroPassword": "XXXXXXXXXX",
"xeroUsername": "foo@example.com"
},
Expand All @@ -18,6 +19,9 @@
"authorizeCallbackUrl": "https://example.com/xerocallback",
"consumerKey": "AAAAAAAAAAAAAAAAAA",
"consumerSecret": "BBBBBBBBBBBBBBBBBBBB",
"userAgent": "Tester (PUBLIC) - Application for testing Xero"
"userAgent": "Tester (PUBLIC) - Application for testing Xero",
//Only used for test purposes, not required for general usage.
"xeroPassword": "XXXXXXXXXX",
"xeroUsername": "foo@example.com"
}
}
}

0 comments on commit 560950b

Please sign in to comment.