@@ -7,7 +7,8 @@ const ARANGO_VERSION = Number(process.env.ARANGO_VERSION || 30500);
77const describe35 = ARANGO_VERSION >= 30500 ? describe : describe . skip ;
88
99describe35 ( "Accessing analyzers" , function ( ) {
10- let name = `testdb_${ Date . now ( ) } ` ;
10+ const builtins : string [ ] = [ ] ;
11+ const name = `testdb_${ Date . now ( ) } ` ;
1112 let db : Database ;
1213 before ( async ( ) => {
1314 db = new Database ( {
@@ -16,6 +17,8 @@ describe35("Accessing analyzers", function() {
1617 } ) ;
1718 await db . createDatabase ( name ) ;
1819 db . useDatabase ( name ) ;
20+ builtins . push ( ...( await db . listAnalyzers ( ) ) . map ( a => a . name ) ) ;
21+ expect ( builtins ) . not . to . have . length ( 0 ) ;
1922 } ) ;
2023 after ( async ( ) => {
2124 try {
@@ -36,42 +39,53 @@ describe35("Accessing analyzers", function() {
3639 } ) ;
3740 } ) ;
3841 describe ( "database.listAnalyzers" , ( ) => {
39- let analyzerNames = range ( 4 ) . map ( i => `a_${ Date . now ( ) } _${ i } ` ) ;
42+ const analyzerNames = range ( 4 ) . map ( i => `${ name } ::a_${ Date . now ( ) } _${ i } ` ) ;
43+ let allNames : string [ ] ;
4044 before ( async ( ) => {
45+ allNames = [ ...builtins , ...analyzerNames ] . sort ( ) ;
4146 await Promise . all (
4247 analyzerNames . map ( name =>
43- db . analyzer ( name ) . create ( { type : "identity" } )
48+ db . analyzer ( name . replace ( / ^ [ ^ : ] + : : / , "" ) ) . create ( { type : "identity" } )
4449 )
4550 ) ;
4651 } ) ;
4752 after ( async ( ) => {
48- await Promise . all ( analyzerNames . map ( name => db . analyzer ( name ) . drop ( ) ) ) ;
53+ await Promise . all (
54+ analyzerNames . map ( name =>
55+ db . analyzer ( name . replace ( / ^ [ ^ : ] + : : / , "" ) ) . drop ( )
56+ )
57+ ) ;
4958 } ) ;
5059 it ( "fetches information about all analyzers" , async ( ) => {
5160 const analyzers = await db . listAnalyzers ( ) ;
52- expect ( analyzers . length ) . to . equal ( analyzerNames . length ) ;
53- expect ( analyzers . map ( a => a . name ) . sort ( ) ) . to . eql ( analyzerNames ) ;
61+ console . log ( analyzers . map ( a => a . name ) , allNames ) ;
62+ expect ( analyzers . map ( a => a . name ) . sort ( ) ) . to . eql ( allNames ) ;
5463 } ) ;
5564 } ) ;
5665 describe ( "database.analyzers" , ( ) => {
57- let analyzerNames = range ( 4 ) . map ( i => `a_${ Date . now ( ) } _${ i } ` ) ;
66+ const analyzerNames = range ( 4 ) . map ( i => `${ name } ::a_${ Date . now ( ) } _${ i } ` ) ;
67+ let allNames : string [ ] ;
5868 before ( async ( ) => {
69+ allNames = [ ...builtins , ...analyzerNames ] . sort ( ) ;
5970 await Promise . all (
6071 analyzerNames . map ( name =>
61- db . analyzer ( name ) . create ( { type : "identity" } )
72+ db . analyzer ( name . replace ( / ^ [ ^ : ] + : : / , "" ) ) . create ( { type : "identity" } )
6273 )
6374 ) ;
6475 } ) ;
6576 after ( async ( ) => {
66- await Promise . all ( analyzerNames . map ( name => db . analyzer ( name ) . drop ( ) ) ) ;
77+ await Promise . all (
78+ analyzerNames . map ( name =>
79+ db . analyzer ( name . replace ( / ^ [ ^ : ] + : : / , "" ) ) . drop ( )
80+ )
81+ ) ;
6782 } ) ;
6883 it ( "creates ArangoAnalyzer instances" , async ( ) => {
6984 const analyzers = await db . analyzers ( ) ;
70- let arangoAnalyzers = analyzers
71- . filter ( a => a instanceof ArangoAnalyzer )
72- . sort ( ) ;
73- expect ( arangoAnalyzers . length ) . to . equal ( analyzerNames . length ) ;
74- expect ( arangoAnalyzers . map ( a => a . name ) . sort ( ) ) . to . eql ( analyzerNames ) ;
85+ for ( const analyzer of analyzers ) {
86+ expect ( analyzer ) . to . be . instanceOf ( ArangoAnalyzer ) ;
87+ }
88+ expect ( analyzers . map ( a => a . name ) . sort ( ) ) . to . eql ( allNames ) ;
7589 } ) ;
7690 } ) ;
7791} ) ;
0 commit comments