Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Maaaartin committed Nov 20, 2024
1 parent 024756d commit 69675af
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 79 deletions.
2 changes: 1 addition & 1 deletion __tests__/adbClient/getProp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('Gep prop tests', () => {
const port = await adbMock.start();
const adb = new Client({ noAutoStart: true, port });
const result = await adb.getProp('serial', 'prop');
expect(result).toEqual(date);
expect(result).toEqual(date.toISOString());
} finally {
await adbMock.end();
}
Expand Down
2 changes: 1 addition & 1 deletion __tests__/adbClient/getSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('Get setting OKAY tests', () => {
const port = await adbMock.start();
const adb = new Client({ noAutoStart: true, port });
const result = await adb.getSetting('serial', 'system', 'prop');
expect(result).toEqual(date);
expect(result).toEqual(date.toISOString());
} finally {
await adbMock.end();
}
Expand Down
26 changes: 12 additions & 14 deletions __tests__/adbClient/listProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ describe('List properties', () => {
{
cmd: 'shell:getprop',
res: {
value: `[one]: [1]
value: `[one]: [int]
[two]: [string]
[three]: [bool]
[four]: [bool]
[five]: [string]
[six]: [string]
[one]: [1]
[two]: [two]
[three]: [false]
[four]: [true]
[five]: [null]
[six]: []
[seven]: [Sun Jul 17 2022 21:11:48 GMT+0200 (Central European Summer Time)]`,
`,
raw: true
}
}
Expand All @@ -30,14 +36,8 @@ describe('List properties', () => {
['two', 'two'],
['three', false],
['four', true],
['five', null],
['six', undefined],
[
'seven',
new Date(
'Sun Jul 17 2022 21:11:48 GMT+0200 (Central European Summer Time)'
)
]
['five', 'null'],
['six', '']
])
);
} finally {
Expand All @@ -56,8 +56,7 @@ describe('List properties', () => {
[three]: [false]
[four]: [true]
[five]: [null]
[six]: []
[seven]: [Sun Jul 17 2022 21:11:48 GMT+0200 (Central European Summer Time)]`,
[six]: []`,
raw: true
}
}
Expand Down Expand Up @@ -105,8 +104,7 @@ describe('List properties', () => {
[three]: [false]
[four]: [true]
[five]: [null]
[six]: []
[seven]: [Sun Jul 17 2022 21:11:48 GMT+0200 (Central European Summer Time)]`,
[six]: []`,
raw: true
}
}
Expand Down
17 changes: 4 additions & 13 deletions __tests__/adbClient/listSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ two="two"
three=false
four=true
five=null
six=
seven=Sun Jul 17 2022 21:11:48 GMT+0200 (Central European Summer Time)`,
six=`,
raw: true
}
}
Expand All @@ -32,13 +31,7 @@ seven=Sun Jul 17 2022 21:11:48 GMT+0200 (Central European Summer Time)`,
['three', false],
['four', true],
['five', null],
['six', undefined],
[
'seven',
new Date(
'Sun Jul 17 2022 21:11:48 GMT+0200 (Central European Summer Time)'
)
]
['six', undefined]
])
);
} finally {
Expand Down Expand Up @@ -75,8 +68,7 @@ seven=Sun Jul 17 2022 21:11:48 GMT+0200 (Central European Summer Time)`,
three=false
four=true
five=null
six=
seven=Sun Jul 17 2022 21:11:48 GMT+0200 (Central European Summer Time)`,
six=`,
raw: true
}
}
Expand Down Expand Up @@ -123,8 +115,7 @@ seven=Sun Jul 17 2022 21:11:48 GMT+0200 (Central European Summer Time)`,
three=false
four=true
five=null
six=
seven=Sun Jul 17 2022 21:11:48 GMT+0200 (Central European Summer Time)`,
six=`,
raw: true
}
}
Expand Down
20 changes: 10 additions & 10 deletions __tests__/device/listProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ describe('List properties tests', () => {
{
cmd: 'shell:getprop',
res: {
value: `[one]: [1]
value: `[one]: [int]
[two]: [string]
[three]: [bool]
[four]: [bool]
[five]: [string]
[six]: [string]
[one]: [1]
[two]: [two]
[three]: [false]
[four]: [true]
[five]: [null]
[six]: []
[seven]: [Sun Jul 17 2022 21:11:48 GMT+0200 (Central European Summer Time)]`,
`,
raw: true
}
}
Expand All @@ -40,14 +46,8 @@ describe('List properties tests', () => {
['two', 'two'],
['three', false],
['four', true],
['five', null],
['six', undefined],
[
'seven',
new Date(
'Sun Jul 17 2022 21:11:48 GMT+0200 (Central European Summer Time)'
)
]
['five', 'null'],
['six', '']
])
);
} finally {
Expand Down
11 changes: 2 additions & 9 deletions __tests__/device/listSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ two="two"
three=false
four=true
five=null
six=
seven=Sun Jul 17 2022 21:11:48 GMT+0200 (Central European Summer Time)`,
six=`,
raw: true
}
}
Expand All @@ -30,13 +29,7 @@ seven=Sun Jul 17 2022 21:11:48 GMT+0200 (Central European Summer Time)`,
['three', false],
['four', true],
['five', null],
['six', undefined],
[
'seven',
new Date(
'Sun Jul 17 2022 21:11:48 GMT+0200 (Central European Summer Time)'
)
]
['six', undefined]
])
);
} finally {
Expand Down
37 changes: 6 additions & 31 deletions __tests__/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,6 @@ describe('String to type', () => {
const result = stringToType('[]');
expect(result).toBe('[]');
});

it('Cast string date as Date', () => {
const result = stringToType('Mon Dec 20 15:05:47 UTC 2021');
expect(result).toEqual(new Date('Mon Dec 20 15:05:47 UTC 2021'));
});

it('Cast iso date as Date', () => {
const date = new Date();
const result = stringToType(date.toISOString());
expect(result).toEqual(date);
});
});

