UNPKG

994 BJavaScriptView Raw
1var util = require('../lib/util.js');
2var Validator = require('../lib/validator');
3var expect = require('chai').expect;
4
5describe('Utility functions', function() {
6 describe('isFile()', function () {
7 it('should return true if specified path is a file', function() {
8 var result = util.isFile('test/fixture/single.json');
9 expect(result).to.be.true;
10 });
11 it('should return false if specified path is not a file', function() {
12 var result = util.isFile('test/fixture/not_exist.json');
13 expect(result).to.be.false;
14 });
15 });
16 describe('parseJSON()', function () {
17 it('should return object if it is JSON strings', function() {
18 var result = util.parseJSON('{"foo": 1}');
19 expect(result).to.be.ok;
20 });
21 });
22});
23
24describe('Validator class', function() {
25 it('should return object if arguments are every correct', function() {
26 var result = new Validator('UA-1234-56', 'foo', '{"foo": 1}').validate();
27 expect(result).to.be.ok;
28 });
29});