-
Notifications
You must be signed in to change notification settings - Fork 191
/
parsers-cube.test.js
51 lines (40 loc) · 1.59 KB
/
parsers-cube.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
*@jest-environment jsdom
*/
global.$ = require("jquery");
global.URL.createObjectURL = function() {};
let $3Dmol = require("../../build/3Dmol.js");
const fs = require('fs');
describe('Function CUBE | Input:1fas.cube |', ()=>{
// CUBE returns 'atoms'
const data = fs.readFileSync('tests/auto/data/1fas.cube', 'utf-8');
let atoms = $3Dmol.Parsers.CUBE(data, {}); // assignBonds is undefined (same as true)
test("Atom is empty if input has less than 6 lines", () => {
let str = "line1\nline2\nline3";
let result = $3Dmol.Parsers.CUBE(str);
expect(result).toEqual([[]]); // if lines.length < 6, atoms is empty
});
test("Length of atoms is equal to 1", ()=>{
expect(atoms.length).toBe(1);
});
test("Atoms should match the snapshot", ()=>{
expect(atoms).toMatchSnapshot();
});
});
describe('Function CUBE | Input:1fas.cube | assignBonds: false |', ()=>{
const data = fs.readFileSync('tests/auto/data/1fas.cube', 'utf-8');
let atoms = $3Dmol.Parsers.CUBE(data, {assignBonds:false});
test("All bonds are empty when assignBonds is false", ()=>{
for(let i = 0; i < atoms[0].length; i++){
expect(atoms[0][i].bonds).toEqual([]);
}
});
test("All bondOrder are empty when assignBonds is false", ()=>{
for(let i = 0; i < atoms[0].length; i++){
expect(atoms[0][i].bondOrder).toEqual([]);
}
});
test("Atoms should match the snapshot (assignBonds:false)", ()=>{
expect(atoms).toMatchSnapshot();
});
});