@@ -1730,5 +1730,83 @@ suite('Auto Completion Tests', () => {
1730
1730
) ;
1731
1731
} ) ;
1732
1732
} ) ;
1733
+ describe ( 'Array completion' , ( ) => {
1734
+ it ( 'Simple array object completion with "-" without any item' , async ( ) => {
1735
+ const schema = require ( path . join ( __dirname , './fixtures/testArrayCompletionSchema.json' ) ) ;
1736
+ languageService . addSchema ( SCHEMA_ID , schema ) ;
1737
+ const content = 'test_simpleArrayObject:\n -' ;
1738
+ const completion = parseSetup ( content , content . length ) ;
1739
+ completion . then ( function ( result ) {
1740
+ assert . equal ( result . items . length , 1 ) ;
1741
+ assert . equal ( result . items [ 0 ] . label , '- (array item)' ) ;
1742
+ } ) ;
1743
+ } ) ;
1744
+
1745
+ it ( 'Simple array object completion without "-" after array item' , async ( ) => {
1746
+ const schema = require ( path . join ( __dirname , './fixtures/testArrayCompletionSchema.json' ) ) ;
1747
+ languageService . addSchema ( SCHEMA_ID , schema ) ;
1748
+ const content = 'test_simpleArrayObject:\n - obj1:\n name: 1\n ' ;
1749
+ const completion = parseSetup ( content , content . length ) ;
1750
+ completion . then ( function ( result ) {
1751
+ assert . equal ( result . items . length , 1 ) ;
1752
+ assert . equal ( result . items [ 0 ] . label , '- (array item)' ) ;
1753
+ } ) ;
1754
+ } ) ;
1755
+
1756
+ it ( 'Simple array object completion with "-" after array item' , async ( ) => {
1757
+ const schema = require ( path . join ( __dirname , './fixtures/testArrayCompletionSchema.json' ) ) ;
1758
+ languageService . addSchema ( SCHEMA_ID , schema ) ;
1759
+ const content = 'test_simpleArrayObject:\n - obj1:\n name: 1\n -' ;
1760
+ const completion = parseSetup ( content , content . length ) ;
1761
+ completion . then ( function ( result ) {
1762
+ assert . equal ( result . items . length , 1 ) ;
1763
+ assert . equal ( result . items [ 0 ] . label , '- (array item)' ) ;
1764
+ } ) ;
1765
+ } ) ;
1766
+
1767
+ it ( 'Array anyOf two objects completion with "- " without any item' , async ( ) => {
1768
+ const schema = require ( path . join ( __dirname , './fixtures/testArrayCompletionSchema.json' ) ) ;
1769
+ languageService . addSchema ( SCHEMA_ID , schema ) ;
1770
+ const content = 'test_array_anyOf_2objects:\n - ' ;
1771
+ const completion = parseSetup ( content , content . length ) ;
1772
+ completion . then ( function ( result ) {
1773
+ assert . equal ( result . items . length , 2 ) ;
1774
+ assert . equal ( result . items [ 0 ] . label , 'obj1' ) ;
1775
+ } ) ;
1776
+ } ) ;
1777
+
1778
+ it ( 'Array anyOf two objects completion with "-" without any item' , async ( ) => {
1779
+ const schema = require ( path . join ( __dirname , './fixtures/testArrayCompletionSchema.json' ) ) ;
1780
+ languageService . addSchema ( SCHEMA_ID , schema ) ;
1781
+ const content = 'test_array_anyOf_2objects:\n -' ;
1782
+ const completion = parseSetup ( content , content . length ) ;
1783
+ completion . then ( function ( result ) {
1784
+ assert . equal ( result . items . length , 2 ) ;
1785
+ assert . equal ( result . items [ 0 ] . label , '- (array item) 1' ) ;
1786
+ } ) ;
1787
+ } ) ;
1788
+
1789
+ it ( 'Array anyOf two objects completion without "-" after array item' , async ( ) => {
1790
+ const schema = require ( path . join ( __dirname , './fixtures/testArrayCompletionSchema.json' ) ) ;
1791
+ languageService . addSchema ( SCHEMA_ID , schema ) ;
1792
+ const content = 'test_array_anyOf_2objects:\n - obj1:\n name: 1\n ' ;
1793
+ const completion = parseSetup ( content , content . length ) ;
1794
+ completion . then ( function ( result ) {
1795
+ assert . equal ( result . items . length , 2 ) ;
1796
+ assert . equal ( result . items [ 0 ] . label , '- (array item) 1' ) ;
1797
+ } ) ;
1798
+ } ) ;
1799
+
1800
+ it ( 'Array anyOf two objects completion with "-" after array item' , async ( ) => {
1801
+ const schema = require ( path . join ( __dirname , './fixtures/testArrayCompletionSchema.json' ) ) ;
1802
+ languageService . addSchema ( SCHEMA_ID , schema ) ;
1803
+ const content = 'test_array_anyOf_2objects:\n - obj1:\n name: 1\n -' ;
1804
+ const completion = parseSetup ( content , content . length ) ;
1805
+ completion . then ( function ( result ) {
1806
+ assert . equal ( result . items . length , 2 ) ;
1807
+ assert . equal ( result . items [ 0 ] . label , '- (array item) 1' ) ;
1808
+ } ) ;
1809
+ } ) ;
1810
+ } ) ;
1733
1811
} ) ;
1734
1812
} ) ;
0 commit comments