@anephenix/sarus
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -95,6 +95,6 @@ // File Dependencies | ||
sarusOne.send('Hello again'); | ||
sarusOne.__proto__ = null; | ||
sarusOne = null; | ||
sarusOne.disconnect(); | ||
const sarusTwo = new Sarus(sarusConfig); | ||
expect(sarusTwo.messages).toEqual(['Hello world', 'Hello again']); | ||
return sarusTwo; | ||
}; | ||
@@ -109,2 +109,34 @@ | ||
}); | ||
it('should process any existing messages from previous sessionStorage on initialization', async () => { | ||
sessionStorage.clear(); | ||
const sarusTwo = retrieveMessagesFromStorage({ | ||
url, | ||
storageType: 'session', | ||
reconnectAutomatically: true | ||
}); | ||
const server = new WS(url); | ||
const messageOne = await server.nextMessage; | ||
const messageTwo = await server.nextMessage; | ||
expect(sarusTwo.messages).toEqual([]); | ||
expect(messageOne).toBe('Hello world'); | ||
expect(messageTwo).toBe('Hello again'); | ||
server.close(); | ||
}); | ||
it('should process any existing messages from previous localStorage on initialization', async () => { | ||
localStorage.clear(); | ||
const sarusTwo = retrieveMessagesFromStorage({ | ||
url, | ||
storageType: 'local', | ||
reconnectAutomatically: true | ||
}); | ||
const server = new WS(url); | ||
const messageOne = await server.nextMessage; | ||
const messageTwo = await server.nextMessage; | ||
expect(sarusTwo.messages).toEqual([]); | ||
expect(messageOne).toBe('Hello world'); | ||
expect(messageTwo).toBe('Hello again'); | ||
server.close(); | ||
}); | ||
}); |
# CHANGELOG | ||
### 0.2.1 - Sunday 17th March, 2019 | ||
- Fixed a bug where messages stored in persistent storage were not being popped | ||
off of the message queue by new Sarus clients. | ||
- Added GitHub issue templates | ||
- Added CONTRIBUTING.md | ||
- Added CODE_OF_CONDUCT.md | ||
- Added some missing JSdoc code comments | ||
### 0.2.0 - Friday 15th March, 2019 | ||
@@ -4,0 +13,0 @@ |
@@ -219,2 +219,3 @@ // File Dependencies | ||
this.attachEventListeners(); | ||
if (this.messages.length > 0) this.process(); | ||
} | ||
@@ -246,2 +247,8 @@ | ||
/** | ||
* Disconnects the WebSocket client from the server, and changes the | ||
* reconnectAutomatically flag to disable automatic reconnection, unless the | ||
* developer passes a boolean flag to not do that. | ||
* @param {boolean} overrideDisableReconnect | ||
*/ | ||
disconnect(overrideDisableReconnect) { | ||
@@ -332,2 +339,3 @@ const self = this; | ||
const data = messages[0]; | ||
if (!data && messages.length === 0) return; | ||
if (this.ws.readyState === 1) { | ||
@@ -334,0 +342,0 @@ this.ws.send(data); |
{ | ||
"name": "@anephenix/sarus", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "A WebSocket JavaScript library", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65349
23
997