Skip to content

Commit

Permalink
Add unit tests and update framework
Browse files Browse the repository at this point in the history
  • Loading branch information
jmfcool committed Mar 25, 2022
1 parent a15ac6c commit 70669c5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion demo/jmfcool.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions jmfcool.js
@@ -1,13 +1,13 @@
var jmfcool = jmfcool || {};

jmfcool.formatters = {
this : function(o) { if (typeof o != 'string') o = (o).toString(); return o; },
currency : function(o) { if (typeof o == 'number') o = (o).toFixed(2); return o; }
this : (o) => { if (typeof o != 'string') o = (o).toString(); return o; },
currency : (o) => { if (typeof o == 'number') o = (o).toFixed(2); return o; }
};

jmfcool.init = () => {};

jmfcool.model = (file, callback) =>{
jmfcool.model = (file, callback) => {
fetch(file).then(response => response.json()).then(data => callback(data)).catch(error => error);
},

Expand Down
2 changes: 1 addition & 1 deletion release/jmfcool.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion test/formatters.test.js
Expand Up @@ -3,8 +3,18 @@ import { jmfcool } from '../jmfcool.js';

describe('Formatters', () => {

test('should be an object', () => {
test('jmfcool.formatters should be an object', () => {
expect(jmfcool.formatters).toBeInstanceOf(Object);
});

test('jmfcool.formatters.this should be a function', () => {
var formatters = jmfcool.formatters;
expect(formatters.this).toBeInstanceOf(Function);
});

test('jmfcool.formatters.currency should be a function', () => {
var formatters = jmfcool.formatters;
expect(formatters.currency).toBeInstanceOf(Function);
});

});

0 comments on commit 70669c5

Please sign in to comment.