lint: Correct linting errors in v3 tests

This commit is contained in:
Blade Barringer
2016-01-03 09:47:27 -06:00
parent 37916271e8
commit f80f41f764
26 changed files with 392 additions and 370 deletions

View File

@@ -6,12 +6,12 @@ describe('analyticsService', () => {
let amplitudeNock, gaNock;
beforeEach(() => {
amplitudeNock = nock( 'https://api.amplitude.com')
amplitudeNock = nock('https://api.amplitude.com')
.filteringPath(/httpapi.*/g, '')
.post('/')
.reply(200, {status: 'OK'});
gaNock = nock( 'http://www.google-analytics.com');
gaNock = nock('http://www.google-analytics.com');
});
describe('#track', () => {
@@ -23,14 +23,14 @@ describe('analyticsService', () => {
category: 'behavior',
uuid: 'unique-user-id',
resting: true,
cronCount: 5
cronCount: 5,
};
});
context('Amplitude', () => {
it('calls out to amplitude', () => {
return analyticsService.track(eventType, data)
.then((res) => {
.then(() => {
amplitudeNock.done();
});
});
@@ -42,7 +42,7 @@ describe('analyticsService', () => {
.filteringPath(/httpapi.*user_id.*no-user-id-was-provided.*/g, '');
return analyticsService.track(eventType, data)
.then((res) => {
.then(() => {
amplitudeNock.done();
});
});
@@ -52,7 +52,7 @@ describe('analyticsService', () => {
.filteringPath(/httpapi.*platform.*server.*/g, '');
return analyticsService.track(eventType, data)
.then((res) => {
.then(() => {
amplitudeNock.done();
});
});
@@ -62,79 +62,79 @@ describe('analyticsService', () => {
.filteringPath(/httpapi.*event_properties%22%3A%7B%22category%22%3A%22behavior%22%2C%22resting%22%3Atrue%2C%22cronCount%22%3A5%7D%2C%22.*/g, '');
return analyticsService.track(eventType, data)
.then((res) => {
.then(() => {
amplitudeNock.done();
});
});
it('sends english item name for gear if itemKey is provided', () => {
data.itemKey = 'headAccessory_special_foxEars'
data.itemKey = 'headAccessory_special_foxEars';
amplitudeNock
.filteringPath(/httpapi.*itemName.*Fox%20Ears.*/g, '');
return analyticsService.track(eventType, data)
.then((res) => {
.then(() => {
amplitudeNock.done();
});
});
it('sends english item name for egg if itemKey is provided', () => {
data.itemKey = 'Wolf'
data.itemKey = 'Wolf';
amplitudeNock
.filteringPath(/httpapi.*itemName.*Wolf%20Egg.*/g, '');
return analyticsService.track(eventType, data)
.then((res) => {
.then(() => {
amplitudeNock.done();
});
});
it('sends english item name for food if itemKey is provided', () => {
data.itemKey = 'Cake_Skeleton'
data.itemKey = 'Cake_Skeleton';
amplitudeNock
.filteringPath(/httpapi.*itemName.*Bare%20Bones%20Cake.*/g, '');
return analyticsService.track(eventType, data)
.then((res) => {
.then(() => {
amplitudeNock.done();
});
});
it('sends english item name for hatching potion if itemKey is provided', () => {
data.itemKey = 'Golden'
data.itemKey = 'Golden';
amplitudeNock
.filteringPath(/httpapi.*itemName.*Golden%20Hatching%20Potion.*/g, '');
return analyticsService.track(eventType, data)
.then((res) => {
.then(() => {
amplitudeNock.done();
});
});
it('sends english item name for quest if itemKey is provided', () => {
data.itemKey = 'atom1'
data.itemKey = 'atom1';
amplitudeNock
.filteringPath(/httpapi.*itemName.*Attack%20of%20the%20Mundane%2C%20Part%201%3A%20Dish%20Disaster!.*/g, '');
return analyticsService.track(eventType, data)
.then((res) => {
.then(() => {
amplitudeNock.done();
});
});
it('sends english item name for purchased spell if itemKey is provided', () => {
data.itemKey = 'seafoam'
data.itemKey = 'seafoam';
amplitudeNock
.filteringPath(/httpapi.*itemName.*Seafoam.*/g, '');
return analyticsService.track(eventType, data)
.then((res) => {
.then(() => {
amplitudeNock.done();
});
});
@@ -142,14 +142,14 @@ describe('analyticsService', () => {
it('sends user data if provided', () => {
let stats = { class: 'wizard', exp: 5, gp: 23, hp: 10, lvl: 4, mp: 30 };
let user = {
stats: stats,
stats,
contributor: { level: 1 },
purchased: { plan: { planId: 'foo-plan' } },
flags: {tour: {intro: -2}},
habits: [{_id: 'habit'}],
dailys: [{_id: 'daily'}],
todos: [{_id: 'todo'}],
rewards: [{_id: 'reward'}]
rewards: [{_id: 'reward'}],
};
data.user = user;
@@ -158,7 +158,7 @@ describe('analyticsService', () => {
.filteringPath(/httpapi.*user_properties%22%3A%7B%22Class%22%3A%22wizard%22%2C%22Experience%22%3A5%2C%22Gold%22%3A23%2C%22Health%22%3A10%2C%22Level%22%3A4%2C%22Mana%22%3A30%2C%22tutorialComplete%22%3Atrue%2C%22Number%20Of%20Tasks%22%3A%7B%22habits%22%3A1%2C%22dailys%22%3A1%2C%22todos%22%3A1%2C%22rewards%22%3A1%7D%2C%22contributorLevel%22%3A1%2C%22subscription%22%3A%22foo-plan%22%7D%2C%22.*/g, '');
return analyticsService.track(eventType, data)
.then((res) => {
.then(() => {
amplitudeNock.done();
});
});
@@ -171,7 +171,7 @@ describe('analyticsService', () => {
.reply(200, {status: 'OK'});
return analyticsService.track(eventType, data)
.then((res) => {
.then(() => {
gaNock.done();
});
});
@@ -182,7 +182,7 @@ describe('analyticsService', () => {
.reply(200, {status: 'OK'});
return analyticsService.track(eventType, data)
.then((res) => {
.then(() => {
gaNock.done();
});
});
@@ -201,14 +201,14 @@ describe('analyticsService', () => {
purchaseValue: 8,
purchaseType: 'checkout',
gift: false,
quantity: 1
quantity: 1,
};
});
context('Amplitude', () => {
it('calls out to amplitude', () => {
return analyticsService.trackPurchase(data)
.then((res) => {
.then(() => {
amplitudeNock.done();
});
});
@@ -220,7 +220,7 @@ describe('analyticsService', () => {
.filteringPath(/httpapi.*user_id.*no-user-id-was-provided.*/g, '');
return analyticsService.trackPurchase(data)
.then((res) => {
.then(() => {
amplitudeNock.done();
});
});
@@ -230,7 +230,7 @@ describe('analyticsService', () => {
.filteringPath(/httpapi.*platform.*server.*/g, '');
return analyticsService.trackPurchase(data)
.then((res) => {
.then(() => {
amplitudeNock.done();
});
});
@@ -240,7 +240,7 @@ describe('analyticsService', () => {
.filteringPath(/httpapi.*aypal-checkout%22%2C%22paymentMethod%22%3A%22PayPal%22%2C%22itemPurchased%22%3A%22Gems%22%2C%22purchaseType%22%3A%22checkout%22%2C%22gift%22%3Afalse%2C%22quantity%22%3A1%7D%2C%22event_type%22%3A%22purchase%22%2C%22revenue.*/g, '');
return analyticsService.trackPurchase(data)
.then((res) => {
.then(() => {
amplitudeNock.done();
});
});
@@ -248,14 +248,14 @@ describe('analyticsService', () => {
it('sends user data if provided', () => {
let stats = { class: 'wizard', exp: 5, gp: 23, hp: 10, lvl: 4, mp: 30 };
let user = {
stats: stats,
stats,
contributor: { level: 1 },
purchased: { plan: { planId: 'foo-plan' } },
flags: {tour: {intro: -2}},
habits: [{_id: 'habit'}],
dailys: [{_id: 'daily'}],
todos: [{_id: 'todo'}],
rewards: [{_id: 'reward'}]
rewards: [{_id: 'reward'}],
};
data.user = user;
@@ -264,7 +264,7 @@ describe('analyticsService', () => {
.filteringPath(/httpapi.*user_properties%22%3A%7B%22Class%22%3A%22wizard%22%2C%22Experience%22%3A5%2C%22Gold%22%3A23%2C%22Health%22%3A10%2C%22Level%22%3A4%2C%22Mana%22%3A30%2C%22tutorialComplete%22%3Atrue%2C%22Number%20Of%20Tasks%22%3A%7B%22habits%22%3A1%2C%22dailys%22%3A1%2C%22todos%22%3A1%2C%22rewards%22%3A1%7D%2C%22contributorLevel%22%3A1%2C%22subscription%22%3A%22foo-plan%22%7D%2C%22.*/g, '');
return analyticsService.trackPurchase(data)
.then((res) => {
.then(() => {
amplitudeNock.done();
});
});
@@ -277,7 +277,7 @@ describe('analyticsService', () => {
.reply(200, {status: 'OK'});
return analyticsService.trackPurchase(data)
.then((res) => {
.then(() => {
gaNock.done();
});
});
@@ -290,7 +290,7 @@ describe('analyticsService', () => {
.reply(200, {status: 'OK'});
return analyticsService.trackPurchase(data)
.then((res) => {
.then(() => {
gaNock.done();
});
});

View File

@@ -32,7 +32,7 @@ describe('Base model plugin', () => {
it('can sanitize input objects', () => {
baseModel(schema, {
noSet: ['noUpdateForMe']
noSet: ['noUpdateForMe'],
});
expect(schema.statics.sanitize).to.exist;
@@ -45,7 +45,7 @@ describe('Base model plugin', () => {
it('accepts an array of additional fields to sanitize at runtime', () => {
baseModel(schema, {
noSet: ['noUpdateForMe']
noSet: ['noUpdateForMe'],
});
expect(schema.statics.sanitize).to.exist;
@@ -59,7 +59,7 @@ describe('Base model plugin', () => {
it('can make fields private', () => {
baseModel(schema, {
private: ['amPrivate']
private: ['amPrivate'],
});
expect(schema.options.toJSON.transform).to.exist;
@@ -73,7 +73,7 @@ describe('Base model plugin', () => {
it('accepts a further transform function for toJSON', () => {
let options = {
private: ['amPrivate'],
toJSONTransform: sandbox.stub().returns(true)
toJSONTransform: sandbox.stub().returns(true),
};
baseModel(schema, options);
@@ -88,7 +88,7 @@ describe('Base model plugin', () => {
it('accepts a transform function for sanitize', () => {
let options = {
private: ['amPrivate'],
sanitizeTransform: sandbox.stub().returns(true)
sanitizeTransform: sandbox.stub().returns(true),
};
baseModel(schema, options);

View File

@@ -11,8 +11,9 @@ describe('Build Manifest', () => {
});
it('throws an error in case the page does not exist', () => {
let getManifestFilesFn = () => { getManifestFiles('strange name here') };
expect(getManifestFilesFn).to.throw(Error);
expect(() => {
getManifestFiles('strange name here');
}).to.throw(Error);
});
});
});

View File

@@ -1,3 +1,4 @@
/* eslint-disable global-require */
import request from 'request';
import nconf from 'nconf';
import nodemailer from 'nodemailer';
@@ -14,21 +15,21 @@ function getUser () {
},
facebook: {
emails: [{
value: 'email@facebook'
value: 'email@facebook',
}],
displayName: 'fb display name',
}
},
},
profile: {
name: 'profile name',
},
preferences: {
emailNotifications: {
unsubscribeFromAll: false
unsubscribeFromAll: false,
},
},
};
};
}
describe('emails', () => {
let pathToEmailLib = '../../../../../website/src/libs/api-v3/email';
@@ -63,7 +64,7 @@ describe('emails', () => {
attachEmail.send();
expect(sendMailSpy).to.be.calledOnce;
deferred.reject();
deferred.promise.catch((err) => {
deferred.promise.catch(() => {
expect(logger.error).to.be.calledOnce;
done();
});
@@ -93,11 +94,11 @@ describe('emails', () => {
let attachEmail = require(pathToEmailLib);
let getUserInfo = attachEmail.getUserInfo;
let user = getUser();
delete user.profile['name'];
delete user.auth['local'];
delete user.profile.name;
delete user.auth.local;
let data = getUserInfo(user, ['name', 'email', '_id', 'canSend']);
expect(data).to.have.property('name', user.auth.facebook.displayName);
expect(data).to.have.property('email', user.auth.facebook.emails[0].value);
expect(data).to.have.property('_id', user._id);
@@ -108,12 +109,12 @@ describe('emails', () => {
let attachEmail = require(pathToEmailLib);
let getUserInfo = attachEmail.getUserInfo;
let user = getUser();
delete user.profile['name'];
delete user.auth.local['email']
delete user.auth['facebook'];
delete user.profile.name;
delete user.auth.local.email;
delete user.auth.facebook;
let data = getUserInfo(user, ['name', 'email', '_id', 'canSend']);
expect(data).to.have.property('name', user.auth.local.username);
expect(data).not.to.have.property('email');
expect(data).to.have.property('_id', user._id);
@@ -148,8 +149,8 @@ describe('emails', () => {
to: sinon.match((value) => {
return Array.isArray(value) && value[0].name === mailingInfo.name;
}, 'matches mailing info array'),
}
}
},
},
}));
});
@@ -160,7 +161,7 @@ describe('emails', () => {
let emailType = 'an email type';
let mailingInfo = {
name: 'my name',
//email: 'my@email',
// email: 'my@email',
};
sendTxnEmail(mailingInfo, emailType);
@@ -180,8 +181,8 @@ describe('emails', () => {
data: {
emailType: sinon.match.same(emailType),
to: sinon.match(val => val[0]._id === mailingInfo._id),
}
}
},
},
}));
});
@@ -194,7 +195,7 @@ describe('emails', () => {
name: 'my name',
email: 'my@email',
};
let variables = [1,2,3];
let variables = [1, 2, 3];
sendTxnEmail(mailingInfo, emailType, variables);
expect(request.post).to.be.calledWith(sinon.match({
@@ -204,13 +205,12 @@ describe('emails', () => {
return value[0].name === 'BASE_URL';
}, 'matches variables'),
personalVariables: sinon.match((value) => {
return (value[0].rcpt === mailingInfo.email
&& value[0].vars[0].name === 'RECIPIENT_NAME'
&& value[0].vars[1].name === 'RECIPIENT_UNSUB_URL'
);
return value[0].rcpt === mailingInfo.email &&
value[0].vars[0].name === 'RECIPIENT_NAME' &&
value[0].vars[1].name === 'RECIPIENT_UNSUB_URL';
}, 'matches personal variables'),
}
}
},
},
}));
});
});

View File

@@ -1,4 +1,4 @@
import {
import {
encrypt,
decrypt,
} from '../../../../../website/src/libs/api-v3/encryption';

View File

@@ -34,7 +34,7 @@ describe('i18n', () => {
describe('localePath', () => {
it('is an absolute path to common/locales/', () => {
expect(localePath).to.match(/.*\/common\/locales\//);
expect(localePath)
expect(localePath);
});
});

View File

@@ -2,7 +2,6 @@ import request from 'request';
import { sendTaskWebhook } from '../../../../../website/src/libs/api-v3/webhook';
describe('webhooks', () => {
beforeEach(() => {
sandbox.stub(request, 'post');
});
@@ -15,12 +14,12 @@ describe('webhooks', () => {
let task = {
details: { _id: 'task-id' },
delta: 1.4,
direction: 'up'
direction: 'up',
};
let data = {
task: task,
user: { _id: 'user-id' }
task,
user: { _id: 'user-id' },
};
it('does not send if no webhook endpoints exist', () => {
@@ -37,8 +36,8 @@ describe('webhooks', () => {
sort: 0,
id: 'some-id',
enabled: false,
url: 'http://example.org/endpoint'
}
url: 'http://example.org/endpoint',
},
};
sendTaskWebhook(webhooks, data);
@@ -52,8 +51,8 @@ describe('webhooks', () => {
sort: 0,
id: 'some-id',
enabled: true,
url: 'http://malformedurl/endpoint'
}
url: 'http://malformedurl/endpoint',
},
};
sendTaskWebhook(webhooks, data);
@@ -67,8 +66,8 @@ describe('webhooks', () => {
sort: 0,
id: 'some-id',
enabled: true,
url: 'http://example.org/endpoint'
}
url: 'http://example.org/endpoint',
},
};
sendTaskWebhook(webhooks, data);
@@ -81,10 +80,10 @@ describe('webhooks', () => {
task: { _id: 'task-id' },
delta: 1.4,
user: {
_id: 'user-id'
}
_id: 'user-id',
},
},
json: true
json: true,
});
});
@@ -94,14 +93,14 @@ describe('webhooks', () => {
sort: 0,
id: 'some-id',
enabled: true,
url: 'http://example.org/endpoint'
url: 'http://example.org/endpoint',
},
'second-webhook': {
sort: 1,
id: 'second-webhook',
enabled: true,
url: 'http://example.com/2/endpoint'
}
url: 'http://example.com/2/endpoint',
},
};
sendTaskWebhook(webhooks, data);
@@ -114,10 +113,10 @@ describe('webhooks', () => {
task: { _id: 'task-id' },
delta: 1.4,
user: {
_id: 'user-id'
}
_id: 'user-id',
},
},
json: true
json: true,
});
expect(request.post).to.be.calledWith({
url: 'http://example.com/2/endpoint',
@@ -126,10 +125,10 @@ describe('webhooks', () => {
task: { _id: 'task-id' },
delta: 1.4,
user: {
_id: 'user-id'
}
_id: 'user-id',
},
},
json: true
json: true,
});
});
});