Use Prettier JS (#5017)

* Adds prettier

* Run lint before tests
This commit is contained in:
Florent Vilmart
2018-09-01 13:58:06 -04:00
committed by GitHub
parent 189cd259ee
commit d83a0b6808
240 changed files with 41098 additions and 29020 deletions

View File

@@ -1,41 +1,41 @@
const loadAdapter = require("../lib/Adapters/AdapterLoader").loadAdapter;
const FilesAdapter = require("@parse/fs-files-adapter").default;
const S3Adapter = require("@parse/s3-files-adapter").default;
const ParsePushAdapter = require("@parse/push-adapter").default;
const loadAdapter = require('../lib/Adapters/AdapterLoader').loadAdapter;
const FilesAdapter = require('@parse/fs-files-adapter').default;
const S3Adapter = require('@parse/s3-files-adapter').default;
const ParsePushAdapter = require('@parse/push-adapter').default;
const Config = require('../lib/Config');
describe("AdapterLoader", ()=>{
it("should instantiate an adapter from string in object", (done) => {
const adapterPath = require('path').resolve("./spec/MockAdapter");
describe('AdapterLoader', () => {
it('should instantiate an adapter from string in object', done => {
const adapterPath = require('path').resolve('./spec/MockAdapter');
const adapter = loadAdapter({
adapter: adapterPath,
options: {
key: "value",
foo: "bar"
}
key: 'value',
foo: 'bar',
},
});
expect(adapter instanceof Object).toBe(true);
expect(adapter.options.key).toBe("value");
expect(adapter.options.foo).toBe("bar");
expect(adapter.options.key).toBe('value');
expect(adapter.options.foo).toBe('bar');
done();
});
it("should instantiate an adapter from string", (done) => {
const adapterPath = require('path').resolve("./spec/MockAdapter");
it('should instantiate an adapter from string', done => {
const adapterPath = require('path').resolve('./spec/MockAdapter');
const adapter = loadAdapter(adapterPath);
expect(adapter instanceof Object).toBe(true);
done();
});
it("should instantiate an adapter from string that is module", (done) => {
const adapterPath = require('path').resolve("./lib/Adapters/Files/FilesAdapter");
it('should instantiate an adapter from string that is module', done => {
const adapterPath = require('path').resolve(
'./lib/Adapters/Files/FilesAdapter'
);
const adapter = loadAdapter({
adapter: adapterPath
adapter: adapterPath,
});
expect(typeof adapter).toBe('object');
@@ -46,9 +46,9 @@ describe("AdapterLoader", ()=>{
done();
});
it("should instantiate an adapter from npm module", (done) => {
it('should instantiate an adapter from npm module', done => {
const adapter = loadAdapter({
module: '@parse/fs-files-adapter'
module: '@parse/fs-files-adapter',
});
expect(typeof adapter).toBe('object');
@@ -59,59 +59,59 @@ describe("AdapterLoader", ()=>{
done();
});
it("should instantiate an adapter from function/Class", (done) => {
it('should instantiate an adapter from function/Class', done => {
const adapter = loadAdapter({
adapter: FilesAdapter
adapter: FilesAdapter,
});
expect(adapter instanceof FilesAdapter).toBe(true);
done();
});
it("should instantiate the default adapter from Class", (done) => {
it('should instantiate the default adapter from Class', done => {
const adapter = loadAdapter(null, FilesAdapter);
expect(adapter instanceof FilesAdapter).toBe(true);
done();
});
it("should use the default adapter", (done) => {
it('should use the default adapter', done => {
const defaultAdapter = new FilesAdapter();
const adapter = loadAdapter(null, defaultAdapter);
expect(adapter instanceof FilesAdapter).toBe(true);
done();
});
it("should use the provided adapter", (done) => {
it('should use the provided adapter', done => {
const originalAdapter = new FilesAdapter();
const adapter = loadAdapter(originalAdapter);
expect(adapter).toBe(originalAdapter);
done();
});
it("should fail loading an improperly configured adapter", (done) => {
it('should fail loading an improperly configured adapter', done => {
const Adapter = function(options) {
if (!options.foo) {
throw "foo is required for that adapter";
throw 'foo is required for that adapter';
}
}
};
const adapterOptions = {
param: "key",
doSomething: function() {}
param: 'key',
doSomething: function() {},
};
expect(() => {
const adapter = loadAdapter(adapterOptions, Adapter);
expect(adapter).toEqual(adapterOptions);
}).not.toThrow("foo is required for that adapter");
}).not.toThrow('foo is required for that adapter');
done();
});
it("should load push adapter from options", (done) => {
it('should load push adapter from options', done => {
const options = {
android: {
senderId: 'yolo',
apiKey: 'yolo'
}
}
apiKey: 'yolo',
},
};
expect(() => {
const adapter = loadAdapter(undefined, ParsePushAdapter, options);
expect(adapter.constructor).toBe(ParsePushAdapter);
@@ -120,16 +120,16 @@ describe("AdapterLoader", ()=>{
done();
});
it("should load custom push adapter from string (#3544)", (done) => {
const adapterPath = require('path').resolve("./spec/MockPushAdapter");
it('should load custom push adapter from string (#3544)', done => {
const adapterPath = require('path').resolve('./spec/MockPushAdapter');
const options = {
ios: {
bundleId: 'bundle.id'
}
}
bundleId: 'bundle.id',
},
};
const pushAdapterOptions = {
adapter: adapterPath,
options
options,
};
expect(() => {
reconfigureServer({
@@ -144,12 +144,12 @@ describe("AdapterLoader", ()=>{
}).not.toThrow();
});
it("should load S3Adapter from direct passing", (done) => {
const s3Adapter = new S3Adapter("key", "secret", "bucket")
it('should load S3Adapter from direct passing', done => {
const s3Adapter = new S3Adapter('key', 'secret', 'bucket');
expect(() => {
const adapter = loadAdapter(s3Adapter, FilesAdapter);
expect(adapter).toBe(s3Adapter);
}).not.toThrow();
done();
})
});
});