forked from sheepzh/time-tracker-4-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsite.test.ts
More file actions
27 lines (22 loc) · 1.21 KB
/
site.test.ts
File metadata and controls
27 lines (22 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
* Copyright (c) 2021 Hengyang Zhang
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
import { extractSiteName, generateSiteLabel } from "@util/site"
test('extract site name', () => {
expect(extractSiteName("")).toEqual(undefined)
expect(extractSiteName(" ")).toEqual(undefined)
expect(extractSiteName('Product Hunt – The best new products in tech.')).toEqual('Product Hunt')
expect(extractSiteName('Product Hunt – The - best new products in tech.')).toEqual('The')
expect(extractSiteName('Office 365 登录 | Microsoft Office')).toEqual('Microsoft Office')
expect(extractSiteName('首页 - 知乎')).toEqual('知乎')
expect(extractSiteName('哔哩哔哩 (゜-゜)つロ 干杯~-bilibili', 'www.bilibili.com')).toEqual('bilibili')
expect(extractSiteName('SurveyMonkey: The World’s Most Popular Free Online Survey Tool')).toEqual('SurveyMonkey')
})
test('generateSiteLabel', () => {
expect(generateSiteLabel('www.baidu.com', '百度')).toEqual('百度 (www.baidu.com)')
expect(generateSiteLabel('www.baidu.com', '')).toEqual('www.baidu.com')
expect(generateSiteLabel('www.baidu.com', undefined)).toEqual('www.baidu.com')
})