prettier/tests/method-chain/__snapshots__/jsfmt.spec.js.snap

960 lines
26 KiB
Plaintext

// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`bracket_0.js 1`] = `
====================================options=====================================
parsers: ["flow", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
function a() {
function b() {
queryThenMutateDOM(
() => {
title = SomeThing.call(root, 'someLongStringThatPushesThisTextReallyFar')[0];
}
);
}
}
=====================================output=====================================
function a() {
function b() {
queryThenMutateDOM(() => {
title = SomeThing.call(
root,
"someLongStringThatPushesThisTextReallyFar"
)[0];
});
}
}
================================================================================
`;
exports[`break-last-call.js 1`] = `
====================================options=====================================
parsers: ["flow", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
export default store => {
return callApi(endpoint, schema).then(
response => next(actionWith({
response,
type: successType
})),
error => next(actionWith({
type: failureType,
error: error.message || 'Something bad happened'
}))
)
}
it('should group messages with same created time', () => {
expect(
groupMessages(messages).toJS(),
).toEqual({
'11/01/2017 13:36': [
{message: 'test', messageType: 'SMS', status: 'Unknown', created: '11/01/2017 13:36'},
{message: 'test', messageType: 'Email', status: 'Unknown', created: '11/01/2017 13:36'},
],
'09/01/2017 17:25': [
{message: 'te', messageType: 'SMS', status: 'Unknown', created: '09/01/2017 17:25'},
{message: 'te', messageType: 'Email', status: 'Unknown', created: '09/01/2017 17:25'},
],
'11/01/2017 13:33': [
{message: 'test', messageType: 'SMS', status: 'Unknown', created: '11/01/2017 13:33'},
{message: 'test', messageType: 'Email', status: 'Unknown', created: '11/01/2017 13:33'},
],
'11/01/2017 13:37': [
{message: 'test', messageType: 'SMS', status: 'Unknown', created: '11/01/2017 13:37'},
{message: 'test', messageType: 'Email', status: 'Unknown', created: '11/01/2017 13:37'},
],
});
});
=====================================output=====================================
export default store => {
return callApi(endpoint, schema).then(
response =>
next(
actionWith({
response,
type: successType
})
),
error =>
next(
actionWith({
type: failureType,
error: error.message || "Something bad happened"
})
)
);
};
it("should group messages with same created time", () => {
expect(groupMessages(messages).toJS()).toEqual({
"11/01/2017 13:36": [
{
message: "test",
messageType: "SMS",
status: "Unknown",
created: "11/01/2017 13:36"
},
{
message: "test",
messageType: "Email",
status: "Unknown",
created: "11/01/2017 13:36"
}
],
"09/01/2017 17:25": [
{
message: "te",
messageType: "SMS",
status: "Unknown",
created: "09/01/2017 17:25"
},
{
message: "te",
messageType: "Email",
status: "Unknown",
created: "09/01/2017 17:25"
}
],
"11/01/2017 13:33": [
{
message: "test",
messageType: "SMS",
status: "Unknown",
created: "11/01/2017 13:33"
},
{
message: "test",
messageType: "Email",
status: "Unknown",
created: "11/01/2017 13:33"
}
],
"11/01/2017 13:37": [
{
message: "test",
messageType: "SMS",
status: "Unknown",
created: "11/01/2017 13:37"
},
{
message: "test",
messageType: "Email",
status: "Unknown",
created: "11/01/2017 13:37"
}
]
});
});
================================================================================
`;
exports[`break-last-member.js 1`] = `
====================================options=====================================
parsers: ["flow", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
SomeVeryLongUpperCaseConstant.someVeryLongCallExpression().some_very_long_member_expression
weNeedToReachTheEightyCharacterLimitXXXXXXXXXXXXXXXXX.someNode
.childrenInAnArray[0];
superSupersuperSupersuperSupersuperSupersuperSuperLong.exampleOfOrderOfGetterAndSetterReordered;
superSupersuperSupersuperSupersuperSupersuperSuperLong.exampleOfOrderOfGetterAndSetterReordered[0];
expect(
findDOMNode(component.instance()).getElementsByClassName(styles.inner)[0].style.paddingRight
).toBe('1000px');
const { course, conflicts = [], index, scheduleId, studentId, something } = a.this.props;
const { course, conflicts = [], index, scheduleId, studentId, something } = this.props;
const {
updated,
author: { identifier: ownerId },
location,
category: categories,
} = rawAd.entry;
=====================================output=====================================
SomeVeryLongUpperCaseConstant.someVeryLongCallExpression()
.some_very_long_member_expression;
weNeedToReachTheEightyCharacterLimitXXXXXXXXXXXXXXXXX.someNode
.childrenInAnArray[0];
superSupersuperSupersuperSupersuperSupersuperSuperLong.exampleOfOrderOfGetterAndSetterReordered;
superSupersuperSupersuperSupersuperSupersuperSuperLong
.exampleOfOrderOfGetterAndSetterReordered[0];
expect(
findDOMNode(component.instance()).getElementsByClassName(styles.inner)[0]
.style.paddingRight
).toBe("1000px");
const {
course,
conflicts = [],
index,
scheduleId,
studentId,
something
} = a.this.props;
const {
course,
conflicts = [],
index,
scheduleId,
studentId,
something
} = this.props;
const {
updated,
author: { identifier: ownerId },
location,
category: categories
} = rawAd.entry;
================================================================================
`;
exports[`break-multiple.js 1`] = `
====================================options=====================================
parsers: ["flow", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
object.foo().bar().baz();
foo().bar().baz();
foo().bar.baz();
=====================================output=====================================
object
.foo()
.bar()
.baz();
foo()
.bar()
.baz();
foo().bar.baz();
================================================================================
`;
exports[`comment.js 1`] = `
====================================options=====================================
parsers: ["flow", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
function f() {
return observableFromSubscribeFunction()
// Debounce manually rather than using editor.onDidStopChanging so that the debounce time is
// configurable.
.debounceTime(debounceInterval);
}
_.a(a)
/* very very very very very very very long such that it is longer than 80 columns */
.a()
_.a(
a
)/* very very very very very very very long such that it is longer than 80 columns */
.a();
_.a(
a
) /* very very very very very very very long such that it is longer than 80 columns */.a();
Something
// $FlowFixMe(>=0.41.0)
.getInstance(this.props.dao)
.getters()
// Warm-up first
measure()
.then(() => {
SomethingLong();
});
measure() // Warm-up first
.then(() => {
SomethingLong();
});
const configModel = this.baseConfigurationService.getCache().consolidated // global/default values (do NOT modify)
.merge(this.cachedWorkspaceConfig);
this.doWriteConfiguration(target, value, options) // queue up writes to prevent race conditions
.then(() => null,
error => {
return options.donotNotifyError ? TPromise.wrapError(error) : this.onError(error, target, value);
});
ret = __DEV__ ?
// $FlowFixMe: this type differs according to the env
vm.runInContext(source, ctx)
: a
this.firebase.object(\`/shops/\${shopLocation.shop}\`)
// keep distance info
.first((shop: ShopQueryResult, index: number, source: Observable<ShopQueryResult>): any => {
// add distance to result
const s = shop;
s.distance = shopLocation.distance;
return s;
});
angular.module('AngularAppModule')
// Hello, I am comment.
.constant('API_URL', 'http://localhost:8080/api');
=====================================output=====================================
function f() {
return (
observableFromSubscribeFunction()
// Debounce manually rather than using editor.onDidStopChanging so that the debounce time is
// configurable.
.debounceTime(debounceInterval)
);
}
_.a(a)
/* very very very very very very very long such that it is longer than 80 columns */
.a();
_.a(
a
) /* very very very very very very very long such that it is longer than 80 columns */
.a();
_.a(
a
) /* very very very very very very very long such that it is longer than 80 columns */
.a();
Something
// $FlowFixMe(>=0.41.0)
.getInstance(this.props.dao)
.getters();
// Warm-up first
measure().then(() => {
SomethingLong();
});
measure() // Warm-up first
.then(() => {
SomethingLong();
});
const configModel = this.baseConfigurationService
.getCache()
.consolidated // global/default values (do NOT modify)
.merge(this.cachedWorkspaceConfig);
this.doWriteConfiguration(target, value, options) // queue up writes to prevent race conditions
.then(
() => null,
error => {
return options.donotNotifyError
? TPromise.wrapError(error)
: this.onError(error, target, value);
}
);
ret = __DEV__
? // $FlowFixMe: this type differs according to the env
vm.runInContext(source, ctx)
: a;
this.firebase
.object(\`/shops/\${shopLocation.shop}\`)
// keep distance info
.first(
(
shop: ShopQueryResult,
index: number,
source: Observable<ShopQueryResult>
): any => {
// add distance to result
const s = shop;
s.distance = shopLocation.distance;
return s;
}
);
angular
.module("AngularAppModule")
// Hello, I am comment.
.constant("API_URL", "http://localhost:8080/api");
================================================================================
`;
exports[`computed.js 1`] = `
====================================options=====================================
parsers: ["flow", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
nock(/test/)
.matchHeader('Accept', 'application/json')
[httpMethodNock(method)]('/foo')
.reply(200, {
foo: 'bar',
});
=====================================output=====================================
nock(/test/)
.matchHeader("Accept", "application/json")
[httpMethodNock(method)]("/foo")
.reply(200, {
foo: "bar"
});
================================================================================
`;
exports[`computed-merge.js 1`] = `
====================================options=====================================
parsers: ["flow", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
[].forEach(key => {
data[key]('foo')
.then(() => console.log('bar'))
.catch(() => console.log('baz'));
});
[].forEach(key => {
data('foo')
[key]('bar')
.then(() => console.log('bar'))
.catch(() => console.log('baz'));
});
window.Data[key]("foo")
.then(() => a)
.catch(() => b);
=====================================output=====================================
[].forEach(key => {
data[key]("foo")
.then(() => console.log("bar"))
.catch(() => console.log("baz"));
});
[].forEach(key => {
data("foo")
[key]("bar")
.then(() => console.log("bar"))
.catch(() => console.log("baz"));
});
window.Data[key]("foo")
.then(() => a)
.catch(() => b);
================================================================================
`;
exports[`conditional.js 1`] = `
====================================options=====================================
parsers: ["flow", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
(a ? b : c).d();
(a ? b : c).d().e();
(a ? b : c).d().e().f();
(valid
? helper.responseBody(this.currentUser)
: helper.responseBody(this.defaultUser))
.map();
(valid
? helper.responseBody(this.currentUser)
: helper.responseBody(this.defaultUser))
.map().filter();
(valid
? helper.responseBody(this.currentUser)
: helper.responseBody(defaultUser))
.map();
object[valid
? helper.responseBody(this.currentUser)
: helper.responseBody(defaultUser)]
.map();
=====================================output=====================================
(a ? b : c).d();
(a ? b : c).d().e();
(a ? b : c)
.d()
.e()
.f();
(valid
? helper.responseBody(this.currentUser)
: helper.responseBody(this.defaultUser)
).map();
(valid
? helper.responseBody(this.currentUser)
: helper.responseBody(this.defaultUser)
)
.map()
.filter();
(valid
? helper.responseBody(this.currentUser)
: helper.responseBody(defaultUser)
).map();
object[
valid
? helper.responseBody(this.currentUser)
: helper.responseBody(defaultUser)
].map();
================================================================================
`;
exports[`d3.js 1`] = `
====================================options=====================================
parsers: ["flow", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
d3.select('body')
.append('circle')
.at({ width: 30, fill: '#f0f' })
.st({ fontWeight: 600 })
d3.scaleLinear()
.domain([1950, 1980])
.range([0, width])
not.d3.select('body')
.append('circle')
.at({ width: 30, fill: '#f0f' })
.st({ fontWeight: 600 })
not.d3.scaleLinear()
.domain([1950, 1980])
.range([0, width])
=====================================output=====================================
d3.select("body")
.append("circle")
.at({ width: 30, fill: "#f0f" })
.st({ fontWeight: 600 });
d3.scaleLinear()
.domain([1950, 1980])
.range([0, width]);
not.d3
.select("body")
.append("circle")
.at({ width: 30, fill: "#f0f" })
.st({ fontWeight: 600 });
not.d3
.scaleLinear()
.domain([1950, 1980])
.range([0, width]);
================================================================================
`;
exports[`first_long.js 1`] = `
====================================options=====================================
parsers: ["flow", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
export default function theFunction(action$, store) {
return action$.ofType(THE_ACTION).switchMap(action => Observable
.webSocket({
url: THE_URL,
more: stuff(),
evenMore: stuff({
value1: true,
value2: false,
value3: false
})
})
.filter(data => theFilter(data))
.map(({ theType, ...data }) => theMap(theType, data))
.retryWhen(errors => errors));
}
function f() {
return this._getWorker(workerOptions)({
filePath,
hasteImplModulePath: this._options.hasteImplModulePath,
}).then(
metadata => {
// \`1\` for truthy values instead of \`true\` to save cache space.
fileMetadata[H.VISITED] = 1;
const metadataId = metadata.id;
const metadataModule = metadata.module;
if (metadataId && metadataModule) {
fileMetadata[H.ID] = metadataId;
setModule(metadataId, metadataModule);
}
fileMetadata[H.DEPENDENCIES] = metadata.dependencies || [];
}
);
}
=====================================output=====================================
export default function theFunction(action$, store) {
return action$.ofType(THE_ACTION).switchMap(action =>
Observable.webSocket({
url: THE_URL,
more: stuff(),
evenMore: stuff({
value1: true,
value2: false,
value3: false
})
})
.filter(data => theFilter(data))
.map(({ theType, ...data }) => theMap(theType, data))
.retryWhen(errors => errors)
);
}
function f() {
return this._getWorker(workerOptions)({
filePath,
hasteImplModulePath: this._options.hasteImplModulePath
}).then(metadata => {
// \`1\` for truthy values instead of \`true\` to save cache space.
fileMetadata[H.VISITED] = 1;
const metadataId = metadata.id;
const metadataModule = metadata.module;
if (metadataId && metadataModule) {
fileMetadata[H.ID] = metadataId;
setModule(metadataId, metadataModule);
}
fileMetadata[H.DEPENDENCIES] = metadata.dependencies || [];
});
}
================================================================================
`;
exports[`inline_merge.js 1`] = `
====================================options=====================================
parsers: ["flow", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
Object.keys(
availableLocales({
test: true
})
)
.forEach(locale => {
// ...
});
this.layoutPartsToHide = this.utils.hashset(
_.flatMap(this.visibilityHandlers, fn => fn())
.concat(this.record.resolved_legacy_visrules)
.filter(Boolean)
);
var jqxhr = $.ajax("example.php")
.done(doneFn)
.fail(failFn);
=====================================output=====================================
Object.keys(
availableLocales({
test: true
})
).forEach(locale => {
// ...
});
this.layoutPartsToHide = this.utils.hashset(
_.flatMap(this.visibilityHandlers, fn => fn())
.concat(this.record.resolved_legacy_visrules)
.filter(Boolean)
);
var jqxhr = $.ajax("example.php")
.done(doneFn)
.fail(failFn);
================================================================================
`;
exports[`logical.js 1`] = `
====================================options=====================================
parsers: ["flow", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
const someLongVariableName = (idx(
this.props,
props => props.someLongPropertyName
) || []
).map(edge => edge.node);
(veryLongVeryLongVeryLong || e).map(tickets =>
TicketRecord.createFromSomeLongString());
(veryLongVeryLongVeryLong || e).map(tickets =>
TicketRecord.createFromSomeLongString()).filter(obj => !!obj);
(veryLongVeryLongVeryLong || anotherVeryLongVeryLongVeryLong || veryVeryVeryLongError).map(tickets =>
TicketRecord.createFromSomeLongString());
(veryLongVeryLongVeryLong || anotherVeryLongVeryLongVeryLong || veryVeryVeryLongError).map(tickets =>
TicketRecord.createFromSomeLongString()).filter(obj => !!obj);
=====================================output=====================================
const someLongVariableName = (
idx(this.props, props => props.someLongPropertyName) || []
).map(edge => edge.node);
(veryLongVeryLongVeryLong || e).map(tickets =>
TicketRecord.createFromSomeLongString()
);
(veryLongVeryLongVeryLong || e)
.map(tickets => TicketRecord.createFromSomeLongString())
.filter(obj => !!obj);
(
veryLongVeryLongVeryLong ||
anotherVeryLongVeryLongVeryLong ||
veryVeryVeryLongError
).map(tickets => TicketRecord.createFromSomeLongString());
(
veryLongVeryLongVeryLong ||
anotherVeryLongVeryLongVeryLong ||
veryVeryVeryLongError
)
.map(tickets => TicketRecord.createFromSomeLongString())
.filter(obj => !!obj);
================================================================================
`;
exports[`multiple-members.js 1`] = `
====================================options=====================================
parsers: ["flow", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
if (testConfig.ENABLE_ONLINE_TESTS === "true") {
describe("POST /users/me/pet", function() {
it("saves pet", function() {
function assert(pet) {
expect(pet).to.have.property("OwnerAddress").that.deep.equals({
AddressLine1: "Alexanderstrasse",
AddressLine2: "",
PostalCode: "10999",
Region: "Berlin",
City: "Berlin",
Country: "DE"
});
}
});
});
}
wrapper.find('SomewhatLongNodeName').prop('longPropFunctionName')().then(function() {
doSomething();
});
wrapper.find('SomewhatLongNodeName').prop('longPropFunctionName')('argument').then(function() {
doSomething();
});
wrapper.find('SomewhatLongNodeName').prop('longPropFunctionName', 'second argument that pushes this group past 80 characters')('argument').then(function() {
doSomething();
});
wrapper.find('SomewhatLongNodeName').prop('longPropFunctionName')('argument', 'second argument that pushes this group past 80 characters').then(function() {
doSomething();
});
=====================================output=====================================
if (testConfig.ENABLE_ONLINE_TESTS === "true") {
describe("POST /users/me/pet", function() {
it("saves pet", function() {
function assert(pet) {
expect(pet)
.to.have.property("OwnerAddress")
.that.deep.equals({
AddressLine1: "Alexanderstrasse",
AddressLine2: "",
PostalCode: "10999",
Region: "Berlin",
City: "Berlin",
Country: "DE"
});
}
});
});
}
wrapper
.find("SomewhatLongNodeName")
.prop("longPropFunctionName")()
.then(function() {
doSomething();
});
wrapper
.find("SomewhatLongNodeName")
.prop("longPropFunctionName")("argument")
.then(function() {
doSomething();
});
wrapper
.find("SomewhatLongNodeName")
.prop(
"longPropFunctionName",
"second argument that pushes this group past 80 characters"
)("argument")
.then(function() {
doSomething();
});
wrapper
.find("SomewhatLongNodeName")
.prop("longPropFunctionName")(
"argument",
"second argument that pushes this group past 80 characters"
)
.then(function() {
doSomething();
});
================================================================================
`;
exports[`short-names.js 1`] = `
====================================options=====================================
parsers: ["flow", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
const svgJsFiles = fs
.readdirSync(svgDir)
.filter(f => svgJsFileExtRegex.test(f))
.map(f => path.join(svgDir, f));
=====================================output=====================================
const svgJsFiles = fs
.readdirSync(svgDir)
.filter(f => svgJsFileExtRegex.test(f))
.map(f => path.join(svgDir, f));
================================================================================
`;
exports[`square_0.js 1`] = `
====================================options=====================================
parsers: ["flow", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
const version = someLongString
.split('jest version =')
.pop()
.split(EOL)[0]
.trim();
const component = find('.org-lclp-edit-copy-url-banner__link')[0]
.getAttribute('href')
.indexOf(this.landingPageLink);
=====================================output=====================================
const version = someLongString
.split("jest version =")
.pop()
.split(EOL)[0]
.trim();
const component = find(".org-lclp-edit-copy-url-banner__link")[0]
.getAttribute("href")
.indexOf(this.landingPageLink);
================================================================================
`;
exports[`test.js 1`] = `
====================================options=====================================
parsers: ["flow", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
method().then(x => x)
["abc"](x => x)
[abc](x => x);
({}.a().b());
({}).a().b();
=====================================output=====================================
method()
.then(x => x)
["abc"](x => x)
[abc](x => x);
({}.a().b());
({}.a().b());
================================================================================
`;
exports[`this.js 1`] = `
====================================options=====================================
parsers: ["flow", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
const sel = this.connections
.concat(this.activities.concat(this.operators))
.filter(x => x.selected);
=====================================output=====================================
const sel = this.connections
.concat(this.activities.concat(this.operators))
.filter(x => x.selected);
================================================================================
`;