From 2a13697621a3d2c27b1bd0ae2fec6fdd328bb8c9 Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford Date: Wed, 12 Sep 2018 17:23:01 -0400 Subject: [PATCH] Add tests for `getLabelForOpcode` --- test/unit/engine_runtime.js | 43 ++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/test/unit/engine_runtime.js b/test/unit/engine_runtime.js index 458f3884c..de43c37c6 100644 --- a/test/unit/engine_runtime.js +++ b/test/unit/engine_runtime.js @@ -50,7 +50,7 @@ test('monitorStateDoesNotEqual', t => { }); r.requestAddMonitor(prevMonitorState); r.requestUpdateMonitor(newMonitorDelta); - + t.equals(false, prevMonitorState.equals(r._monitorState.get(id))); t.equals(String(24), r._monitorState.get(id).get('value')); @@ -67,3 +67,44 @@ test('monitorStateDoesNotEqual', t => { t.end(); }); + +test('getLabelForOpcode', t => { + const r = new Runtime(); + + const fakeExtension = { + id: 'fakeExtension', + name: 'Fake Extension', + blocks: [ + { + info: { + opcode: 'foo', + json: {}, + text: 'Foo', + xml: '' + } + }, + { + info: { + opcode: 'foo_2', + json: {}, + text: 'Foo 2', + xml: '' + } + } + ] + }; + + r._blockInfo.push(fakeExtension); + + const result1 = r.getLabelForOpcode('fakeExtension_foo'); + t.type(result1.category, 'string'); + t.type(result1.label, 'string'); + t.equals(result1.label, 'Fake Extension: Foo'); + + const result2 = r.getLabelForOpcode('fakeExtension_foo_2'); + t.type(result2.category, 'string'); + t.type(result2.label, 'string'); + t.equals(result2.label, 'Fake Extension: Foo 2'); + + t.end(); +});