Skip to content

Commit 78cb0b4

Browse files
committed
test: improve file path assertion and update snapshot expectations
1 parent a392723 commit 78cb0b4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/index.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import fs from 'node:fs';
2+
import path from 'node:path';
23
import { KeyValues } from '../src';
34

45
const defaultOptions: Options = {
@@ -77,8 +78,9 @@ describe('KeyValues Default Test', () => {
7778
it('should return the default path to the json file', () => {
7879
const keyValues = new KeyValues();
7980
const filePath = keyValues.file();
80-
// expect(filePath).toMatch(/\.json$/);
81-
expect(filePath).toBe('localdb\\keyvalues.json');
81+
82+
const expectedPath = path.join('localdb', 'keyvalues.json');
83+
expect(filePath).toStrictEqual(expectedPath);
8284
});
8385

8486
it('should reset options object to defaultOptions', () => {
@@ -132,7 +134,7 @@ describe('KeyValues Default Test', () => {
132134
expect(kvs.getSync('recObject')).toBeUndefined();
133135
expect(kvs.getSync('recDictionary')).toBeUndefined();
134136
expect(kvs.getSync('recArray')).not.toBeUndefined();
135-
expect(kvs.getSync('recArray')).toMatchSnapshot(['Heliomar', 'Marques']);
137+
expect(kvs.getSync('recArray')).toStrictEqual(['Heliomar', 'Marques']);
136138

137139
kvs.setSync('recNull', Object.values(recNull)[0]);
138140
kvs.setSync('recStr', Object.values(recStr)[0]);
@@ -148,7 +150,7 @@ describe('KeyValues Default Test', () => {
148150
expect(kvs.getSync('recBool')).not.toBeUndefined();
149151
expect(kvs.getSync('recObject')).not.toBeUndefined();
150152
expect(kvs.getSync('recDictionary')).not.toBeUndefined();
151-
expect(kvs.getSync<string[]>('recArray')).toMatchSnapshot(['Heliomar', 'Marques']);
153+
expect(kvs.getSync<string[]>('recArray')).toStrictEqual(['Heliomar', 'Marques']);
152154
});
153155

154156
it('test set/get property Array', () => {

0 commit comments

Comments
 (0)