UNPKG

@cainiaofe/cn-utils

Version:

菜鸟前端基础工具库

52 lines (51 loc) 2.44 kB
import { PROD, PRE, TEST, DAILY, getCnEnv } from '../index'; test('verbose', function () { expect(getCnEnv({ hostname: 'http://127.0.0.1:7210/#/xxx' })).toBe(DAILY); expect(getCnEnv({ hostname: '127.0.0.1:7210/#/xxx' })).toBe(DAILY); expect(getCnEnv({ hostname: '127.0.0.1:7210' })).toBe(DAILY); }); test('daily', function () { expect(getCnEnv({ hostname: '127.0.0.1' })).toBe(DAILY); expect(getCnEnv({ hostname: 'localhost' })).toBe(DAILY); expect(getCnEnv({ hostname: '30.117.72.7' })).toBe(DAILY); }); test('国际-gpn', function () { expect(getCnEnv({ hostname: 'os.gpn.cainiao-inc.com' })).toBe(PROD); expect(getCnEnv({ hostname: 'pre-os.gpn.cainiao-inc.com' })).toBe(PRE); expect(getCnEnv({ hostname: 'daily.os.gpn.cainiao-inc.test' })).toBe(DAILY); }); test('pk', function () { expect(getCnEnv({ hostname: 'pre2-pk.cainiao.com' })).toBe(PRE); }); test('ct', function () { expect(getCnEnv({ hostname: 'daily-ct.cainiao.test' })).toBe(DAILY); }); test('企业智能-hr', function () { expect(getCnEnv({ hostname: 'hr.cainiao.com' })).toBe(PROD); expect(getCnEnv({ hostname: 'pre-hr.cainiao.com' })).toBe(PRE); expect(getCnEnv({ hostname: 'hr.cainiao.test' })).toBe(TEST); }); test('国内-cwoutprod', function () { expect(getCnEnv({ hostname: 'cwoutprod.cainiao.com' })).toBe(PROD); expect(getCnEnv({ hostname: 'pre-cwoutprod.cainiao.com' })).toBe(PRE); }); test('国内-inbound', function () { expect(getCnEnv({ hostname: 'cw-inbound.cainiao.com' })).toBe(PROD); expect(getCnEnv({ hostname: 'pre.cw-inbound.cainiao.com' })).toBe(PRE); }); test('地网-park', function () { expect(getCnEnv({ hostname: 'park.cainiao.com' })).toBe(PROD); expect(getCnEnv({ hostname: 'pre-park.cainiao.com' })).toBe(PRE); expect(getCnEnv({ hostname: 'park.cainiao.test' })).toBe(TEST); }); test('iot', function () { expect(getCnEnv({ hostname: 'iot.cainiao.com' })).toBe(PROD); expect(getCnEnv({ hostname: 'pre-iot.cainiao.com' })).toBe(PRE); expect(getCnEnv({ hostname: 'iot.cainiao.test' })).toBe(TEST); }); test('src', function () { var prodSrc = 'https://g.alicdn.com/cnxt/web-app-sample/0.1.25/js/app.js'; var devSrc = 'https://dev.g.alicdn.com/cnxt/web-app-sample/0.1.25/js/app.js'; expect(getCnEnv({ hostname: 'xxx', currentScriptSrc: prodSrc })).toBe(PROD); expect(getCnEnv({ hostname: 'xxx', currentScriptSrc: devSrc })).toBe(DAILY); });