@mdfriday/foundry
Version:
The core engine of MDFriday. Convert Markdown and shortcodes into fully themed static sites – Hugo-style, powered by TypeScript.
81 lines • 3.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const item_1 = require("./item");
describe('Item', () => {
describe('ValTyped', () => {
it('should correctly parse float numbers', () => {
let source = new TextEncoder().encode('3.14');
let item = new item_1.Item();
item['low'] = 0;
item['high'] = source.length;
expect(item.ValTyped(source)).toBe(3.14);
source = new TextEncoder().encode('.14');
item = new item_1.Item();
item['low'] = 0;
item['high'] = source.length;
expect(item.ValTyped(source)).toBe(0.14);
});
it('should correctly parse integers', () => {
const source = new TextEncoder().encode('314');
const item = new item_1.Item();
item['low'] = 0;
item['high'] = source.length;
expect(item.ValTyped(source)).toBe(314);
});
it('should handle string flag', () => {
const source = new TextEncoder().encode('314');
const item = new item_1.Item();
item['low'] = 0;
item['high'] = source.length;
item['isString'] = true;
expect(item.ValTyped(source)).toBe('314');
});
it('should handle invalid number formats', () => {
let source = new TextEncoder().encode('314x');
let item = new item_1.Item();
item['low'] = 0;
item['high'] = source.length;
expect(item.ValTyped(source)).toBe('314x');
source = new TextEncoder().encode('314 ');
item = new item_1.Item();
item['low'] = 0;
item['high'] = source.length;
expect(item.ValTyped(source)).toBe('314 ');
});
it('should correctly parse boolean values', () => {
let source = new TextEncoder().encode('true');
let item = new item_1.Item();
item['low'] = 0;
item['high'] = source.length;
expect(item.ValTyped(source)).toBe(true);
source = new TextEncoder().encode('false');
item = new item_1.Item();
item['low'] = 0;
item['high'] = source.length;
expect(item.ValTyped(source)).toBe(false);
});
it('should handle invalid boolean formats', () => {
let source = new TextEncoder().encode('falsex');
let item = new item_1.Item();
item['low'] = 0;
item['high'] = source.length;
expect(item.ValTyped(source)).toBe('falsex');
source = new TextEncoder().encode('xfalse');
item = new item_1.Item();
item['low'] = 0;
item['high'] = source.length;
expect(item.ValTyped(source)).toBe('xfalse');
source = new TextEncoder().encode('truex');
item = new item_1.Item();
item['low'] = 0;
item['high'] = source.length;
expect(item.ValTyped(source)).toBe('truex');
source = new TextEncoder().encode('xtrue');
item = new item_1.Item();
item['low'] = 0;
item['high'] = source.length;
expect(item.ValTyped(source)).toBe('xtrue');
});
});
});
//# sourceMappingURL=item.test.js.map