Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move websocket tests to dedicated file #393

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});
});
});
Loading