Skip to content

Commit

Permalink
Check index is created for schema #149
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-cowley committed Apr 14, 2021
1 parent 1e85681 commit feb6a61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"types": "types/index.d.ts",
"scripts": {
"build": "./node_modules/@babel/cli/bin/babel.js src -d build",
"test": "./node_modules/.bin/mocha --timeout 5000 --require @babel/register ./test{/,/**/}*.spec.js",
"test": "./node_modules/.bin/mocha --timeout 5000 --require @babel/register ./test{/,/**/}Schema*.spec.js",
"lint": "./node_modules/.bin/eslint src/",
"coverage": "./node_modules/.bin/nyc --reporter=html npm test",
"tdd": "./node_modules/.bin/mocha --require @babel/register --watch"
Expand Down
23 changes: 7 additions & 16 deletions test/Schema.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Schema.js', () => {
after(() => {
instance.close();
});

it('should construct', () => {
assert.instanceOf(instance.schema, Schema);
assert.isFunction(instance.schema.install);
Expand Down Expand Up @@ -73,7 +73,7 @@ describe('Schema.js', () => {

// Assertions
// expect(id_unique).to.equal(true);

// Enterprise?
if (instance.enterprise()) {
expect(id_exists).to.equal(true);
Expand All @@ -83,24 +83,15 @@ describe('Schema.js', () => {
.then(() => instance.cypher('CALL db.indexes'))
.then(indexes => {
const expected = {
age: true
'SchemaThing.age': true
};
let actual = {};

const has_index = /INDEX ON :([A-Za-z0-9]+)\(([A-Za-z0-9]+)\)/

// TODO: Reinstate

// indexes.records.forEach(index => {
// const description = index.get('description');
// const is_indexed = description.match(has_index);

// if (is_indexed && is_indexed[1] == label) {
// actual[is_indexed[2]] = true;
// }
// });
indexes.records.forEach(index => {
actual[ index.get('labelsOrTypes')[0] + '.'+ index.get('properties')[0] ] = true;
});

// expect(actual).to.include(expected);
expect(actual).to.include(expected);
})
.then(() => done())
.catch(e => {
Expand Down

0 comments on commit feb6a61

Please sign in to comment.