-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/npm_and_yarn/express-4.19.2
- Loading branch information
Showing
11 changed files
with
216 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
EmployeeId,Name,Title,Team,Manager | ||
001,Destiny Norris,Marketing Manager,Marketing, | ||
002,Darci Prosser,Creative Writer,Marketing,001 | ||
003,Alanah Bloggs,Frontend Developer,IT,004 | ||
004,Fabian Dalby,Web Service Manager,IT, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export const mock_employees_limit_1 = [ | ||
{ | ||
"Manager": { | ||
"@type": "xsd:string", | ||
"@value": "", | ||
}, | ||
"Name": { | ||
"@type": "xsd:string", | ||
"@value": "Destiny Norris", | ||
}, | ||
"Title": { | ||
"@type": "xsd:string", | ||
"@value": "Marketing Manager", | ||
}, | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
//@ts-check | ||
import { describe, expect, test, beforeAll } from '@jest/globals'; | ||
import { WOQLClient, WOQL } from '../index.js'; | ||
import { DbDetails, DocParamsGet } from '../dist/typescript/lib/typedef.js'; | ||
import schemaJson from './persons_schema' | ||
import { mock_employees_limit_1 } from './data/employees_limit1'; | ||
import fs from 'fs'; | ||
|
||
let client: WOQLClient //= new WOQLClient('http://localhost:6363'); | ||
|
||
beforeAll(() => { | ||
client = new WOQLClient("http://localhost:6363", { user: 'admin', organization: 'admin', key: 'root' }) | ||
}); | ||
|
||
const db01 = 'db__test_woql'; | ||
|
||
describe('Create a database, schema and insert data', () => { | ||
test('Create a database', async () => { | ||
const dbObj: DbDetails = { label: db01, comment: 'add db', schema: true } | ||
const result = await client.createDatabase(db01, dbObj); | ||
//woqlClient return only the data no status | ||
expect(result["@type"]).toEqual("api:DbCreateResponse"); | ||
expect(result["api:status"]).toEqual("api:success"); | ||
}); | ||
|
||
test('Create a schema', async () => { | ||
const result = await client.addDocument(schemaJson, { graph_type: "schema", full_replace: true }); | ||
expect(result).toStrictEqual(["Child", "Person", "Parent"]); | ||
}) | ||
|
||
test('Query with CSV upload from file', async () => { | ||
const query = WOQL.limit(1).and( | ||
WOQL.get( | ||
WOQL.as('Name', 'v:Name') | ||
.as('Manager', 'v:Manager') | ||
.as('Title', 'v:Title'), | ||
WOQL.post("./integration_tests/data/employees.csv") | ||
), | ||
); | ||
const result = await client.query(query, undefined, undefined, undefined, undefined,); | ||
expect(result?.bindings).toStrictEqual(mock_employees_limit_1); | ||
}); | ||
|
||
test('Query with CSV upload as resource attachment', async () => { | ||
const query = WOQL.limit(1).and( | ||
WOQL.get( | ||
WOQL.as('Name', 'v:Name') | ||
.as('Manager', 'v:Manager') | ||
.as('Title', 'v:Title'), | ||
WOQL.post("employees.csv") | ||
), | ||
); | ||
const data = fs.readFileSync('./integration_tests/data/employees.csv'); | ||
const result = await client.query(query, undefined, undefined, undefined, undefined, [{ | ||
filename: "employees.csv", | ||
data: data, | ||
}]); | ||
expect(result?.bindings).toStrictEqual(mock_employees_limit_1); | ||
}); | ||
|
||
test('Get branches from the server (only main)', async () => { | ||
const result = await client.getBranches(); | ||
expect(result.main["@id"]).toStrictEqual("Branch/main"); | ||
expect(Object.keys(result)).toStrictEqual(["main"]); | ||
}); | ||
|
||
test('Get commits log from the server', async () => { | ||
const result = await client.getCommitsLog(); | ||
expect(result.length).toStrictEqual(1); | ||
expect(result[0]["@type"]).toStrictEqual("ValidCommit"); | ||
}); | ||
|
||
test('Get prefixes from the server', async () => { | ||
const result = await client.getPrefixes(); | ||
expect(result).toStrictEqual({"@base": "terminusdb:///data/", "@schema": "terminusdb:///schema#", "@type": "Context"}); | ||
}); | ||
|
||
test('Get userOrganisations from the server', async () => { | ||
const result = (await client.getUserOrganizations()).filter(org => org["@id"] === "Organization/admin"); | ||
expect(result[0]["@id"]).toStrictEqual("Organization/admin"); | ||
}); | ||
|
||
test('Delete a database', async () => { | ||
const result = await client.deleteDatabase(db01); | ||
expect(result).toStrictEqual({ '@type': 'api:DbDeleteResponse', 'api:status': 'api:success' }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
const axios = require('axios'); | ||
const axios = require('axios').default; | ||
|
||
const axiosInstance = axios.create(); | ||
const axiosInstance = axios.create({}); | ||
|
||
module.exports = axiosInstance; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.