Skip to content

Commit 67bf8f1

Browse files
fix: standardize encoding in file read operations and update test assertions (fix snyk issues)
1 parent 024e368 commit 67bf8f1

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

sanity-report-dev11.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const user3 = process.env.USER3;
1313
const user4 = process.env.USER4;
1414

1515
const reportPath = path.resolve('reports/sanity.html');
16-
const reportHtml = fs.readFileSync(reportPath, 'utf-8');
16+
const reportHtml = fs.readFileSync(reportPath, 'utf8');
1717
const dom = new JSDOM(reportHtml);
1818
const document = dom.window.document;
1919

sanity-report.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dotenv.config();
99
const { App } = pkg;
1010

1111
const reportPath = path.resolve('reports/sanity.html');
12-
const reportHtml = fs.readFileSync(reportPath, 'utf-8');
12+
const reportHtml = fs.readFileSync(reportPath, 'utf8');
1313
const dom = new JSDOM(reportHtml);
1414
const document = dom.window.document;
1515

src/lib/query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ export class Query extends BaseQuery {
399399
return this;
400400
}
401401
this._parameters[key] = { '$ne': value };
402-
return this;;
402+
return this;
403403
}
404404

405405
/**

test/api/entry.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseEntry } from 'src';
1+
import { BaseEntry } from '../../src';
22
import { Entry } from '../../src/lib/entry';
33
import { stackInstance } from '../utils/stack-instance';
44
import { TEntry } from './types';

test/unit/entry-queryable.spec.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// file deepcode ignore AttrAccessOnNull/test: <ignored in this unit test file due to the way method chaining is used with the contentType.entry().query() pattern.>
12
import { AxiosInstance, httpClient } from '@contentstack/core';
23
import { ContentType } from '../../src/lib/content-type';
34
import MockAdapter from 'axios-mock-adapter';
@@ -21,15 +22,15 @@ describe('Query Operators API test cases', () => {
2122
});
2223
it('should get entries which matches the fieldUid and values', () => {
2324
const query = contentType.entry().query().containedIn('fieldUID', ['value']);
24-
expect(query._parameters).toStrictEqual({'fieldUID': {'$in': ['value']}});
25+
expect(query._parameters).toEqual({'fieldUID': {'$in': ['value']}});
2526
});
2627
it('should get entries which does not match the fieldUid and values', () => {
2728
const query = contentType.entry().query().notContainedIn('fieldUID', ['value', 'value2']);
28-
expect(query._parameters).toStrictEqual({'fieldUID': {'$nin': ['value', 'value2']}});
29+
expect(query._parameters).toEqual({'fieldUID': {'$nin': ['value', 'value2']}});
2930
});
3031
it('should get entries which does not match the fieldUid - notExists', () => {
3132
const query = contentType.entry().query().notExists('fieldUID');
32-
expect(query._parameters).toStrictEqual({'fieldUID': {'$exists': false}});
33+
expect(query._parameters).toEqual({'fieldUID': {'$exists': false}});
3334
});
3435
it('should get entries which matches the fieldUid - exists', async () => {
3536
const query = contentType.entry().query().exists('fieldUID');
@@ -41,21 +42,21 @@ describe('Query Operators API test cases', () => {
4142
const query1: Query = await contentType.entry().query().containedIn('fieldUID', ['value']);
4243
const query2: Query = await contentType.entry().query().where('fieldUID', QueryOperation.EQUALS, 'value2');
4344
const query = await contentType.entry().query().or(query1, query2);
44-
expect(query._parameters).toStrictEqual({ '$or': [ {'fieldUID': {'$in': ['value']}}, { 'fieldUID': 'value2' } ] });
45+
expect(query._parameters).toEqual({ '$or': [ {'fieldUID': {'$in': ['value']}}, { 'fieldUID': 'value2' } ] });
4546
});
4647
it('should return entry when both conditions are matching - and', async () => {
4748
const query1: Query = await contentType.entry().query().containedIn('fieldUID', ['value']);
4849
const query2: Query = await contentType.entry().query().where('fieldUID', QueryOperation.EQUALS, 'value2');
4950
const query = await contentType.entry().query().and(query1, query2);
50-
expect(query._parameters).toStrictEqual({ '$and': [ {'fieldUID': {'$in': ['value']}}, { 'fieldUID': 'value2' } ] });
51+
expect(query._parameters).toEqual({ '$and': [ {'fieldUID': {'$in': ['value']}}, { 'fieldUID': 'value2' } ] });
5152
});
5253
it('should return entry equal to the condition - equalTo', async () => {
5354
const query = contentType.entry().query().equalTo('fieldUID', 'value');
54-
expect(query._parameters).toStrictEqual({ 'fieldUID': 'value' });
55+
expect(query._parameters).toEqual({ 'fieldUID': 'value' });
5556
});
5657
it('should return entry equal to the condition - notEqualTo', async () => {
5758
const query = contentType.entry().query().notEqualTo('fieldUID', 'value');
58-
expect(query._parameters).toStrictEqual({ 'fieldUID': {'$ne': 'value'} });
59+
expect(query._parameters).toEqual({ 'fieldUID': {'$ne': 'value'} });
5960
});
6061
it('should return entry for referenceIn query', async () => {
6162
const query1 = contentType.entry().query().where('fieldUID', QueryOperation.EQUALS, 'value');
@@ -97,18 +98,18 @@ describe('Query Operators API test cases', () => {
9798
});
9899
it('should get entries which is lessThan the fieldUid and values', async () => {
99100
const query = contentType.entry().query().lessThan('fieldUID', 'value');
100-
expect(query._parameters).toStrictEqual({'fieldUID': {'$lt': 'value'}});
101+
expect(query._parameters).toEqual({'fieldUID': {'$lt': 'value'}});
101102
});
102103
it('should get entries which is lessThanOrEqualTo the fieldUid and values', async () => {
103104
const query = contentType.entry().query().lessThanOrEqualTo('fieldUID', 'value');
104-
expect(query._parameters).toStrictEqual({'fieldUID': {'$lte': 'value'}});
105+
expect(query._parameters).toEqual({'fieldUID': {'$lte': 'value'}});
105106
});
106107
it('should get entries which is greaterThan the fieldUid and values', async () => {
107108
const query = contentType.entry().query().greaterThan('fieldUID', 'value');
108-
expect(query._parameters).toStrictEqual({'fieldUID': {'$gt': 'value'}});
109+
expect(query._parameters).toEqual({'fieldUID': {'$gt': 'value'}});
109110
});
110111
it('should get entries which is greaterThanOrEqualTo the fieldUid and values', async () => {
111112
const query = contentType.entry().query().greaterThanOrEqualTo('fieldUID', 'value');
112-
expect(query._parameters).toStrictEqual({'fieldUID': {'$gte': 'value'}});
113+
expect(query._parameters).toEqual({'fieldUID': {'$gte': 'value'}});
113114
});
114115
});

0 commit comments

Comments
 (0)