Skip to content

Commit

Permalink
Update copyright header with ASLv2 info
Browse files Browse the repository at this point in the history
  • Loading branch information
mpetazzoni committed Mar 1, 2024
1 parent 538c69f commit d8a6654
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
15 changes: 15 additions & 0 deletions lib/sse.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
/**
* sse.js - A flexible EventSource polyfill/replacement.
* https://github.com/mpetazzoni/sse.js
*
* Copyright (C) 2016-2024 Maxime Petazzoni <maxime.petazzoni@bulix.org>.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


Expand Down
28 changes: 24 additions & 4 deletions lib/sse.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/**
* sse.js - A flexible EventSource polyfill/replacement.
* https://github.com/mpetazzoni/sse.js
*
* Copyright (C) 2016-2024 Maxime Petazzoni <maxime.petazzoni@bulix.org>.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { SSE } from 'sse.js';

// Setup Mocking for XMLHttpRequest
Expand Down Expand Up @@ -32,7 +52,7 @@ beforeEach(() => {


describe('SSE Initialization', () => {

it('should initialize with default options', () => {
const sse = new SSE('http://example.com');
expect(sse.method).toBe('GET');
Expand Down Expand Up @@ -164,7 +184,7 @@ describe('SSE Event handling and Listeners', () => {
expect(listener.mock.calls[0][0].event).toBe(undefined);
expect(listener.mock.calls[0][0].id).toBe('1');
expect(listener.mock.calls[0][0].lastEventId).toBe('1');
})
})

it('should handle multiple data events', () => {
sse.xhr.responseText = 'id: id1\ndata: First message\n\n';
Expand Down Expand Up @@ -237,7 +257,7 @@ describe('SSE Event handling and Listeners', () => {
expect(listener.mock.calls[0][0].data).toBe('Test message\nmore message');
expect(listener.mock.calls[0][0].event).toBe(undefined);
expect(listener.mock.calls[0][0].id).toBe(null);
})
})

it('should handle an event with a custom event type', () => {
sse.xhr.responseText = 'event: customEvent\ndata: Custom event data\n\n';
Expand All @@ -250,7 +270,7 @@ describe('SSE Event handling and Listeners', () => {
expect(customListener.mock.calls[0][0].type).toBe('customEvent');
expect(customListener.mock.calls[0][0].id).toBe(null);
});

it('should handle events different field orders', () => {
sse.xhr.responseText = 'data: Custom event data\nevent: customEvent\nid: 1\n\n';
sse.xhr.trigger('progress', {});
Expand Down

0 comments on commit d8a6654

Please sign in to comment.