38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { readDeviceInfo } from '../../web/src/deviceInfo.js';
|
|
|
|
test('모델 힌트가 없거나 거절된 브라우저도 정상 연결할 수 있다', async () => {
|
|
assert.deepEqual(await readDeviceInfo({}), { model: '', platform: '', manufacturer: '' });
|
|
assert.deepEqual(
|
|
await readDeviceInfo({
|
|
userAgentData: {
|
|
getHighEntropyValues: async () => {
|
|
throw Error('withheld');
|
|
},
|
|
},
|
|
}),
|
|
{},
|
|
);
|
|
});
|
|
test('Android 모델을 구분하고 브라우저 브랜드를 제조사로 사용하지 않는다', async () => {
|
|
const nav = {
|
|
userAgentData: {
|
|
getHighEntropyValues: async (hints) => {
|
|
assert.deepEqual(hints, ['model']);
|
|
return { model: 'SM-S938B', platform: 'Android', brands: [{ brand: 'Chrome' }] };
|
|
},
|
|
},
|
|
};
|
|
assert.deepEqual(await readDeviceInfo(nav), {
|
|
model: 'SM-S938B',
|
|
platform: 'Android',
|
|
manufacturer: 'Samsung',
|
|
});
|
|
nav.userAgentData.getHighEntropyValues = async () => ({
|
|
model: 'Unknown phone',
|
|
platform: 'Android',
|
|
});
|
|
assert.equal((await readDeviceInfo(nav)).manufacturer, '');
|
|
});
|