mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-13 06:57:05 +03:00
Fix deep equal fail
This commit is contained in:
@@ -4,6 +4,10 @@ import {getHash} from '../../src/utils/getHash';
|
|||||||
import {db} from '../../src/databases/databases';
|
import {db} from '../../src/databases/databases';
|
||||||
import {LockCategory} from '../../src/types/segments.model';
|
import {LockCategory} from '../../src/types/segments.model';
|
||||||
|
|
||||||
|
const deepEquals = (a,b) => {
|
||||||
|
a.forEach((e) => { if (!b.includes(e)) return false; });
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
describe('lockCategoriesRecords', () => {
|
describe('lockCategoriesRecords', () => {
|
||||||
before(async () => {
|
before(async () => {
|
||||||
@@ -61,7 +65,7 @@ describe('lockCategoriesRecords', () => {
|
|||||||
.then(async res => {
|
.then(async res => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
if (JSON.stringify(data) === JSON.stringify(expected)) {
|
if (deepEquals(data, expected)) {
|
||||||
done();
|
done();
|
||||||
} else {
|
} else {
|
||||||
done("Incorrect response: expected " + JSON.stringify(expected) + " got " + JSON.stringify(data));
|
done("Incorrect response: expected " + JSON.stringify(expected) + " got " + JSON.stringify(data));
|
||||||
@@ -154,7 +158,7 @@ describe('lockCategoriesRecords', () => {
|
|||||||
.then(async res => {
|
.then(async res => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
if (JSON.stringify(data) === JSON.stringify(expected)) {
|
if (deepEquals(data, expected)) {
|
||||||
done();
|
done();
|
||||||
} else {
|
} else {
|
||||||
done("Incorrect response: expected " + JSON.stringify(expected) + " got " + JSON.stringify(data));
|
done("Incorrect response: expected " + JSON.stringify(expected) + " got " + JSON.stringify(data));
|
||||||
@@ -666,7 +670,7 @@ describe('lockCategoriesRecords', () => {
|
|||||||
.then(async res => {
|
.then(async res => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
if (JSON.stringify(data) === JSON.stringify(expected)) {
|
if (deepEquals(data, expected)) {
|
||||||
done();
|
done();
|
||||||
} else {
|
} else {
|
||||||
done("Incorrect response: expected " + JSON.stringify(expected) + " got " + JSON.stringify(data));
|
done("Incorrect response: expected " + JSON.stringify(expected) + " got " + JSON.stringify(data));
|
||||||
|
|||||||
Reference in New Issue
Block a user