diff --git a/packages/receipt-components/test/receipt-component.test.ts b/packages/receipt-components/test/receipt-component.test.ts
index 20a4194..e2c8fdf 100644
--- a/packages/receipt-components/test/receipt-component.test.ts
+++ b/packages/receipt-components/test/receipt-component.test.ts
@@ -39,7 +39,7 @@ describe('receipt-component', () => {
});
it('should use ReceiptComponent.astBuilders in nodeRegistry', () => {
- ReceiptComponent.registerNode(dummyNodePlugin);
+ ReceiptComponent.registerNodes([dummyNodePlugin]);
const component = new ReceiptComponent('test', {
render: () => '',
});
@@ -90,13 +90,13 @@ describe('receipt-component', () => {
describe('buildAst', () => {
it('should build AST from renderTemplate function', () => {
const render = () => '';
- const component = new ReceiptComponent('test', {
+ const component = new ReceiptComponent('test', {
render,
});
- const ast = component.buildAst({});
+ const ast = component.buildAst(null);
expect(ast).toEqual({
name: 'root',
- props: null,
+ props: {},
children: [],
});
});
@@ -137,21 +137,21 @@ describe('receipt-component', () => {
});
it('should register a node', () => {
ReceiptComponent.registerRenderer(dummyRendererPlugin);
- ReceiptComponent.registerNode(dummyNodePlugin);
+ ReceiptComponent.registerNodes([dummyNodePlugin]);
expect(ReceiptComponent.astBuilders.dummyNode).toBe(
dummyNodePlugin.buildNode
);
});
it('should allow registering a node with renderers not defined on instance', () => {
- ReceiptComponent.registerNode(dummyNodePlugin);
+ ReceiptComponent.registerNodes([dummyNodePlugin]);
expect(ReceiptComponent.astBuilders.dummyNode).toBe(
dummyNodePlugin.buildNode
);
});
it('should register aliases for a node', () => {
- ReceiptComponent.registerNode(dummyNodePluginWithAlias);
+ ReceiptComponent.registerNodes([dummyNodePluginWithAlias]);
expect(ReceiptComponent.astBuilders.dummyNode).toBe(
dummyNodePluginWithAlias.buildNode
);
@@ -161,8 +161,8 @@ describe('receipt-component', () => {
});
it('should allow overriding a node', () => {
- ReceiptComponent.registerNode(dummyNodePlugin);
- ReceiptComponent.registerNode(dummyNodePluginWithAlias);
+ ReceiptComponent.registerNodes([dummyNodePlugin]);
+ ReceiptComponent.registerNodes([dummyNodePluginWithAlias]);
expect(ReceiptComponent.astBuilders.dummyNode).toBe(
dummyNodePluginWithAlias.buildNode
);
@@ -170,7 +170,7 @@ describe('receipt-component', () => {
it('should register node renderers to installed renderers', () => {
ReceiptComponent.registerRenderer(dummyRendererPlugin);
- ReceiptComponent.registerNode(dummyNodePlugin);
+ ReceiptComponent.registerNodes([dummyNodePlugin]);
expect(dummyRenderFuncRegistry.dummyNode).toBeDefined();
});
});
diff --git a/packages/renderers/receipt-escpos-renderer/test/nodes/align.test.ts b/packages/renderers/receipt-escpos-renderer/test/nodes/align.test.ts
index fd30a70..b64ec4e 100644
--- a/packages/renderers/receipt-escpos-renderer/test/nodes/align.test.ts
+++ b/packages/renderers/receipt-escpos-renderer/test/nodes/align.test.ts
@@ -40,6 +40,7 @@ describe('align', () => {
bytes.ESC,
0x61,
0x00,
+ bytes.LF,
bytes.ESC,
0x61,
0x01,
@@ -60,6 +61,7 @@ describe('align', () => {
0x61,
0x01,
...childBytes,
+ bytes.LF,
bytes.ESC,
0x61,
0x00,
diff --git a/packages/renderers/receipt-escpos-renderer/test/util/index.test.ts b/packages/renderers/receipt-escpos-renderer/test/util/index.test.ts
index ad6dd0b..9e9b008 100644
--- a/packages/renderers/receipt-escpos-renderer/test/util/index.test.ts
+++ b/packages/renderers/receipt-escpos-renderer/test/util/index.test.ts
@@ -35,13 +35,6 @@ describe('util', () => {
});
});
describe('splitLines', () => {
- it('should pad spaces to the line length', () => {
- const text = 'Hello';
- const lines = splitLines(text, 15, 0).join('\n');
-
- assert(lines.length === 15);
- });
-
it('should split the text into lines', () => {
const text = 'Hello World';
const lines = splitLines(text, 5, 0);
@@ -60,38 +53,6 @@ describe('util', () => {
expect(lines[1]?.trim()).toBe('World');
});
- it('should pad spaces at the start if justify is right', () => {
- const text = 'Hello World';
- const lines = splitLines(text, 15, 0, 'right');
-
- expect(lines.length).toBe(1);
- expect(lines[0]).toBe('Hello World'.padStart(15, ' '));
- });
-
- it('should pad spaces at the end if justify is left', () => {
- const text = 'Hello World';
- const lines = splitLines(text, 15, 0, 'left');
-
- expect(lines.length).toBe(1);
- expect(lines[0]).toBe('Hello World'.padEnd(15, ' '));
- });
-
- it('should pad spaces at the start and end if justify is center', () => {
- const text = 'Hello World';
- const lines = splitLines(text, 15, 0, 'center');
-
- expect(lines.length).toBe(1);
- expect(lines[0]).toBe('Hello World'.padStart(13, ' ').padEnd(12, ' '));
- });
-
- it('should have extra spaces at the end if justify is center and the line length is odd', () => {
- const text = 'Hello World';
- const lines = splitLines(text, 14, 0, 'center');
-
- expect(lines.length).toBe(1);
- expect(lines[0]).toBe('Hello World'.padStart(12, ' ').padEnd(13, ' '));
- });
-
it('should split text when word lengths equal line length', () => {
const text = 'Hello World';
const lines = splitLines(text, 10, 0);
@@ -108,14 +69,5 @@ describe('util', () => {
expect(lines.length).toBe(1);
expect(lines[0]?.trim()).toBe('Hello World');
});
-
- it('should justify every line', () => {
- const text = 'Hello World';
- const lines = splitLines(text, 10, 0);
-
- expect(lines.length).toBe(2);
- expect(lines[0]).toBe('Hello'.padEnd(10, ' '));
- expect(lines[1]).toBe('World'.padEnd(10, ' '));
- });
});
});