Skip to content

Commit

Permalink
update test case from @{} to ${}
Browse files Browse the repository at this point in the history
  • Loading branch information
zhixzhan committed Mar 2, 2020
1 parent a3e8aa0 commit c429fe3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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']));
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ 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']));
});
});

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'),
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -35,5 +35,6 @@
}
]
}
]
],
"generator": "Main.lg"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit c429fe3

Please sign in to comment.