Skip to content

Commit

Permalink
Move websocket tests to dedicated file
Browse files Browse the repository at this point in the history
  • Loading branch information
minottic committed Aug 27, 2024
1 parent f65fc8b commit 54f1893
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 51 deletions.
51 changes: 0 additions & 51 deletions sci-log-db/src/__tests__/unit/utils.misc.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
sanitizeTextContent,
sanitizeTextContentInPlace,
} from '../../utils/misc';
import {matchesFilterSettings} from '../../utils/websocket';

describe('Utils unit tests', function (this: Suite) {
it('Should filterEmptySubsnippets', () => {
Expand Down Expand Up @@ -317,54 +316,4 @@ describe('Utils unit tests', function (this: Suite) {
expect(t.input).to.be.eql(t.expected);
});
});

[
{
input: [{tags: ['a']}, {filter: {}}],
expected: true,
},
{
input: [{tags: ['a', 'p']}, {filter: {tags: ['b', 'c']}}],
expected: false,
},
{
input: [{snippetType: 'anotherType'}, {filter: {snippetType: ['aType']}}],
expected: false,
},
{
input: [{snippetType: 'aType'}, {filter: {snippetType: ['aType']}}],
expected: true,
},
{
input: [{tags: ['a', 'p']}, {filter: {tags: ['a', 'c']}}],
expected: true,
},
{
input: [
{tags: ['a', 'p'], snippetType: 'anotherType'},
{filter: {tags: ['a', 'c'], snippetType: ['aType']}},
],
expected: false,
},
{
input: [
{tags: ['a', 'p'], snippetType: 'aType'},
{filter: {tags: ['a', 'c'], snippetType: ['aType']}},
],
expected: true,
},
{
input: [
{tags: ['b', 'p'], snippetType: 'aType'},
{filter: {tags: ['a', 'c'], snippetType: ['aType']}},
],
expected: false,
},
].forEach((t, i) => {
it(`Should test matchesFilterSettings ${i}`, () => {
expect(
matchesFilterSettings(t.input[0] as Basesnippet, t.input[1]),
).to.be.eql(t.expected);
});
});
});
56 changes: 56 additions & 0 deletions sci-log-db/src/__tests__/unit/websocket.utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import {expect} from '@loopback/testlab';
import {Suite} from 'mocha';
import {Basesnippet} from '../../models';
import {matchesFilterSettings} from '../../utils/websocket';

describe('Websocket unit tests', function (this: Suite) {
[
{
input: [{tags: ['a']}, {filter: {}}],
expected: true,
},
{
input: [{tags: ['a', 'p']}, {filter: {tags: ['b', 'c']}}],
expected: false,
},
{
input: [{snippetType: 'anotherType'}, {filter: {snippetType: ['aType']}}],
expected: false,
},
{
input: [{snippetType: 'aType'}, {filter: {snippetType: ['aType']}}],
expected: true,
},
{
input: [{tags: ['a', 'p']}, {filter: {tags: ['a', 'c']}}],
expected: true,
},
{
input: [
{tags: ['a', 'p'], snippetType: 'anotherType'},
{filter: {tags: ['a', 'c'], snippetType: ['aType']}},
],
expected: false,
},
{
input: [
{tags: ['a', 'p'], snippetType: 'aType'},
{filter: {tags: ['a', 'c'], snippetType: ['aType']}},
],
expected: true,
},
{
input: [
{tags: ['b', 'p'], snippetType: 'aType'},
{filter: {tags: ['a', 'c'], snippetType: ['aType']}},
],
expected: false,
},
].forEach((t, i) => {
it(`Should test matchesFilterSettings ${i}`, () => {
expect(
matchesFilterSettings(t.input[0] as Basesnippet, t.input[1]),
).to.be.eql(t.expected);
});
});
});

0 comments on commit 54f1893

Please sign in to comment.