Skip to content

Commit

Permalink
chore: run Prettier as part of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
targos committed Jul 19, 2024
1 parent 4d6b4fb commit 88c9b40
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
run: npm ci
- name: Run ESLint
run: npm run eslint
- name: Run Prettier
run: npm run prettier
test:
runs-on: ubuntu-latest
strategy:
Expand Down
34 changes: 17 additions & 17 deletions __tests__/molecule.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,25 @@ describe('from and to SMILES', () => {
expect(mol.toIsomericSmiles({ kekulizedOutput: true })).toBe('C1=CC=CC=C1');
expect(mol.toIsomericSmiles({ createSmarts: true })).toBe('c1ccccc1');
mol.setAtomMapNo(0, 1);
expect(mol.toIsomericSmiles({ includeMapping: true })).toBe('c1cc[cH:1]cc1');
expect(mol.toIsomericSmiles({ includeMapping: true })).toBe(
'c1cc[cH:1]cc1',
);

const fragment = Molecule.fromSmiles('C1=CC=CC=C1C');
fragment.setFragment(true);
fragment.setAtomicNo(6, 1)
expect(fragment.toIsomericSmiles({ createSmarts: true })).toBe('c1cc[c;!H0]cc1');
})
fragment.setAtomicNo(6, 1);
expect(fragment.toIsomericSmiles({ createSmarts: true })).toBe(
'c1cc[c;!H0]cc1',
);
});
});

it('smarts options', () => {
const fragment = Molecule.fromSmiles('C1=CC=CC=C1C');
fragment.setFragment(true);
fragment.setAtomicNo(6, 1)
fragment.setAtomicNo(6, 1);
expect(fragment.toSmarts()).toBe('c1cc[c;!H0]cc1');
})
});

describe('Molecule', () => {
it('medley', () => {
Expand Down Expand Up @@ -178,22 +182,22 @@ describe('Molecule', () => {

it('getFinalRanks', () => {
const molecule = Molecule.fromSmiles('CCC');
molecule.setAtomicNo(0, 8)
molecule.setAtomicNo(0, 8);
const atoms = [];
const ranks = [...molecule.getFinalRanks()];
for (let i = 0; i < molecule.getAllAtoms(); i++) {
atoms.push(molecule.getAtomLabel(i), ranks[i]);
}
expect(atoms).toStrictEqual(['O', 3, 'C', 2, 'C', 1])
expect(atoms).toStrictEqual(['O', 3, 'C', 2, 'C', 1]);
const molecule2 = Molecule.fromSmiles('CCC');
molecule2.setAtomicNo(2, 8)
molecule2.setAtomicNo(2, 8);
const atoms2 = [];
const ranks2 = [...molecule2.getFinalRanks()];
for (let i = 0; i < molecule2.getAllAtoms(); i++) {
atoms2.push(molecule2.getAtomLabel(i), ranks2[i]);
}
expect(atoms2).toStrictEqual(['C', 1, 'C', 2, 'O', 3])
})
expect(atoms2).toStrictEqual(['C', 1, 'C', 2, 'O', 3]);
});

it('getFinalRanks of xMolecule', () => {
const molecule = Molecule.fromSmiles('CCCO');
Expand All @@ -210,12 +214,8 @@ describe('Molecule', () => {
}

const ranks = [...molecule.getFinalRanks()];
expect(ranks).toStrictEqual([
3, 1, 2, 4, 11,
10, 9, 5, 6, 7,
8, 12
])
})
expect(ranks).toStrictEqual([3, 1, 2, 4, 11, 10, 9, 5, 6, 7, 8, 12]);
});

it('should have a method that returns the OCL object', () => {
const molecule = Molecule.fromSmiles('C');
Expand Down
4 changes: 2 additions & 2 deletions __tests__/molecule.queryFeatures.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ test('bond query features cycle of 4 atoms with aromatic bond', () => {
expect(firstBondQueryFeatures.ringSize).toBe(4);
expect(firstBondQueryFeatures.aromatic).toBe(true);
expect(firstBondQueryFeatures.nonAromatic).toBe(false);
})
});

test('bond query features atom bridge 2 to 7', () => {
const molecule = Molecule.fromIDCode('eM@HzCNDh');
const firstBondQueryFeatures = molecule.getBondQueryFeaturesObject(0);
expect(firstBondQueryFeatures.brigdeMin).toBe(2);
expect(firstBondQueryFeatures.brigdeSpan).toBe(5);
expect(firstBondQueryFeatures.nonAromatic).toBe(false);
})
});
4 changes: 2 additions & 2 deletions benchmark/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
rules:
import/no-unresolved: [error, { ignore: ['./distold']}]
no-console: off
import/no-unresolved: [error, { ignore: ['./distold'] }]
no-console: off
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"build-full-pretty": "npm run build:pretty -- -m full",
"eslint": "eslint __tests__ scripts benchmark",
"eslint-fix": "npm run eslint -- --fix",
"test": "npm run build && npm run test-only && npm run eslint",
"prettier": "prettier --check __tests__ scripts benchmark",
"prettier-write": "prettier --write __tests__ scripts benchmark",
"test": "npm run build && npm run test-only && npm run eslint && npm run prettier",
"test-only": "jest"
},
"main": "./core.js",
Expand Down
4 changes: 3 additions & 1 deletion scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ async function build() {
log('Creating ESM-compatible entry points');
for (const mod of modules) {
log(`Creating ESM-compatible entry point for module ${mod.name}${suffix}`);
const moduleInstance = require(`../dist/openchemlib-${mod.name}${suffix}.js`);
const moduleInstance = require(
`../dist/openchemlib-${mod.name}${suffix}.js`,
);
const moduleExports = Object.keys(moduleInstance).map(
(moduleExport) => `exports.${moduleExport} = OCL.${moduleExport};`,
);
Expand Down
2 changes: 1 addition & 1 deletion scripts/extend/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function extendCore(exports) {
funcTol: 1e-6,
};
ForceFieldMMFF94.prototype.minimise = function minimise(options) {
options = { ...defaultMinimiseOptions, ...options};
options = { ...defaultMinimiseOptions, ...options };
return this._minimise(options.maxIts, options.gradTol, options.funcTol);
};
};

0 comments on commit 88c9b40

Please sign in to comment.