* Split core lib into multiple files * Refactor data encoding methods * Refactor data masking process * Improve qr code generation process * Increase minimum required node version to 0.10 * Add linter * Add tests and tests coverage * Update travis config to fix compilation issues * Add examples folder * Add missing license tag in package.json * Update build script and add sourcemap support * Publish only strictly needed files on npm * Update readme
25 lines
884 B
JavaScript
25 lines
884 B
JavaScript
var test = require('tap').test
|
|
var FormatInfo = require('core/format-info')
|
|
var ECLevel = require('core/error-correction-level')
|
|
var MaskPattern = require('core/mask-pattern')
|
|
|
|
var EXPECTED_FORMAT_BITS = [
|
|
[0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976],
|
|
[0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0],
|
|
[0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed],
|
|
[0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b]
|
|
]
|
|
|
|
test('Format encoded info', function (t) {
|
|
var levels = [ECLevel.L, ECLevel.M, ECLevel.Q, ECLevel.H]
|
|
var patterns = Object.keys(MaskPattern.Patterns).length
|
|
|
|
for (var l = 0; l < levels.length; l++) {
|
|
for (var p = 0; p < patterns; p++) {
|
|
var bch = FormatInfo.getEncodedBits(levels[l], p)
|
|
t.equal(bch, EXPECTED_FORMAT_BITS[l][p], 'Should return correct bits')
|
|
}
|
|
}
|
|
|
|
t.end()
|
|
})
|