| 
1 |  | -import { assert } from 'console';  | 
2 |  | -import weaviate, {  | 
3 |  | -  WeaviateClient,  | 
4 |  | -} from '..';  | 
 | 1 | +import weaviate, { WeaviateClient } from '..';  | 
5 | 2 | import { requireAtLeast } from '../../test/version';  | 
6 | 3 | import { Alias } from './types';  | 
7 | 4 | 
 
  | 
8 |  | -requireAtLeast(1, 32, 0).describe("manages collection aliases", () => {  | 
 | 5 | +requireAtLeast(1, 32, 0).describe('manages collection aliases', () => {  | 
9 | 6 |   let client: WeaviateClient;  | 
10 |  | -  const collectionsWithAliases = ["PaulHewson", "GeorgeBarnes", "ColsonBaker"];  | 
 | 7 | +  const collectionsWithAliases = ['PaulHewson', 'GeorgeBarnes', 'ColsonBaker'];  | 
11 | 8 | 
 
  | 
12 | 9 |   beforeAll(async () => {  | 
13 | 10 |     client = await weaviate.connectToLocal();  | 
14 | 11 |     await Promise.all(collectionsWithAliases.map(client.collections.delete));  | 
15 |  | -    await Promise.all(collectionsWithAliases.map(name => client.collections.create({ name })));  | 
 | 12 | +    await Promise.all(collectionsWithAliases.map((name) => client.collections.create({ name })));  | 
16 | 13 |   });  | 
17 | 14 | 
 
  | 
18 |  | -  it("should create alias", () => {  | 
 | 15 | +  it('should create alias', () => {  | 
19 | 16 |     return Promise.all([  | 
20 |  | -      client.alias.create({ collection: "PaulHewson", alias: "Bono" }),  | 
21 |  | -      client.alias.create({ collection: "GeorgeBarnes", alias: "MachineGunKelly" }),  | 
 | 17 | +      client.alias.create({ collection: 'PaulHewson', alias: 'Bono' }),  | 
 | 18 | +      client.alias.create({ collection: 'GeorgeBarnes', alias: 'MachineGunKelly' }),  | 
22 | 19 |     ])  | 
23 | 20 |       .then(() => client.alias.listAll())  | 
24 |  | -      .then(aliases => {  | 
 | 21 | +      .then((aliases) => {  | 
25 | 22 |         expect(aliases).not.toBeUndefined();  | 
26 | 23 |         expect(aliases).toHaveLength(2);  | 
27 | 24 |         expect(aliases).toEqual<Alias[]>([  | 
28 |  | -          { collection: "PaulHewson", alias: "Bono" },  | 
29 |  | -          { collection: "GeorgeBarnes", alias: "MachineGunKelly" },  | 
 | 25 | +          { collection: 'PaulHewson', alias: 'Bono' },  | 
 | 26 | +          { collection: 'GeorgeBarnes', alias: 'MachineGunKelly' },  | 
30 | 27 |         ]);  | 
31 | 28 |       });  | 
32 |  | -  })  | 
 | 29 | +  });  | 
33 | 30 | 
 
  | 
34 |  | -  it("should update alias", () => {  | 
35 |  | -    return client.alias.update({ alias: "MachineGunKelly", newTargetCollection: "ColsonBaker" })  | 
36 |  | -      .then(() => client.alias.get("MachineGunKelly"))  | 
37 |  | -      .then(alias => {  | 
38 |  | -        expect(alias.collection).toEqual("ColsonBaker");  | 
39 |  | -      })  | 
40 |  | -  })  | 
 | 31 | +  it('should update alias', () => {  | 
 | 32 | +    return client.alias  | 
 | 33 | +      .update({ alias: 'MachineGunKelly', newTargetCollection: 'ColsonBaker' })  | 
 | 34 | +      .then(() => client.alias.get('MachineGunKelly'))  | 
 | 35 | +      .then((alias) => {  | 
 | 36 | +        expect(alias.collection).toEqual('ColsonBaker');  | 
 | 37 | +      });  | 
 | 38 | +  });  | 
41 | 39 | 
 
  | 
42 |  | -  it("should delete alias Bono", () => {  | 
43 |  | -    return client.alias.delete("Bono")  | 
44 |  | -      .then(() => client.alias.listAll("PaulHewson"))  | 
45 |  | -      .then(aliases => expect(aliases).toEqual([]));  | 
46 |  | -  })  | 
 | 40 | +  it('should delete alias Bono', () => {  | 
 | 41 | +    return client.alias  | 
 | 42 | +      .delete('Bono')  | 
 | 43 | +      .then(() => client.alias.listAll('PaulHewson'))  | 
 | 44 | +      .then((aliases) => expect(aliases).toEqual([]));  | 
 | 45 | +  });  | 
47 | 46 | 
 
  | 
48 |  | -  it("should delete alias MachineGunKelly", () => {  | 
49 |  | -    return client.alias.delete("MachineGunKelly")  | 
50 |  | -      .then(() => client.alias.listAll("ColsonBaker"))  | 
51 |  | -      .then(aliases => expect(aliases).toEqual([]));  | 
52 |  | -  })  | 
53 |  | -})  | 
 | 47 | +  it('should delete alias MachineGunKelly', () => {  | 
 | 48 | +    return client.alias  | 
 | 49 | +      .delete('MachineGunKelly')  | 
 | 50 | +      .then(() => client.alias.listAll('ColsonBaker'))  | 
 | 51 | +      .then((aliases) => expect(aliases).toEqual([]));  | 
 | 52 | +  });  | 
 | 53 | +});  | 
0 commit comments