UNPKG

obniz

Version:

obniz sdk for javascript

2,513 lines (2,415 loc) 40 kB
let chai = require('chai'); let expect = chai.expect; let testUtil = require('../../../testUtil.js'); chai.use(require('chai-like')); chai.use(testUtil.obnizAssert); describe('display', function() { beforeEach(function(done) { return testUtil.setupObnizPromise(this, done, { binary: true }); }); afterEach(function(done) { return testUtil.releaseObnizePromise(this, done); }); it('request test no.0', function() { let requestJson = [{ display: { clear: true } }]; let expecteBinaryStrings = ['08 00 00']; expect(requestJson.length).to.be.equal(1); let isValidCommand = testUtil.isValidCommandRequestJson(requestJson); expect(isValidCommand.valid).to.be.true; let compress = this.obniz.constructor.WSCommand.compress( this.obniz.wscommands, requestJson[0] ); let binaryArray = expecteBinaryStrings .join(' ') .split(' ') .map(function(val, index) { return parseInt(val, 16); }); expect(binaryArray.length).to.be.above(2); let binary = new Uint8Array(binaryArray); expect(compress).to.be.deep.equal(binary); }); it('request test no.2', function() { let requestJson = [{ display: { text: 'Pushing' } }]; let expecteBinaryStrings = ['08 01 07 50 75 73 68 69 6e 67']; expect(requestJson.length).to.be.equal(1); let isValidCommand = testUtil.isValidCommandRequestJson(requestJson); expect(isValidCommand.valid).to.be.true; let compress = this.obniz.constructor.WSCommand.compress( this.obniz.wscommands, requestJson[0] ); let binaryArray = expecteBinaryStrings .join(' ') .split(' ') .map(function(val, index) { return parseInt(val, 16); }); expect(binaryArray.length).to.be.above(2); let binary = new Uint8Array(binaryArray); expect(compress).to.be.deep.equal(binary); }); it('request test no.4', function() { let requestJson = [{ display: { clear: true } }]; let expecteBinaryStrings = ['08 00 00']; expect(requestJson.length).to.be.equal(1); let isValidCommand = testUtil.isValidCommandRequestJson(requestJson); expect(isValidCommand.valid).to.be.true; let compress = this.obniz.constructor.WSCommand.compress( this.obniz.wscommands, requestJson[0] ); let binaryArray = expecteBinaryStrings .join(' ') .split(' ') .map(function(val, index) { return parseInt(val, 16); }); expect(binaryArray.length).to.be.above(2); let binary = new Uint8Array(binaryArray); expect(compress).to.be.deep.equal(binary); }); it('response test no.5', function() { let responseBinaryString = '09 00 01 03'; let expectJson = [{ switch: { state: 'right' } }]; let binaryArray = responseBinaryString.split(' ').map(function(val, index) { return parseInt(val, 16); }); let binary = new Uint8Array(binaryArray); let json = this.obniz.binary2Json(binary); let isValidCommand = testUtil.isValidCommandResponseJson(json); expect(isValidCommand.valid).to.be.true; expect(json).to.be.deep.equal(expectJson); }); it('request test no.6', function() { let requestJson = [{ display: { clear: true } }]; let expecteBinaryStrings = ['08 00 00']; expect(requestJson.length).to.be.equal(1); let isValidCommand = testUtil.isValidCommandRequestJson(requestJson); expect(isValidCommand.valid).to.be.true; let compress = this.obniz.constructor.WSCommand.compress( this.obniz.wscommands, requestJson[0] ); let binaryArray = expecteBinaryStrings .join(' ') .split(' ') .map(function(val, index) { return parseInt(val, 16); }); expect(binaryArray.length).to.be.above(2); let binary = new Uint8Array(binaryArray); expect(compress).to.be.deep.equal(binary); }); it('qr', function() { const requestJson = [ { display: { qr: { text: 'https://obniz.io/p/13924942', correction: 'Q' }, }, }, ]; const binaryArray = [ 8, 3, 68, 0, 255, 255, 255, 255, 255, 255, 255, 252, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 252, 0, 0, 0, 0, 0, 0, 0, 0, 192, 0, 204, 240, 204, 12, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 192, 0, 204, 240, 204, 12, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 207, 252, 192, 243, 51, 252, 255, 204, 0, 0, 0, 0, 0, 0, 0, 0, 207, 252, 192, 243, 51, 252, 255, 204, 0, 0, 0, 0, 0, 0, 0, 0, 204, 12, 252, 51, 12, 60, 192, 204, 0, 0, 0, 0, 0, 0, 0, 0, 204, 12, 252, 51, 12, 60, 192, 204, 0, 0, 0, 0, 0, 0, 0, 0, 204, 12, 243, 51, 243, 204, 192, 204, 0, 0, 0, 0, 0, 0, 0, 0, 204, 12, 243, 51, 243, 204, 192, 204, 0, 0, 0, 0, 0, 0, 0, 0, 204, 12, 243, 240, 192, 12, 192, 204, 0, 0, 0, 0, 0, 0, 0, 0, 204, 12, 243, 240, 192, 12, 192, 204, 0, 0, 0, 0, 0, 0, 0, 0, 207, 252, 255, 255, 243, 252, 255, 204, 0, 0, 0, 0, 0, 0, 0, 0, 207, 252, 255, 255, 243, 252, 255, 204, 0, 0, 0, 0, 0, 0, 0, 0, 192, 0, 204, 204, 204, 204, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 192, 0, 204, 204, 204, 204, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 243, 195, 48, 63, 255, 252, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 243, 195, 48, 63, 255, 252, 0, 0, 0, 0, 0, 0, 0, 0, 243, 252, 15, 48, 63, 195, 255, 12, 0, 0, 0, 0, 0, 0, 0, 0, 243, 252, 15, 48, 63, 195, 255, 12, 0, 0, 0, 0, 0, 0, 0, 0, 192, 255, 192, 63, 240, 3, 204, 60, 0, 0, 0, 0, 0, 0, 0, 0, 192, 255, 192, 63, 240, 3, 204, 60, 0, 0, 0, 0, 0, 0, 0, 0, 240, 240, 63, 60, 12, 240, 15, 252, 0, 0, 0, 0, 0, 0, 0, 0, 240, 240, 63, 60, 12, 240, 15, 252, 0, 0, 0, 0, 0, 0, 0, 0, 240, 195, 60, 60, 15, 204, 255, 252, 0, 0, 0, 0, 0, 0, 0, 0, 240, 195, 60, 60, 15, 204, 255, 252, 0, 0, 0, 0, 0, 0, 0, 0, 192, 252, 243, 195, 15, 0, 243, 60, 0, 0, 0, 0, 0, 0, 0, 0, 192, 252, 243, 195, 15, 0, 243, 60, 0, 0, 0, 0, 0, 0, 0, 0, 252, 51, 51, 0, 15, 12, 195, 12, 0, 0, 0, 0, 0, 0, 0, 0, 252, 51, 51, 0, 15, 12, 195, 12, 0, 0, 0, 0, 0, 0, 0, 0, 240, 252, 204, 255, 252, 195, 63, 252, 0, 0, 0, 0, 0, 0, 0, 0, 240, 252, 204, 255, 252, 195, 63, 252, 0, 0, 0, 0, 0, 0, 0, 0, 252, 207, 204, 195, 15, 63, 192, 60, 0, 0, 0, 0, 0, 0, 0, 0, 252, 207, 204, 195, 15, 63, 192, 60, 0, 0, 0, 0, 0, 0, 0, 0, 252, 12, 192, 51, 252, 3, 48, 204, 0, 0, 0, 0, 0, 0, 0, 0, 252, 12, 192, 51, 252, 3, 48, 204, 0, 0, 0, 0, 0, 0, 0, 0, 195, 63, 48, 63, 195, 48, 192, 204, 0, 0, 0, 0, 0, 0, 0, 0, 195, 63, 48, 63, 195, 48, 192, 204, 0, 0, 0, 0, 0, 0, 0, 0, 195, 12, 204, 0, 204, 63, 255, 204, 0, 0, 0, 0, 0, 0, 0, 0, 195, 12, 204, 0, 204, 63, 255, 204, 0, 0, 0, 0, 0, 0, 0, 0, 207, 195, 15, 63, 12, 240, 207, 12, 0, 0, 0, 0, 0, 0, 0, 0, 207, 195, 15, 63, 12, 240, 207, 12, 0, 0, 0, 0, 0, 0, 0, 0, 204, 60, 204, 48, 240, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 204, 60, 204, 48, 240, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 207, 48, 48, 207, 192, 252, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 207, 48, 48, 207, 192, 252, 0, 0, 0, 0, 0, 0, 0, 0, 192, 0, 204, 252, 3, 12, 207, 60, 0, 0, 0, 0, 0, 0, 0, 0, 192, 0, 204, 252, 3, 12, 207, 60, 0, 0, 0, 0, 0, 0, 0, 0, 207, 252, 240, 51, 240, 15, 195, 12, 0, 0, 0, 0, 0, 0, 0, 0, 207, 252, 240, 51, 240, 15, 195, 12, 0, 0, 0, 0, 0, 0, 0, 0, 204, 12, 255, 255, 243, 0, 15, 252, 0, 0, 0, 0, 0, 0, 0, 0, 204, 12, 255, 255, 243, 0, 15, 252, 0, 0, 0, 0, 0, 0, 0, 0, 204, 12, 243, 48, 240, 15, 63, 60, 0, 0, 0, 0, 0, 0, 0, 0, 204, 12, 243, 48, 240, 15, 63, 60, 0, 0, 0, 0, 0, 0, 0, 0, 204, 12, 243, 63, 3, 0, 3, 60, 0, 0, 0, 0, 0, 0, 0, 0, 204, 12, 243, 63, 3, 0, 3, 60, 0, 0, 0, 0, 0, 0, 0, 0, 207, 252, 204, 0, 204, 48, 204, 204, 0, 0, 0, 0, 0, 0, 0, 0, 207, 252, 204, 0, 204, 48, 204, 204, 0, 0, 0, 0, 0, 0, 0, 0, 192, 0, 255, 255, 51, 243, 192, 252, 0, 0, 0, 0, 0, 0, 0, 0, 192, 0, 255, 255, 51, 243, 192, 252, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 252, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ]; let isValidCommand = testUtil.isValidCommandRequestJson(requestJson); expect(isValidCommand.valid).to.be.true; let compress = this.obniz.constructor.WSCommand.compress( this.obniz.wscommands, requestJson[0] ); let binary = new Uint8Array(binaryArray); expect(compress).to.be.deep.equal(binary); }); it('request test no.8', function() { let requestJson = [{ display: { clear: true } }]; let expecteBinaryStrings = ['08 00 00']; expect(requestJson.length).to.be.equal(1); let isValidCommand = testUtil.isValidCommandRequestJson(requestJson); expect(isValidCommand.valid).to.be.true; let compress = this.obniz.constructor.WSCommand.compress( this.obniz.wscommands, requestJson[0] ); let binaryArray = expecteBinaryStrings .join(' ') .split(' ') .map(function(val, index) { return parseInt(val, 16); }); expect(binaryArray.length).to.be.above(2); let binary = new Uint8Array(binaryArray); expect(compress).to.be.deep.equal(binary); }); it('request test no.10', function() { let requestJson = [{ display: { clear: true } }]; let expecteBinaryStrings = ['08 00 00']; expect(requestJson.length).to.be.equal(1); let isValidCommand = testUtil.isValidCommandRequestJson(requestJson); expect(isValidCommand.valid).to.be.true; let compress = this.obniz.constructor.WSCommand.compress( this.obniz.wscommands, requestJson[0] ); let binaryArray = expecteBinaryStrings .join(' ') .split(' ') .map(function(val, index) { return parseInt(val, 16); }); expect(binaryArray.length).to.be.above(2); let binary = new Uint8Array(binaryArray); expect(compress).to.be.deep.equal(binary); }); it('request test no.12', function() { let requestJson = [{ display: { clear: true } }]; let expecteBinaryStrings = ['08 00 00']; expect(requestJson.length).to.be.equal(1); let isValidCommand = testUtil.isValidCommandRequestJson(requestJson); expect(isValidCommand.valid).to.be.true; let compress = this.obniz.constructor.WSCommand.compress( this.obniz.wscommands, requestJson[0] ); let binaryArray = expecteBinaryStrings .join(' ') .split(' ') .map(function(val, index) { return parseInt(val, 16); }); expect(binaryArray.length).to.be.above(2); let binary = new Uint8Array(binaryArray); expect(compress).to.be.deep.equal(binary); }); it('request test no.14', function() { let requestJson = [{ display: { text: 'Pushing' } }]; let expecteBinaryStrings = ['08 01 07 50 75 73 68 69 6e 67']; expect(requestJson.length).to.be.equal(1); let isValidCommand = testUtil.isValidCommandRequestJson(requestJson); expect(isValidCommand.valid).to.be.true; let compress = this.obniz.constructor.WSCommand.compress( this.obniz.wscommands, requestJson[0] ); let binaryArray = expecteBinaryStrings .join(' ') .split(' ') .map(function(val, index) { return parseInt(val, 16); }); expect(binaryArray.length).to.be.above(2); let binary = new Uint8Array(binaryArray); expect(compress).to.be.deep.equal(binary); }); it('request test no.16', function() { let requestJson = [{ display: { clear: true } }]; let expecteBinaryStrings = ['08 00 00']; expect(requestJson.length).to.be.equal(1); let isValidCommand = testUtil.isValidCommandRequestJson(requestJson); expect(isValidCommand.valid).to.be.true; let compress = this.obniz.constructor.WSCommand.compress( this.obniz.wscommands, requestJson[0] ); let binaryArray = expecteBinaryStrings .join(' ') .split(' ') .map(function(val, index) { return parseInt(val, 16); }); expect(binaryArray.length).to.be.above(2); let binary = new Uint8Array(binaryArray); expect(compress).to.be.deep.equal(binary); }); it('request test no.17', function() { let requestJson = [{ display: { clear: true } }]; let expecteBinaryStrings = ['08 00 00']; expect(requestJson.length).to.be.equal(1); let isValidCommand = testUtil.isValidCommandRequestJson(requestJson); expect(isValidCommand.valid).to.be.true; let compress = this.obniz.constructor.WSCommand.compress( this.obniz.wscommands, requestJson[0] ); let binaryArray = expecteBinaryStrings .join(' ') .split(' ') .map(function(val, index) { return parseInt(val, 16); }); expect(binaryArray.length).to.be.above(2); let binary = new Uint8Array(binaryArray); expect(compress).to.be.deep.equal(binary); }); it('request test no.21', function() { let requestJson = [{ display: { clear: true } }]; let expecteBinaryStrings = ['08 00 00']; expect(requestJson.length).to.be.equal(1); let isValidCommand = testUtil.isValidCommandRequestJson(requestJson); expect(isValidCommand.valid).to.be.true; let compress = this.obniz.constructor.WSCommand.compress( this.obniz.wscommands, requestJson[0] ); let binaryArray = expecteBinaryStrings .join(' ') .split(' ') .map(function(val, index) { return parseInt(val, 16); }); expect(binaryArray.length).to.be.above(2); let binary = new Uint8Array(binaryArray); expect(compress).to.be.deep.equal(binary); }); it('request test no.23', function() { let requestJson = [ { display: { raw: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0', ]; expect(requestJson.length).to.be.equal(1); let isValidCommand = testUtil.isValidCommandRequestJson(requestJson); expect(isValidCommand.valid).to.be.true; let compress = this.obniz.constructor.WSCommand.compress( this.obniz.wscommands, requestJson[0] ); let binaryArray = expecteBinaryStrings .join(' ') .split(' ') .map(function(val, index) { return parseInt(val, 16); }); expect(binaryArray.length).to.be.above(2); let binary = new Uint8Array(binaryArray); expect(compress).to.be.deep.equal(binary); }); it('pin name', function() { let requestJson = [ { display: { pin_assign: { '0': { module_name: 'io', pin_name: 'output', }, }, }, }, ]; let expecteBinaryStrings = ['8 5 0a 0 69 6F 20 6F 75 74 70 75 74']; expect(requestJson.length).to.be.equal(1); let isValidCommand = testUtil.isValidCommandRequestJson(requestJson); expect(isValidCommand.valid).to.be.true; let compress = this.obniz.constructor.WSCommand.compress( this.obniz.wscommands, requestJson[0] ); let binaryArray = expecteBinaryStrings .join(' ') .split(' ') .map(function(val, index) { return parseInt(val, 16); }); expect(binaryArray.length).to.be.above(2); let binary = new Uint8Array(binaryArray); expect(compress).to.be.deep.equal(binary); }); it('pin name2', function() { let requestJson = [ { display: { pin_assign: { 0: { module_name: 'io', pin_name: 'output', }, '8': { module_name: 'pwm', }, 10: { pin_name: 'input', }, }, }, }, ]; let expecteBinaryStrings = [ '8 5 0a 0 69 6f 20 6f 75 74 70 75 74 8 5 6 8 70 77 6D 20 3F 8 5 8 a 3f 20 69 6E 70 75 74', ]; expect(requestJson.length).to.be.equal(1); let isValidCommand = testUtil.isValidCommandRequestJson(requestJson); expect(isValidCommand.valid).to.be.true; let compress = this.obniz.constructor.WSCommand.compress( this.obniz.wscommands, requestJson[0] ); let binaryArray = expecteBinaryStrings .join(' ') .split(' ') .map(function(val, index) { return parseInt(val, 16); }); expect(binaryArray.length).to.be.above(2); let binary = new Uint8Array(binaryArray); expect(compress).to.be.deep.equal(binary); }); });