2차 수정

This commit is contained in:
jieun committed 2026-11-18 17:58:22 +09:00
1 parent f551671394
commit 188f0c0e2a
5 files changed
+84 -21

No files matched your search

+15 -1
View File
@@ -17,7 +17,7 @@ function load(file, name) {
assert.deepStrictEqual(compiled.errors, [], name + ' template must compile');
const source = parsed.script.content.replace(/^import .*;$/mg, '').replace('export default', 'module.exports =');
const context = {module:{exports:{}}, process:{env:{}}, window:{location:{protocol:'http:',hostname:'localhost'}},
Icon:components.Icon, SensorTrend:components.SensorTrend, createDemo:demo, Date, Number, URL, AbortController,
Icon:components.Icon, SensorTrend:components.SensorTrend, BatteryGauge:components.BatteryGauge, createDemo:demo, Date, Number, URL, AbortController,
setTimeout, clearTimeout, setInterval, clearInterval};
vm.runInNewContext(source, context);
const options = context.module.exports;
@@ -28,6 +28,20 @@ function load(file, name) {
}
components.Icon = load('src/components/ConsoleIcon.vue', 'Icon');
components.SensorTrend = load('src/components/SensorTrend.vue', 'Trend');
components.BatteryGauge = load('src/components/BatteryGauge.vue', 'BatteryGauge');
const Gauge = Vue.extend(components.BatteryGauge);
const gauge = new Gauge({propsData:{value:86}});
assert.equal(gauge.numeric,86);
assert.equal(gauge.valid,true);
for (const value of [0,100,'42.5']) {
gauge.value=value; assert.equal(gauge.valid,true); assert(gauge._render().tag);
}
for (const value of [null,undefined,'',' ']) {
gauge.value=value; assert.equal(gauge.missing,true); assert.equal(gauge.valid,false);
}
for (const value of [-1,101,Infinity,NaN,'invalid',false,{}]) {
gauge.value=value; assert.equal(gauge.missing,false); assert.equal(gauge.valid,false);
}
const options = load('src/pages/Dashboard.vue', 'Dashboard');
const route = Vue.observable({query:{view:'overview'}});
Vue.prototype.$route = route;