Skip to content

Commit

Permalink
Revert "feat: add wire config as function (#1455)" (#1601)
Browse files Browse the repository at this point in the history
This reverts commit 81a6e48.

Revert "feat: add wire config as function (#1455)"
This reverts commit 828aaca.
  • Loading branch information
jodarove authored Oct 31, 2019
1 parent 609b575 commit 722979e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 394 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,6 @@ describe('Implicit mode', () => {
params: {},
static: {
id: 1
},
config: function($cmp) {
return {
id: 1
};
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ describe('observed fields', () => {
publicMethods: ["someMethod"],
wire: {
wiredProp: {
adapter: createElement,
config: function($cmp) {
return {};
}
adapter: createElement
}
},
track: {
Expand Down Expand Up @@ -174,10 +171,7 @@ describe('observed fields', () => {
publicMethods: ["someMethod"],
wire: {
wiredProp: {
adapter: createElement,
config: function($cmp) {
return {};
}
adapter: createElement
}
},
track: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,177 +40,6 @@ describe('Transform property', () => {
},
static: {
key2: ["fixed", "array"]
},
config: function($cmp) {
return {
key2: ["fixed", "array"],
key1: $cmp.prop1
};
}
}
}
});
export default _registerComponent(Test, {
tmpl: _tmpl
});
`,
},
}
);

pluginTest(
'transforms named imports from static imports',
`
import { wire } from 'lwc';
import importedValue from "ns/module";
import { getFoo } from 'data-service';
export default class Test {
@wire(getFoo, { key1: importedValue })
wiredProp;
}
`,
{
output: {
code: `
import { registerDecorators as _registerDecorators } from "lwc";
import _tmpl from "./test.html";
import { registerComponent as _registerComponent } from "lwc";
import importedValue from "ns/module";
import { getFoo } from "data-service";
class Test {
constructor() {
this.wiredProp = void 0;
}
}
_registerDecorators(Test, {
wire: {
wiredProp: {
adapter: getFoo,
params: {},
static: {
key1: importedValue
},
config: function($cmp) {
return {
key1: importedValue
};
}
}
}
});
export default _registerComponent(Test, {
tmpl: _tmpl
});
`,
},
}
);

pluginTest(
'transforms parameters with 2 levels deep (foo.bar)',
`
import { wire } from 'lwc';
import { getFoo } from 'data-service';
export default class Test {
@wire(getFoo, { key1: "$prop1.prop2", key2: ["fixed", 'array'], key3: "$p1.p2" })
wiredProp;
}
`,
{
output: {
code: `
import { registerDecorators as _registerDecorators } from "lwc";
import _tmpl from "./test.html";
import { registerComponent as _registerComponent } from "lwc";
import { getFoo } from "data-service";
class Test {
constructor() {
this.wiredProp = void 0;
}
}
_registerDecorators(Test, {
wire: {
wiredProp: {
adapter: getFoo,
params: {
key1: "prop1.prop2",
key3: "p1.p2"
},
static: {
key2: ["fixed", "array"]
},
config: function($cmp) {
let v1 = $cmp.prop1;
let v2 = $cmp.p1;
return {
key2: ["fixed", "array"],
key1: v1 != null ? v1.prop2 : undefined,
key3: v2 != null ? v2.p2 : undefined
};
}
}
}
});
export default _registerComponent(Test, {
tmpl: _tmpl
});
`,
},
}
);

pluginTest(
'transforms parameters with multiple levels deep',
`
import { wire } from 'lwc';
import { getFoo } from 'data-service';
export default class Test {
@wire(getFoo, { key1: "$prop1.prop2.prop3.prop4", key2: ["fixed", 'array']})
wiredProp;
}
`,
{
output: {
code: `
import { registerDecorators as _registerDecorators } from "lwc";
import _tmpl from "./test.html";
import { registerComponent as _registerComponent } from "lwc";
import { getFoo } from "data-service";
class Test {
constructor() {
this.wiredProp = void 0;
}
}
_registerDecorators(Test, {
wire: {
wiredProp: {
adapter: getFoo,
params: {
key1: "prop1.prop2.prop3.prop4"
},
static: {
key2: ["fixed", "array"]
},
config: function($cmp) {
let v1 = $cmp.prop1;
return {
key2: ["fixed", "array"],
key1:
v1 != null &&
(v1 = v1.prop2) != null &&
(v1 = v1.prop3) != null
? v1.prop4
: undefined
};
}
}
}
Expand Down Expand Up @@ -259,14 +88,6 @@ describe('Transform property', () => {
static: {
key3: "fixed",
key4: ["fixed", "array"]
},
config: function($cmp) {
return {
key3: "fixed",
key4: ["fixed", "array"],
key1: $cmp.prop,
key2: $cmp.prop
};
}
}
}
Expand Down Expand Up @@ -350,10 +171,7 @@ describe('Transform property', () => {
wiredProp: {
adapter: getFoo,
params: {},
static: {},
config: function($cmp) {
return {};
}
static: {}
}
}
});
Expand All @@ -367,7 +185,7 @@ describe('Transform property', () => {
);

pluginTest(
'decorator accepts a member expression',
'decorator accepts a member epxression',
`
import { wire } from 'lwc';
import { Foo } from 'data-service';
Expand All @@ -394,10 +212,7 @@ describe('Transform property', () => {
wiredProp: {
adapter: Foo.Bar,
params: {},
static: {},
config: function($cmp) {
return {};
}
static: {}
}
}
});
Expand Down Expand Up @@ -438,10 +253,7 @@ describe('Transform property', () => {
wiredProp: {
adapter: Foo.Bar,
params: {},
static: {},
config: function($cmp) {
return {};
}
static: {}
}
}
});
Expand Down Expand Up @@ -502,10 +314,7 @@ describe('Transform property', () => {
_registerDecorators(Test, {
wire: {
wiredProp: {
adapter: getFoo,
config: function($cmp) {
return {};
}
adapter: getFoo
}
}
});
Expand Down Expand Up @@ -670,12 +479,6 @@ describe('Transform property', () => {
},
static: {
key2: ["fixed"]
},
config: function($cmp) {
return {
key2: ["fixed"],
key1: $cmp.prop1
};
}
},
wired2: {
Expand All @@ -685,12 +488,6 @@ describe('Transform property', () => {
},
static: {
key2: ["array"]
},
config: function($cmp) {
return {
key2: ["array"],
key1: $cmp.prop1
};
}
}
}
Expand Down Expand Up @@ -738,13 +535,7 @@ describe('Transform method', () => {
static: {
key2: ["fixed"]
},
method: 1,
config: function($cmp) {
return {
key2: ["fixed"],
key1: $cmp.prop1
};
}
method: 1
}
}
});
Expand Down
Loading

0 comments on commit 722979e

Please sign in to comment.