Skip to content

Commit 86d466e

Browse files
fix: test for wire invocation order
1 parent beecebe commit 86d466e

File tree

6 files changed

+47
-0
lines changed

6 files changed

+47
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"entry": "x/wire"
3+
}

packages/@lwc/engine-server/src/__tests__/fixtures/wire/invocation-sequence/error.txt

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<fixture-test>
2+
<template shadowrootmode="open">
3+
<div>
4+
Wire adapter invocation sequence: 1. connect 2. update
5+
</div>
6+
<div>
7+
Wired prop: true
8+
</div>
9+
</template>
10+
</fixture-test>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export let invocationSequence = [];
2+
3+
export class adapter {
4+
constructor(dataCallback) {
5+
this.dc = dataCallback;
6+
}
7+
8+
connect() {
9+
invocationSequence.push('connect');
10+
}
11+
12+
update() {
13+
invocationSequence.push('update');
14+
this.dc(true);
15+
}
16+
17+
disconnect() {}
18+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<template>
2+
<div>Wire adapter invocation sequence: {invocationSequence}</div>
3+
<div>Wired prop: {wiredProp}</div>
4+
</template>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { LightningElement, wire } from 'lwc';
2+
3+
import { adapter, invocationSequence } from './adapter';
4+
5+
export default class Wire extends LightningElement {
6+
@wire(adapter)
7+
wiredProp;
8+
9+
get invocationSequence() {
10+
return invocationSequence.map((invocation, i) => `${i + 1}. ${invocation}`).join(' ');
11+
}
12+
}

0 commit comments

Comments
 (0)