Skip to content

Commit

Permalink
Fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikprijck committed Aug 31, 2023
1 parent 4e37522 commit 437b580
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 30 deletions.
4 changes: 2 additions & 2 deletions test/context/context.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'path';
import { AuthApiError } from 'auth0';
import fs from 'fs-extra';
import chai, { expect } from 'chai';
import sinon from 'sinon';
Expand All @@ -10,7 +11,6 @@ import { setupContext, filterOnlyIncludedResourceTypes } from '../../src/context
import directoryContext from '../../src/context/directory';
import yamlContext from '../../src/context/yaml';
import { cleanThenMkdir, testDataDir, createDir } from '../utils';
import {AuthApiError} from "auth0";

chai.use(chaiAsPromised);
chai.use(sinonChai);
Expand All @@ -21,7 +21,7 @@ const config = {
AUTH0_ACCESS_TOKEN: 'fake',
};

export const TEST_PRIVATE_KEY = `-----BEGIN PRIVATE KEY-----
const TEST_PRIVATE_KEY = `-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDx+hc8imR4soBV
9WD9bRey14VqzZfCvEAYbSWctLeZz9xhz+kP+mWxHvv07wi3/ZiYcVYgOYIhxbnt
ugNp78oCFUEsdRrdq2juHlqBtjaYpINQSOqNaKUBt3JRkPPxRLyhwCZ6HJVYy5Wp
Expand Down
4 changes: 2 additions & 2 deletions test/tools/auth0/handlers/actions.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe('#actions handler', () => {
expect(data.name).to.equal('action-test');
expect(data.supported_triggers[0].id).to.equal('post-login');
expect(data.supported_triggers[0].version).to.equal('v1');
return Promise.resolve({ data: { ...data, id: actionId }});
return Promise.resolve({ data: { ...data, id: actionId } });
},
update: () => Promise.resolve({ data: [] }),
delete: () => Promise.resolve({ data: [] }),
Expand Down Expand Up @@ -259,7 +259,7 @@ describe('#actions handler', () => {

const auth0 = {
actions: {
getAll: () => mockPagedData({ include_totals: true}, 'actions', actionsData),
getAll: () => mockPagedData({ include_totals: true }, 'actions', actionsData),
},
};

Expand Down
2 changes: 1 addition & 1 deletion test/tools/auth0/handlers/clients.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe('#clients handler', () => {

return Promise.resolve({ data });
},
delete: () => Promise.resolve({ data: []}),
delete: () => Promise.resolve({ data: [] }),
getAll: (params) => mockPagedData(params, 'clients', [
{
client_id: 'client1',
Expand Down
2 changes: 1 addition & 1 deletion test/tools/auth0/handlers/guardianFactorTemplates.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('#guardianFactorTemplates handler', () => {
it('should get guardianFactorTemplates', async () => {
const auth0 = {
guardian: {
getSmsFactorTemplates: (params) => ({ data: { ...params, enrollment_message: 'test' }}),
getSmsFactorTemplates: (params) => ({ data: { ...params, enrollment_message: 'test' } }),
},
pool,
};
Expand Down
2 changes: 1 addition & 1 deletion test/tools/auth0/handlers/hooks.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ describe('#hooks handler', () => {
const auth0 = {
hooks: {
getAll: (params) => mockPagedData(params, 'hooks', hooksData),
get: ({ id }) => Promise.resolve({ data: { ...hooksData[id], code }}),
get: ({ id }) => Promise.resolve({ data: { ...hooksData[id], code } }),
getSecrets: ({ id }) => Promise.resolve({ data: { SECRET: `hook-${id}-secret` } }),
},
};
Expand Down
2 changes: 1 addition & 1 deletion test/tools/auth0/handlers/organizations.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ describe('#organizations handler', () => {
expect(params).to.be.an('object');
expect(params.id).to.equal('123');
expect(params.connection_id).to.equal(sampleEnabledConnection2.connection_id);
return Promise.resolve({ data: undefined});
return Promise.resolve({ data: undefined });
},
updateEnabledConnection: (params, data) => {
expect(params).to.be.an('object');
Expand Down
5 changes: 1 addition & 4 deletions test/tools/auth0/handlers/themes.tests.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
//import chai from "chai";

const { expect, assert, use } = require('chai');
const { omit, cloneDeep } = require('lodash');
const { default: ThemesHandler } = require('../../../../src/tools/auth0/handlers/themes');

const chaiAsPromised = require('chai-as-promised');
const { default: ThemesHandler } = require('../../../../src/tools/auth0/handlers/themes');

use(chaiAsPromised);

Expand Down
36 changes: 18 additions & 18 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ chai.use(chaiAsPromised);
export const localDir = 'local';
export const testDataDir = path.resolve(localDir, 'testData');

export function mockPagedData(params, key, data) {
return params?.include_totals
? {
data: {
[key]: data,
},
}
: {
data,
};
}

export function mockMgmtClient() {
// Fake Mgmt Client. Bit hacky but good enough for now.
return {
Expand All @@ -34,10 +46,10 @@ export function mockMgmtClient() {
clientGrants: { getAll: (params) => (mockPagedData(params, 'client_grants', [])) },
guardian: {
getFactors: () => ({ data: [] }),
getSmsFactorProviderTwilio: () => ({data: []}),
getPushNotificationProviderSNS: () => ({data: []}),
getSmsFactorTemplates: () => ({data: []}),
getPhoneFactorMessageTypes: () => ({ data: { message_types: ['sms'] }}),
getSmsFactorProviderTwilio: () => ({ data: [] }),
getPushNotificationProviderSNS: () => ({ data: [] }),
getSmsFactorTemplates: () => ({ data: [] }),
getPhoneFactorMessageTypes: () => ({ data: { message_types: ['sms'] } }),
getPhoneFactorSelectedProvider: () => ({ data: { provider: 'twilio' } }),
getPolicies: () => ({ data: [] }),
},
Expand Down Expand Up @@ -89,7 +101,7 @@ export function mockMgmtClient() {
}
})
),
getCustomTextByLanguage: () => Promise.resolve({data: {} }),
getCustomTextByLanguage: () => Promise.resolve({ data: {} }),
},
migrations: {
getMigrations: () => ({
Expand All @@ -115,7 +127,7 @@ export function mockMgmtClient() {
new Promise((res) => {
res({ data: {} });
}),
get: () => ({ data: {}}),
get: () => ({ data: {} }),
},
customDomains: { getAll: (params) => mockPagedData(params, 'custom_domains', []) },
};
Expand All @@ -139,15 +151,3 @@ export function createDir(repoDir, files) {
});
});
}

export function mockPagedData(params, key, data) {
return params?.include_totals
? {
data: {
[key]: data,
},
}
: {
data,
};
}

0 comments on commit 437b580

Please sign in to comment.