From c429fe3658f6e392e554f398ba5f52f3feb20d1c Mon Sep 17 00:00:00 2001 From: zhixzhan Date: Mon, 2 Mar 2020 15:59:09 +0800 Subject: [PATCH] update test case from @{} to ${} --- .../lgUtils/models/LgTemplateRef.test.ts | 14 +++++++------- .../lgUtils/parsers/parseLgTemplateRef.test.ts | 12 ++++++------ .../samplebots/bot1/ComposerDialogs/Main.dialog | 15 ++++++++------- .../language-generation/__tests__/app.test.ts | 2 +- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/Composer/packages/lib/shared/__tests__/lgUtils/models/LgTemplateRef.test.ts b/Composer/packages/lib/shared/__tests__/lgUtils/models/LgTemplateRef.test.ts index af6d59ba5d..b708c60893 100644 --- a/Composer/packages/lib/shared/__tests__/lgUtils/models/LgTemplateRef.test.ts +++ b/Composer/packages/lib/shared/__tests__/lgUtils/models/LgTemplateRef.test.ts @@ -20,30 +20,30 @@ describe('LgTemplateRef#', () => { it('can output correct strings', () => { const a = new LgTemplateRef('a', undefined); - expect(a.toString()).toEqual('@{a()}'); + expect(a.toString()).toEqual('${a()}'); const b = new LgTemplateRef('b', []); - expect(b.toString()).toEqual('@{b()}'); + expect(b.toString()).toEqual('${b()}'); const c = new LgTemplateRef('c', ['1', '2']); - expect(c.toString()).toEqual('@{c(1,2)}'); + expect(c.toString()).toEqual('${c(1,2)}'); }); describe('parse()', () => { it('should return null when inputs are invalid', () => { expect(LgTemplateRef.parse('')).toEqual(null); expect(LgTemplateRef.parse('xxx')).toEqual(null); - expect(LgTemplateRef.parse('@{0}')).toEqual(null); + expect(LgTemplateRef.parse('${0}')).toEqual(null); }); it('should return LgTemplateRef when inputs are valid', () => { - const a = LgTemplateRef.parse('@{bfdactivity-123456()}'); + const a = LgTemplateRef.parse('${bfdactivity-123456()}'); expect(a).toEqual(new LgTemplateRef('bfdactivity-123456')); - const a2 = LgTemplateRef.parse('@{bfdactivity-123456()}'); + const a2 = LgTemplateRef.parse('${bfdactivity-123456()}'); expect(a2).toEqual(new LgTemplateRef('bfdactivity-123456')); - const b = LgTemplateRef.parse('@{greeting(1,2)}'); + const b = LgTemplateRef.parse('${greeting(1,2)}'); expect(b).toEqual(new LgTemplateRef('greeting', ['1', '2'])); }); }); diff --git a/Composer/packages/lib/shared/__tests__/lgUtils/parsers/parseLgTemplateRef.test.ts b/Composer/packages/lib/shared/__tests__/lgUtils/parsers/parseLgTemplateRef.test.ts index cc983fdce1..7ecbe397be 100644 --- a/Composer/packages/lib/shared/__tests__/lgUtils/parsers/parseLgTemplateRef.test.ts +++ b/Composer/packages/lib/shared/__tests__/lgUtils/parsers/parseLgTemplateRef.test.ts @@ -8,15 +8,15 @@ describe('parseLgTemplateRef', () => { it('should return null when inputs are invalid', () => { expect(parseLgTemplateRef('')).toEqual(null); expect(parseLgTemplateRef('xxx')).toEqual(null); - expect(parseLgTemplateRef('@{0}')).toEqual(null); - expect(parseLgTemplateRef('hi, @{greeting()}. @{greeting()}')).toEqual(null); + expect(parseLgTemplateRef('${0}')).toEqual(null); + expect(parseLgTemplateRef('hi, ${greeting()}. ${greeting()}')).toEqual(null); }); it('should return LgTemplateRef when inputs are valid', () => { - const a = parseLgTemplateRef('@{bfdactivity-123456()}'); + const a = parseLgTemplateRef('${bfdactivity-123456()}'); expect(a).toEqual(new LgTemplateRef('bfdactivity-123456')); - const b = parseLgTemplateRef('@{greeting(1,2)}'); + const b = parseLgTemplateRef('${greeting(1,2)}'); expect(b).toEqual(new LgTemplateRef('greeting', ['1', '2'])); }); }); @@ -24,8 +24,8 @@ describe('parseLgTemplateRef', () => { describe('extractLgTemplateRefs', () => { it('can extract lg refs from input string', () => { expect(extractLgTemplateRefs('Hi')).toEqual([]); - expect(extractLgTemplateRefs('@{bfdactivity-123456()}')).toEqual([new LgTemplateRef('bfdactivity-123456')]); - expect(extractLgTemplateRefs(`-@{Greeting()}, I'm a fancy bot, @{Bye()}`)).toEqual([ + expect(extractLgTemplateRefs('${bfdactivity-123456()}')).toEqual([new LgTemplateRef('bfdactivity-123456')]); + expect(extractLgTemplateRefs(`-\${Greeting()}, I'm a fancy bot, \${Bye()}`)).toEqual([ new LgTemplateRef('Greeting'), new LgTemplateRef('Bye'), ]); diff --git a/Composer/packages/server/__tests__/mocks/samplebots/bot1/ComposerDialogs/Main.dialog b/Composer/packages/server/__tests__/mocks/samplebots/bot1/ComposerDialogs/Main.dialog index 466beb28e8..54f8b4ef1d 100644 --- a/Composer/packages/server/__tests__/mocks/samplebots/bot1/ComposerDialogs/Main.dialog +++ b/Composer/packages/server/__tests__/mocks/samplebots/bot1/ComposerDialogs/Main.dialog @@ -3,27 +3,27 @@ "steps": [ { "$type": "Microsoft.TextInput", - "prompt": "@{hello()} I'm a ToDo bot" + "prompt": "${hello()} I'm a ToDo bot" }, { "$type": "Microsoft.SendActivity", - "activity": "@{bye()} See you again" + "activity": "${bye()} See you again" }, { "$type": "Microsoft.SendActivity", - "activity": "@{bye()} bye bye again" + "activity": "${bye()} bye bye again" }, { "$type": "Microsoft.SendActivity", - "activity": "@{ShowImage(dialog.attachments[0].contentUrl, dialog.attachments[0].contentType)}" + "activity": "${ShowImage(dialog.attachments[0].contentUrl, dialog.attachments[0].contentType)}" }, { "$type": "Microsoft.SendActivity", - "activity": "You entered: @{user.date[0].value}" + "activity": "You entered: ${user.date[0].value}" }, { "$type": "Microsoft.TextInput", - "activity": "@{bye3()} See you again" + "activity": "${bye3()} See you again" }, { "$type": "Microsoft.OnIntent", @@ -35,5 +35,6 @@ } ] } - ] + ], + "generator": "Main.lg" } diff --git a/Composer/packages/tools/language-servers/language-generation/__tests__/app.test.ts b/Composer/packages/tools/language-servers/language-generation/__tests__/app.test.ts index 980c0de87d..341ea74f63 100644 --- a/Composer/packages/tools/language-servers/language-generation/__tests__/app.test.ts +++ b/Composer/packages/tools/language-servers/language-generation/__tests__/app.test.ts @@ -120,7 +120,7 @@ describe('lg lsp server', () => { it('didChange', async () => { // didChange - const newContent = `${content}-@{G\\r\\n`; + const newContent = `${content}-\${G\\r\\n`; const payload = `{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"inmemory://model/1","version":3},"contentChanges":[{"text": "${newContent}"}]}}`; await send(payload, [ response => {