Skip to content

Commit

Permalink
style: revert formatting changes to conform to StandardJS
Browse files Browse the repository at this point in the history
  • Loading branch information
GovardhaneNitin committed Dec 7, 2024
1 parent 4e5c223 commit b89b1c5
Showing 1 changed file with 60 additions and 60 deletions.
120 changes: 60 additions & 60 deletions src/index.test.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
/* eslint-env mocha */

import sbp from "@sbp/sbp";
import assert from "node:assert/strict";
import { describe, it, mock } from "node:test";
import "../dist/esm/index.js";
import sbp from '@sbp/sbp'
import assert from 'node:assert/strict'
import { describe, it, mock } from 'node:test'
import '../dist/esm/index.js'

describe("[SBP] EVENTS domain", () => {
it("should register event listener", () => {
const testListener = mock.fn(() => {});
sbp("okTurtles.events/on", "testEvent", testListener);
sbp("okTurtles.events/emit", "testEvent");
sbp("okTurtles.events/emit", "testEvent");
assert.equal(testListener.mock.callCount(), 2);
});
it("should pass event listener the right data", () => {
const testListener = mock.fn(() => {});
const testData = 1;
sbp("okTurtles.events/on", "testEvent", testListener);
sbp("okTurtles.events/emit", "testEvent", testData);
assert.equal(testListener.mock.callCount(), 1);
assert.deepEqual(testListener.mock.calls[0].arguments, [testData]);
});
describe('[SBP] EVENTS domain', () => {
it('should register event listener', () => {
const testListener = mock.fn(() => {})
sbp('okTurtles.events/on', 'testEvent', testListener)
sbp('okTurtles.events/emit', 'testEvent')
sbp('okTurtles.events/emit', 'testEvent')
assert.equal(testListener.mock.callCount(), 2)
})
it('should pass event listener the right data', () => {
const testListener = mock.fn(() => {})
const testData = 1
sbp('okTurtles.events/on', 'testEvent', testListener)
sbp('okTurtles.events/emit', 'testEvent', testData)
assert.equal(testListener.mock.callCount(), 1)
assert.deepEqual(testListener.mock.calls[0].arguments, [testData])
})
it('should call "once" listener once', () => {
const testListener = mock.fn(() => {});
sbp("okTurtles.events/once", "testEvent", testListener);
sbp("okTurtles.events/emit", "testEvent");
sbp("okTurtles.events/emit", "testEvent");
assert.equal(testListener.mock.callCount(), 1);
});
it("should disable listener correctly", () => {
const testListener = mock.fn(() => {});
sbp("okTurtles.events/on", "testEvent2", testListener);
sbp("okTurtles.events/emit", "testEvent2");
sbp("okTurtles.events/off", "testEvent2");
sbp("okTurtles.events/emit", "testEvent2");
assert.equal(testListener.mock.callCount(), 1);
});
it("should disable listener correctly (using return value)", () => {
const testListener = mock.fn(() => {});
const disable = sbp("okTurtles.events/on", "testEvent2", testListener);
sbp("okTurtles.events/emit", "testEvent2");
disable();
sbp("okTurtles.events/emit", "testEvent2");
assert.equal(testListener.mock.callCount(), 1);
});
it("should return cleanup function from on", () => {
const testListener = mock.fn(() => {});
const cleanup = sbp("okTurtles.events/on", "testEvent", testListener);
assert.equal(typeof cleanup, "function");
sbp("okTurtles.events/emit", "testEvent");
cleanup();
sbp("okTurtles.events/emit", "testEvent");
assert.equal(testListener.mock.callCount(), 1);
});
it("should return cleanup function from once", () => {
const testListener = mock.fn(() => {});
const cleanup = sbp("okTurtles.events/once", "testEvent", testListener);
assert.equal(typeof cleanup, "function");
cleanup();
sbp("okTurtles.events/emit", "testEvent");
assert.equal(testListener.mock.callCount(), 0);
});
});
const testListener = mock.fn(() => {})
sbp('okTurtles.events/once', 'testEvent', testListener)
sbp('okTurtles.events/emit', 'testEvent')
sbp('okTurtles.events/emit', 'testEvent')
assert.equal(testListener.mock.callCount(), 1)
})
it('should disable listener correctly', () => {
const testListener = mock.fn(() => {})
sbp('okTurtles.events/on', 'testEvent2', testListener)
sbp('okTurtles.events/emit', 'testEvent2')
sbp('okTurtles.events/off', 'testEvent2')
sbp('okTurtles.events/emit', 'testEvent2')
assert.equal(testListener.mock.callCount(), 1)
})
it('should disable listener correctly (using return value)', () => {
const testListener = mock.fn(() => {})
const disable = sbp('okTurtles.events/on', 'testEvent2', testListener)
sbp('okTurtles.events/emit', 'testEvent2')
disable()
sbp('okTurtles.events/emit', 'testEvent2')
assert.equal(testListener.mock.callCount(), 1)
})
it('should return cleanup function from on', () => {
const testListener = mock.fn(() => {})
const cleanup = sbp('okTurtles.events/on', 'testEvent', testListener)
assert.equal(typeof cleanup, 'function')
sbp('okTurtles.events/emit', 'testEvent')
cleanup()
sbp('okTurtles.events/emit', 'testEvent')
assert.equal(testListener.mock.callCount(), 1)
})
it('should return cleanup function from once', () => {
const testListener = mock.fn(() => {})
const cleanup = sbp('okTurtles.events/once', 'testEvent', testListener)
assert.equal(typeof cleanup, 'function')
cleanup()
sbp('okTurtles.events/emit', 'testEvent')
assert.equal(testListener.mock.callCount(), 0)
})
})

0 comments on commit b89b1c5

Please sign in to comment.