describe('Parse primitive type', () => {
Expand All @@ -125,8 +114,7 @@ describe('Find matches', () => {
[four]: [true]
[five]: [null]
[six]: [[]]
[seven]: [Sun Jul 17 2022 21:11:48 GMT+0200 (Central European Summer Time)]
[eight]: []`,
[seven]: []`,
/^\[([\s\S]*?)\]: \[([\s\S]*?)\]?$/gm
);
expect(result).toEqual([
Expand All @@ -136,11 +124,7 @@ describe('Find matches', () => {
['four', 'true'],
['five', 'null'],
['six', '[]'],
[
'seven',
'Sun Jul 17 2022 21:11:48 GMT+0200 (Central European Summer Time)'
],
['eight', '']
['seven', '']
]);
});

Expand All @@ -152,8 +136,7 @@ describe('Find matches', () => {
[four]: [true]
[five]: [null]
[six]: [[]]
[seven]: [Sun Jul 17 2022 21:11:48 GMT+0200 (Central European Summer Time)]
[eight]: []`,
[seven]: []`,
/^\[([\s\S]*?)\]: \[([\s\S]*?)\]?$/gm,
'map'
);
Expand All @@ -165,13 +148,7 @@ describe('Find matches', () => {
['four', true],
['five', null],
['six', '[]'],
[
'seven',
new Date(
'Sun Jul 17 2022 21:11:48 GMT+0200 (Central European Summer Time)'
)
],
['eight', undefined]
['seven', undefined]
])
);
});
Expand All @@ -184,8 +161,7 @@ describe('Find matches', () => {
[four]: [true]
[five]: [null]
[six]: [[]]
[seven]: [Sun Jul 17 2022 21:11:48 GMT+0200 (Central European Summer Time)]
[eight]: []`,
[seven]: []`,
/^\[([\s\S]*?)\]: \[([\s\S]*?)\]?$/gm,
'list'
);
Expand All @@ -196,8 +172,7 @@ describe('Find matches', () => {
'four',
'five',
'six',
'seven',
'eight'
'seven'
]);
});
});
Expand Down

0 comments on commit 69675af

Please sign in to comment.