Skip to content

Commit

Permalink
🚿
Browse files Browse the repository at this point in the history
  • Loading branch information
codemasher committed Jun 8, 2024
1 parent 42b46e5 commit f7d38b2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
20 changes: 18 additions & 2 deletions test/Output/QRStringJSON.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import {
Byte, MaskPattern, QRData, QROptions, QROutputAbstract, QROutputInterface, QRStringJSON, PATTERN_010,
QRCode, QROptions, QROutputAbstract, QROutputInterface, QRStringJSON, M_DATA, M_DATA_DARK,
} from '../../src/index.js';

import {beforeEach, suite, test} from 'mocha';
Expand All @@ -22,7 +22,7 @@ suite('QRStringJSONTest', function(){

beforeEach(function(){
_options = new QROptions();
_matrix = (new QRData(_options, [new Byte('testdata')])).writeMatrix(new MaskPattern(PATTERN_010));
_matrix = (new QRCode(_options)).addByteSegment('testdata').getQRMatrix();
});

suite('QRStringJSON', function(){
Expand All @@ -44,6 +44,22 @@ suite('QRStringJSONTest', function(){
});


test('testSetModuleValues', function(){
let mv = {};

mv[M_DATA_DARK] = '#AAA'
mv[M_DATA] = '#BBB'

_options.moduleValues = mv;

_outputInterface = new QRStringJSON(_options, _matrix);

let data = _outputInterface.dump();

assert.isTrue(data.includes('"layer":"data-dark","value":"#AAA"'));
assert.isTrue(data.includes('"layer":"data","value":"#BBB"'));
});

});

});
Expand Down
14 changes: 8 additions & 6 deletions test/Output/QRStringText.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import {
Byte, MaskPattern, QRData, QROptions, QROutputAbstract, QROutputInterface, QRStringText, PATTERN_010, M_DATA, IS_DARK,
QRCode, QROptions, QROutputAbstract, QROutputInterface, QRStringText, M_DATA, M_DATA_DARK,
} from '../../src/index.js';

import {beforeEach, suite, test} from 'mocha';
Expand All @@ -22,7 +22,7 @@ suite('QRStringTextTest', function(){

beforeEach(function(){
_options = new QROptions();
_matrix = (new QRData(_options, [new Byte('testdata')])).writeMatrix(new MaskPattern(PATTERN_010));
_matrix = (new QRCode(_options)).addByteSegment('testdata').getQRMatrix();
});

suite('QRStringTest', function(){
Expand All @@ -49,14 +49,16 @@ suite('QRStringTextTest', function(){
test('testSetModuleValues', function(){
let mv = {};

mv[M_DATA] = 'A'; // 2
mv[M_DATA|IS_DARK] = 'B'; // 2050
mv[M_DATA] = 'A';
mv[M_DATA_DARK] = 'B';

_options.moduleValues = mv;
_outputInterface = new QRStringText(_options, _matrix);

assert.strictEqual(_outputInterface.moduleValues[M_DATA], 'A');
assert.strictEqual(_outputInterface.moduleValues[M_DATA|IS_DARK], 'B');
let data = _outputInterface.dump();

assert.isTrue(data.includes('A'));
assert.isTrue(data.includes('B'));
});

});
Expand Down

0 comments on commit f7d38b2

Please sign in to comment.