提交 07daf7fe 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

add unit test for hostname() (#151)

上级 7d885e4b
/**
* Wechaty - Wechat for Bot. Connecting ChatBots
*
* Licenst: ISC
* https://github.com/wechaty/wechaty
*
*/
import { test } from 'ava'
import {
BrowserCookie
} from './browser-cookie'
import { BrowserDriver } from './browser-driver'
test('hostname() for wx.qq.com', async t => {
const driver = <BrowserDriver>{}
const browserCookie = new BrowserCookie(driver, 'test/fixture/profile/qq.wechaty.json')
const hostname = await browserCookie.hostname()
t.is(hostname, 'wx.qq.com', 'should get wx.qq.com')
})
test('hostname() for wechat.com', async t => {
const driver = <BrowserDriver>{}
const browserCookie = new BrowserCookie(driver, 'test/fixture/profile/wechat.wechaty.json')
const hostname = await browserCookie.hostname()
t.is(hostname, 'wechat.com', 'should get wechat.com')
})
test('hostname() for default', async t => {
const driver = <BrowserDriver>{}
const browserCookie = new BrowserCookie(driver)
const hostname = await browserCookie.hostname()
t.is(hostname, 'wx.qq.com', 'should get wx.qq.com')
})
test('hostname() for file not exist', async t => {
const driver = <BrowserDriver>{}
const browserCookie = new BrowserCookie(driver, 'file-not-exist.wechaty.json')
const hostname = await browserCookie.hostname()
t.is(hostname, 'wx.qq.com', 'should get wx.qq.com for non exist file')
})
[{"domain":".qq.com","expiry":2147385600,"httpOnly":false,"name":"pgv_pvi","path":"/","secure":false,"value":"8512099328"},{"domain":".qq.com","httpOnly":false,"name":"pgv_si","path":"/","secure":false,"value":"s5248662528"},{"domain":".wx.qq.com","expiry":1482380243,"httpOnly":false,"name":"mm_lang","path":"/","secure":false,"value":"en"}]
[{"domain":".wechat.com","expiry":1482380361,"httpOnly":false,"name":"mm_lang","path":"/","secure":false,"value":"en_US"},{"domain":".wechat.com","expiry":1797697161,"httpOnly":false,"name":"webwx_auth_ticket","path":"/","secure":false,"value":"CIsBEIW4yZYPGoABjgOYg33uUb4ct38aQsfT/zJ8FDNF8yKX4o4sJT7aVXjvBUjBLC/SXBj38TSCEmWsK8DME2FzDUl4kS2vXalfNnAFdScEuveH/h7T2CbHbvv5O4fDfxW2Olb5OQoWLrS61Wkx0XjghelAhyusVCGHiRVTtHaCx4gfyHk4+QyRiYc="},{"domain":".wechat.com","expiry":1797697161,"httpOnly":false,"name":"webwxuvid","path":"/","secure":false,"value":"e2108c64dbecd6ea0e3bc7a0266f467dcc63350fbc55559cdf6c25afd6f8bd88c7216d3aaec6427e41c2b918872bb549"},{"domain":".wechat.com","expiry":1482380361,"httpOnly":false,"name":"webwx_data_ticket","path":"/","secure":false,"value":"gScvXIoeHANgdX4Dq5kOjAGY"},{"domain":".wechat.com","httpOnly":false,"name":"pgv_si","path":"/","secure":false,"value":"s4528565248"},{"domain":".wechat.com","expiry":1482380361,"httpOnly":false,"name":"wxloadtime","path":"/","secure":false,"value":"1482337161"},{"domain":".wechat.com","expiry":1482380361,"httpOnly":false,"name":"wxsid","path":"/","secure":false,"value":"GURmztH40ijJuL3f"},{"domain":".wechat.com","expiry":2147385600,"httpOnly":false,"name":"pgv_pvi","path":"/","secure":false,"value":"6397004800"},{"domain":".wechat.com","expiry":1482380361,"httpOnly":false,"name":"wxuin","path":"/","secure":false,"value":"278208447"}]
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册