|
1 | | -import './viewer/A2J_Types' |
2 | | -// import './viewer/A2J_Prefs' |
3 | | -// import './viewer/A2J_SharedSus' |
4 | | -// import './viewer/A2J_Logic' |
5 | 1 | import 'jquery' |
6 | | -import './A2J_Tabs' |
7 | | - |
8 | 2 | import { assert } from 'chai' |
9 | 3 | import 'steal-mocha' |
10 | | -describe('vcGatherUsage', function () { |
11 | | - it('gathers usage on Page, Field, and Button level property values using variables', function () { |
12 | | - const usageTestPage = new window.TPage() |
13 | | - usageTestPage.fields = [new window.TField()] |
14 | | - usageTestPage.buttons = [new window.TButton()] |
| 4 | +import { vcGatherUsage, findMacroMatches } from './vcGatherUsage' |
| 5 | + |
| 6 | +describe('findMacroMatches', function () { |
| 7 | + it.only('returns matches based on A2J Macro Syntax', function () { |
| 8 | + const matches = findMacroMatches('Hello %%[Client First Name TE]%%, welcome to the interview!', 'Client First Name TE') |
| 9 | + const expectedResult = [ '[Client First Name TE]' ] |
| 10 | + console.log(matches) |
| 11 | + assert.deepEqual(matches, expectedResult, 'should find one match') |
| 12 | + }) |
| 13 | +}) |
15 | 14 |
|
16 | | - window.gGuide.pages = { usageTestPage } |
| 15 | +//Copy above function for other two branches in findMatches, make fail, go from there |
17 | 16 |
|
18 | | - const testProps = { |
19 | | - page: [ |
20 | | - { key: 'name', type: 'regex', display: 'Page Name' }, |
21 | | - { key: 'text', type: 'regex', display: 'Question Text' }, |
22 | | - { key: 'repeatVar', type: 'string', display: 'Counting Variable' }, |
23 | | - { key: 'outerLoopVar', type: 'string', display: 'Outer Loop Variable' }, |
24 | | - { key: 'learn', type: 'regex', display: 'LearnMore Prompt' }, |
25 | | - { key: 'help', type: 'regex', display: 'LearnMore Response' }, |
26 | | - { key: 'helpReader', type: 'regex', display: 'Video Transcript' }, |
27 | | - { key: 'codeBefore', type: 'logic', display: 'Before Logic' }, |
28 | | - { key: 'codeAfter', type: 'logic', display: 'After Logic' } |
29 | | - ], |
30 | | - fields: [ |
31 | | - { key: 'label', type: 'regex', display: 'Field Label' }, |
32 | | - { key: 'name', type: 'string', display: 'Field Variable' }, |
33 | | - { key: 'value', type: 'regex', display: 'Field Default Value' }, |
34 | | - { key: 'invalidPrompt', type: 'regex', display: 'Field Custom Invalid Prompt' }, |
35 | | - { key: 'sample', type: 'regex', display: 'Field Sample Value' } |
36 | | - ], |
37 | | - buttons: [ |
38 | | - { key: 'label', type: 'regex', display: 'Button Label' }, |
39 | | - { key: 'name', type: 'string', display: 'Button Variable Name' }, |
40 | | - { key: 'value', type: 'regex', display: 'Button Default Value' }, |
41 | | - { key: 'repeatVar', type: 'string', display: 'Button Counting Variable' }, |
42 | | - { key: 'url', type: 'regex', display: 'Button URL' } |
43 | | - ] |
44 | | - } |
45 | 17 |
|
46 | | - const setTestProps = (targetMap, propsToSet) => { |
47 | | - for (const entry of propsToSet) { |
48 | | - const prop = entry.key |
49 | | - if (entry.type === 'regex') { |
50 | | - targetMap[prop] = 'macro style %%[Number NU]%%' |
51 | | - } else if (entry.type === 'logic') { |
52 | | - targetMap[prop] = 'SET [Number NU] TO 1' |
53 | | - } else { // direct var set |
54 | | - targetMap[prop] = 'Number NU' |
55 | | - } |
56 | | - } |
57 | | - } |
58 | | - setTestProps(usageTestPage, testProps.page) |
59 | | - setTestProps(usageTestPage.fields[0], testProps.fields) |
60 | | - setTestProps(usageTestPage.buttons[0], testProps.buttons) |
| 18 | +// describe('vcGatherUsage', function () { |
| 19 | +// let usageTestPage |
| 20 | +// const testProps = { |
| 21 | +// page: [ |
| 22 | +// { key: 'name', type: 'regex', display: 'Page Name' }, |
| 23 | +// { key: 'text', type: 'regex', display: 'Question Text' }, |
| 24 | +// { key: 'repeatVar', type: 'string', display: 'Counting Variable' }, |
| 25 | +// { key: 'outerLoopVar', type: 'string', display: 'Outer Loop Variable' }, |
| 26 | +// { key: 'learn', type: 'regex', display: 'LearnMore Prompt' }, |
| 27 | +// { key: 'help', type: 'regex', display: 'LearnMore Response' }, |
| 28 | +// { key: 'helpReader', type: 'regex', display: 'Video Transcript' }, |
| 29 | +// { key: 'codeBefore', type: 'logic', display: 'Before Logic' }, |
| 30 | +// { key: 'codeAfter', type: 'logic', display: 'After Logic' } |
| 31 | +// ], |
| 32 | +// fields: [ |
| 33 | +// { key: 'label', type: 'regex', display: 'Field Label' }, |
| 34 | +// { key: 'name', type: 'string', display: 'Field Variable' }, |
| 35 | +// { key: 'value', type: 'regex', display: 'Field Default Value' }, |
| 36 | +// { key: 'invalidPrompt', type: 'regex', display: 'Field Custom Invalid Prompt' }, |
| 37 | +// { key: 'sample', type: 'regex', display: 'Field Sample Value' } |
| 38 | +// ], |
| 39 | +// buttons: [ |
| 40 | +// { key: 'label', type: 'regex', display: 'Button Label' }, |
| 41 | +// { key: 'name', type: 'string', display: 'Button Variable Name' }, |
| 42 | +// { key: 'value', type: 'regex', display: 'Button Default Value' }, |
| 43 | +// { key: 'repeatVar', type: 'string', display: 'Button Counting Variable' }, |
| 44 | +// { key: 'url', type: 'regex', display: 'Button URL' } |
| 45 | +// ] |
| 46 | +// } |
61 | 47 |
|
62 | | - const foundMessage = window.vcGatherUsage('Number NU') |
63 | | - // if found, `display value` will be in foundMessage for each entry |
64 | | - for (const entry of testProps.page) { |
65 | | - const usedInPage = foundMessage.indexOf(entry.display) !== -1 |
66 | | - assert.isTrue(usedInPage, `should find Number NU usage in page.${entry.key} by displaying ${entry.display} in returned foundMessage html`) |
67 | | - } |
68 | | - for (const entry of testProps.fields) { |
69 | | - const usedInField = foundMessage.indexOf(entry.display) !== -1 |
70 | | - assert.isTrue(usedInField, `should find Number NU usage in field.${entry.key} by displaying ${entry.display} in returned foundMessage html`) |
71 | | - } |
72 | | - for (const entry of testProps.buttons) { |
73 | | - const usedInButton = foundMessage.indexOf(entry.display) !== -1 |
74 | | - assert.isTrue(usedInButton, `should find Number NU usage in button.${entry.key} by displaying ${entry.display} in returned foundMessage html`) |
75 | | - } |
76 | | - }) |
77 | | -}) |
| 48 | +// beforeEach(() => { |
| 49 | +// usageTestPage = new window.TPage() |
| 50 | +// usageTestPage.fields = [new window.TField()] |
| 51 | +// usageTestPage.buttons = [new window.TButton()] |
| 52 | + |
| 53 | +// const gGuide = new window.TGuide() |
| 54 | +// window.gGuide = gGuide |
| 55 | +// window.gGuide.pages = { usageTestPage } |
| 56 | +// }) |
| 57 | + |
| 58 | +// afterEach(() => { |
| 59 | +// window.gGuide = null |
| 60 | +// }) |
| 61 | + |
| 62 | +// it('gathers usage on Page, Field, and Button level property values using variables', function () { |
| 63 | +// const setTestProps = (targetMap, propsToSet) => { |
| 64 | +// for (const entry of propsToSet) { |
| 65 | +// const prop = entry.key |
| 66 | +// if (entry.type === 'regex') { |
| 67 | +// targetMap[prop] = 'macro style %%[Number NU]%%' |
| 68 | +// } else if (entry.type === 'logic') { |
| 69 | +// targetMap[prop] = 'SET [Number NU] TO 1' |
| 70 | +// } else { // direct var set |
| 71 | +// targetMap[prop] = 'Number NU' |
| 72 | +// } |
| 73 | +// } |
| 74 | +// } |
| 75 | +// setTestProps(usageTestPage, testProps.page) |
| 76 | +// setTestProps(usageTestPage.fields[0], testProps.fields) |
| 77 | +// setTestProps(usageTestPage.buttons[0], testProps.buttons) |
| 78 | + |
| 79 | +// const foundMessage = vcGatherUsage('Number NU') |
| 80 | +// // if found, `display value` will be in foundMessage for each entry |
| 81 | +// for (const entry of testProps.page) { |
| 82 | +// const usedInPage = foundMessage.indexOf(entry.display) !== -1 |
| 83 | +// assert.isTrue(usedInPage, `should find Number NU usage in page.${entry.key} by displaying ${entry.display} in returned foundMessage html`) |
| 84 | +// } |
| 85 | +// for (const entry of testProps.fields) { |
| 86 | +// const usedInField = foundMessage.indexOf(entry.display) !== -1 |
| 87 | +// assert.isTrue(usedInField, `should find Number NU usage in field.${entry.key} by displaying ${entry.display} in returned foundMessage html`) |
| 88 | +// } |
| 89 | +// for (const entry of testProps.buttons) { |
| 90 | +// const usedInButton = foundMessage.indexOf(entry.display) !== -1 |
| 91 | +// assert.isTrue(usedInButton, `should find Number NU usage in button.${entry.key} by displaying ${entry.display} in returned foundMessage html`) |
| 92 | +// } |
| 93 | +// }) |
| 94 | + |
| 95 | +// it('gathers explicit usage on Page, Field, and Button level property values using variables', function () { |
| 96 | +// const setTestProps = (targetMap, propsToSet) => { |
| 97 | +// for (const entry of propsToSet) { |
| 98 | +// const prop = entry.key |
| 99 | +// if (entry.type === 'regex') { |
| 100 | +// targetMap[prop] = 'macro style %%[Number NU]%%' |
| 101 | +// } else if (entry.type === 'logic') { |
| 102 | +// targetMap[prop] = 'SET [Number123 NU] TO 1' |
| 103 | +// } else { // direct var set |
| 104 | +// targetMap[prop] = 'Number foo NU' |
| 105 | +// } |
| 106 | +// } |
| 107 | +// } |
| 108 | +// setTestProps(usageTestPage, testProps.page) |
| 109 | +// setTestProps(usageTestPage.fields[0], testProps.fields) |
| 110 | +// setTestProps(usageTestPage.buttons[0], testProps.buttons) |
| 111 | + |
| 112 | +// const foundMessage = vcGatherUsage('Number NU') |
| 113 | +// // if found, `display value` will be in foundMessage for each entry |
| 114 | +// for (const entry of testProps.page) { |
| 115 | +// const usedInPage = foundMessage.indexOf(entry.display) !== -1 |
| 116 | +// assert.isTrue(usedInPage, `should find Number NU usage in page.${entry.key} by displaying ${entry.display} in returned foundMessage html`) |
| 117 | +// } |
| 118 | +// for (const entry of testProps.fields) { |
| 119 | +// const usedInField = foundMessage.indexOf(entry.display) !== -1 |
| 120 | +// assert.isTrue(usedInField, `should find Number NU usage in field.${entry.key} by displaying ${entry.display} in returned foundMessage html`) |
| 121 | +// } |
| 122 | +// for (const entry of testProps.buttons) { |
| 123 | +// const usedInButton = foundMessage.indexOf(entry.display) !== -1 |
| 124 | +// assert.isTrue(usedInButton, `should find Number NU usage in button.${entry.key} by displaying ${entry.display} in returned foundMessage html`) |
| 125 | +// } |
| 126 | +// }) |
| 127 | +// }) |
0 commit comments