mirror of https://github.com/sveltejs/svelte
parent
5070219218
commit
4dd5fc5594
@ -1,38 +0,0 @@
|
||||
import counter from './counter.js';
|
||||
|
||||
export default {
|
||||
data: {
|
||||
x: 1,
|
||||
y: 2,
|
||||
z: 3
|
||||
},
|
||||
|
||||
html: `
|
||||
<p>1</p>
|
||||
<p class='2'>3</p>
|
||||
`,
|
||||
|
||||
test(assert, component) {
|
||||
counter.y = counter.z = 0;
|
||||
|
||||
component.set({ x: 4 });
|
||||
assert.equal(counter.y, 0);
|
||||
assert.equal(counter.z, 0);
|
||||
|
||||
component.set({ x: 5, y: 6 });
|
||||
assert.equal(counter.y, 1);
|
||||
assert.equal(counter.z, 0);
|
||||
|
||||
component.set({ x: 6, y: 6 });
|
||||
assert.equal(counter.y, 1);
|
||||
assert.equal(counter.z, 0);
|
||||
|
||||
component.set({ z: 7 });
|
||||
assert.equal(counter.y, 1);
|
||||
assert.equal(counter.z, 1);
|
||||
|
||||
component.set({ x: 8, z: 7 });
|
||||
assert.equal(counter.y, 1);
|
||||
assert.equal(counter.z, 1);
|
||||
}
|
||||
};
|
@ -0,0 +1,26 @@
|
||||
import counter from './counter.js';
|
||||
|
||||
export default {
|
||||
data: {
|
||||
x: 1,
|
||||
y: 2
|
||||
},
|
||||
|
||||
html: `
|
||||
<p>1</p>
|
||||
<p class='-2-'></p>
|
||||
`,
|
||||
|
||||
test(assert, component) {
|
||||
counter.count = 0;
|
||||
|
||||
component.set({ x: 3 });
|
||||
assert.equal(counter.count, 0);
|
||||
|
||||
component.set({ x: 4, y: 5 });
|
||||
assert.equal(counter.count, 1);
|
||||
|
||||
component.set({ x: 5, y: 5 });
|
||||
assert.equal(counter.count, 1);
|
||||
}
|
||||
};
|
@ -1,4 +1,3 @@
|
||||
export default {
|
||||
y: 0,
|
||||
z: 0
|
||||
count: 0
|
||||
};
|
@ -1,18 +1,13 @@
|
||||
<p>{{x}}</p>
|
||||
<p class='{{getClass(y)}}'>{{myHelper(z)}}</p>
|
||||
<p class='-{{myHelper(y)}}-'></p>
|
||||
|
||||
<script>
|
||||
import counter from './counter.js';
|
||||
|
||||
export default {
|
||||
helpers: {
|
||||
getClass(value) {
|
||||
counter.y += 1;
|
||||
return value;
|
||||
},
|
||||
|
||||
myHelper(value) {
|
||||
counter.z += 1;
|
||||
counter.count += 1;
|
||||
return value;
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
import counter from './counter.js';
|
||||
|
||||
export default {
|
||||
data: {
|
||||
x: 1,
|
||||
y: 2
|
||||
},
|
||||
|
||||
html: `
|
||||
<p>1</p>
|
||||
<p class='2'></p>
|
||||
`,
|
||||
|
||||
test(assert, component) {
|
||||
counter.count = 0;
|
||||
|
||||
component.set({ x: 3 });
|
||||
assert.equal(counter.count, 0);
|
||||
|
||||
component.set({ x: 4, y: 5 });
|
||||
assert.equal(counter.count, 1);
|
||||
|
||||
component.set({ x: 5, y: 5 });
|
||||
assert.equal(counter.count, 1);
|
||||
}
|
||||
};
|
@ -0,0 +1,3 @@
|
||||
export default {
|
||||
count: 0
|
||||
};
|
@ -0,0 +1,15 @@
|
||||
<p>{{x}}</p>
|
||||
<p class='{{myHelper(y)}}'></p>
|
||||
|
||||
<script>
|
||||
import counter from './counter.js';
|
||||
|
||||
export default {
|
||||
helpers: {
|
||||
myHelper(value) {
|
||||
counter.count += 1;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,26 @@
|
||||
import counter from './counter.js';
|
||||
|
||||
export default {
|
||||
data: {
|
||||
x: 1,
|
||||
y: 2
|
||||
},
|
||||
|
||||
html: `
|
||||
<p>1</p>
|
||||
<p>2</p>
|
||||
`,
|
||||
|
||||
test(assert, component) {
|
||||
counter.count = 0;
|
||||
|
||||
component.set({ x: 3 });
|
||||
assert.equal(counter.count, 0);
|
||||
|
||||
component.set({ x: 4, y: 5 });
|
||||
assert.equal(counter.count, 1);
|
||||
|
||||
component.set({ x: 5, y: 5 });
|
||||
assert.equal(counter.count, 1);
|
||||
}
|
||||
};
|
@ -0,0 +1,3 @@
|
||||
export default {
|
||||
count: 0
|
||||
};
|
@ -0,0 +1,15 @@
|
||||
<p>{{x}}</p>
|
||||
<p>{{{myHelper(y)}}}</p>
|
||||
|
||||
<script>
|
||||
import counter from './counter.js';
|
||||
|
||||
export default {
|
||||
helpers: {
|
||||
myHelper(value) {
|
||||
counter.count += 1;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,26 @@
|
||||
import counter from './counter.js';
|
||||
|
||||
export default {
|
||||
data: {
|
||||
x: 1,
|
||||
y: 2
|
||||
},
|
||||
|
||||
html: `
|
||||
<p>1</p>
|
||||
<p>2</p>
|
||||
`,
|
||||
|
||||
test(assert, component) {
|
||||
counter.count = 0;
|
||||
|
||||
component.set({ x: 3 });
|
||||
assert.equal(counter.count, 0);
|
||||
|
||||
component.set({ x: 4, y: 5 });
|
||||
assert.equal(counter.count, 1);
|
||||
|
||||
component.set({ x: 5, y: 5 });
|
||||
assert.equal(counter.count, 1);
|
||||
}
|
||||
};
|
@ -0,0 +1,3 @@
|
||||
export default {
|
||||
count: 0
|
||||
};
|
@ -0,0 +1,15 @@
|
||||
<p>{{x}}</p>
|
||||
<p>{{myHelper(y)}}</p>
|
||||
|
||||
<script>
|
||||
import counter from './counter.js';
|
||||
|
||||
export default {
|
||||
helpers: {
|
||||
myHelper(value) {
|
||||
counter.count += 1;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Reference in new issue