@@ -4,8 +4,8 @@ const uuidv1 = require('uuid/v1')
44const path = require ( 'path' )
55const NEWLINE = require ( 'os' ) . EOL
66const Builder = require ( '../../../src/parser/qnabuild/builder' ) . Builder
7- const luObject = require ( '../../../src/parser/lu/lu ' )
8- const luOptions = require ( '../../../src/parser/lu/luOptions ' )
7+ const qnaObject = require ( '../../../src/parser/lu/qna ' )
8+ const qnaOptions = require ( '../../../src/parser/lu/qnaOptions ' )
99const txtfile = require ( '../../../src/parser/lufile/read-text-file' ) ;
1010
1111const rootDir = path . join ( __dirname , './../../fixtures/testcases/import-resolver/qna-import-resolver' )
@@ -271,7 +271,7 @@ describe('builder: loadContents function can resolve import files with customize
271271 file . filePath = file . filePath . slice ( 0 , file . filePath . length - 3 ) + "en-us.qna"
272272 }
273273
274- luObjects . push ( new luObject ( txtfile . readSync ( file . filePath ) , new luOptions ( file . filePath , file . includeInCollate ) ) )
274+ luObjects . push ( new qnaObject ( txtfile . readSync ( file . filePath ) , new qnaOptions ( file . filePath , file . includeInCollate ) ) )
275275 }
276276 return luObjects
277277 } ;
@@ -290,4 +290,38 @@ describe('builder: loadContents function can resolve import files with customize
290290 assert . isTrue ( result . qnaContents [ 0 ] . content . includes (
291291 `!# @qna.pair.source = custom editorial${ NEWLINE } ${ NEWLINE } ## ? help${ NEWLINE } - could you help${ NEWLINE } ${ NEWLINE } \`\`\`markdown${ NEWLINE } help answer${ NEWLINE } \`\`\`${ NEWLINE } ${ NEWLINE } > !# @qna.pair.source = custom editorial${ NEWLINE } ${ NEWLINE } ## ? welcome${ NEWLINE } ${ NEWLINE } \`\`\`markdown${ NEWLINE } welcome here${ NEWLINE } \`\`\`${ NEWLINE } ${ NEWLINE } > !# @qna.pair.source = custom editorial${ NEWLINE } ${ NEWLINE } ## ? cancel${ NEWLINE } ${ NEWLINE } \`\`\`markdown${ NEWLINE } cancel the task${ NEWLINE } \`\`\`${ NEWLINE } ${ NEWLINE } > !# @qna.pair.source = custom editorial${ NEWLINE } ${ NEWLINE } ## ? stop${ NEWLINE } ${ NEWLINE } \`\`\`markdown${ NEWLINE } stop that${ NEWLINE } \`\`\`` ) )
292292 } )
293+ } )
294+
295+ describe ( 'builder: build function can catch relative endpoint exception successfully' , ( ) => {
296+ it ( 'should throw exception for non absolute endpoint' , async ( ) => {
297+ const builder = new Builder ( ( ) => { } )
298+ try {
299+ await builder . build (
300+ [ new qnaObject ( `# ? Greeting${ NEWLINE } \`\`\`${ NEWLINE } hello${ NEWLINE } \`\`\`` ) ] ,
301+ undefined ,
302+ 'f8c64e2a-1111-3a09-8f78-39d7adc76ec5' ,
303+ 'http:fsd'
304+ )
305+
306+ assert . fail ( "Relative endpoint exception is not thrown." )
307+ } catch ( e ) {
308+ assert . equal ( e . text , `Only absolute URLs are supported. "http:fsd" is not an absolute qnamaker endpoint URL.` )
309+ }
310+ } )
311+
312+ it ( 'should throw exception for non absolute endpoint' , async ( ) => {
313+ const builder = new Builder ( ( ) => { } )
314+ try {
315+ await builder . build (
316+ [ new qnaObject ( `# ? Greeting${ NEWLINE } \`\`\`${ NEWLINE } hello${ NEWLINE } \`\`\`` ) ] ,
317+ undefined ,
318+ 'f8c64e2a-1111-3a09-8f78-39d7adc76ec5' ,
319+ 'fsd'
320+ )
321+
322+ assert . fail ( "Relative endpoint exception is not thrown." )
323+ } catch ( e ) {
324+ assert . equal ( e . text , `Only absolute URLs are supported. "fsd" is not an absolute qnamaker endpoint URL.` )
325+ }
326+ } )
293327} )
0 commit comments