-
Notifications
You must be signed in to change notification settings - Fork 191
/
parsers-vasp.test.js
40 lines (32 loc) · 1.16 KB
/
parsers-vasp.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
/**
*@jest-environment jsdom
*/
global.$ = require("jquery");
global.URL.createObjectURL = function() {};
let $3Dmol = require("../../build/3Dmol.js");
const fs = require('fs');
describe('Function VASP | Input: CONTCAR |', () => {
const data = fs.readFileSync('tests/test_structs/CONTCAR', 'utf-8');
let atoms = $3Dmol.Parsers.VASP(data);
test("Atom is empty if input has less than 3 lines", () => {
let str = "data";
let result = $3Dmol.Parsers.VASP(str);
expect(result).toEqual([[]]);
});
test("Atom is empty if second line of input is not a number", () => {
let str = "line\nline\nline";
let result = $3Dmol.Parsers.VASP(str);
expect(result).toEqual([[]]);
});
test("Atoms is empty if second line of input is negative", () => {
let str = "line1\n-1\nline3";
let result = $3Dmol.Parsers.VASP(str);
expect(result).toEqual([[]]);
});
test("Atoms length is 1", () => {
expect(atoms.length).toBe(1);
});
test("Atoms should match the snapshot", ()=>{
expect(atoms).toMatchSnapshot();
});
});