123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- import { assert } from 'chai';
- import { Utils } from '../../../src/utils/Utils';
- describe('Utils', () => {
- describe('extractDomainFrom', () => {
- describe('Variant #1: simple url', () => {
- const url: string = 'http://google.ru';
- const expectedDomain: string = 'google.ru';
- let domain: string;
- before(() => {
- domain = Utils.extractDomainFrom(url);
- });
- it('should extract domain from the given URL', () => {
- assert.equal(domain, expectedDomain);
- });
- });
- describe('Variant #2: url with `www` part', () => {
- const url: string = 'http://www.google.ru';
- const expectedDomain: string = 'www.google.ru';
- let domain: string;
- before(() => {
- domain = Utils.extractDomainFrom(url);
- });
- it('should extract domain from the given URL', () => {
- assert.equal(domain, expectedDomain);
- });
- });
- describe('Variant #3: url with `https` protocol and port', () => {
- const url: string = 'https://www.google.ru:9000';
- const expectedDomain: string = 'www.google.ru';
- let domain: string;
- before(() => {
- domain = Utils.extractDomainFrom(url);
- });
- it('should extract domain from the given URL', () => {
- assert.equal(domain, expectedDomain);
- });
- });
- describe('Variant #4: protocol-wide url and route', () => {
- const url: string = '//google.ru/abc';
- const expectedDomain: string = 'google.ru';
- let domain: string;
- before(() => {
- domain = Utils.extractDomainFrom(url);
- });
- it('should extract domain from the given URL', () => {
- assert.equal(domain, expectedDomain);
- });
- });
- describe('Variant #5: protocol-wide url, `localhost` and port', () => {
- const url: string = '//localhost:9000';
- const expectedDomain: string = 'localhost';
- let domain: string;
- before(() => {
- domain = Utils.extractDomainFrom(url);
- });
- it('should extract domain from the given URL', () => {
- assert.equal(domain, expectedDomain);
- });
- });
- });
- describe('buildVersionMessage', () => {
- describe('Variant #1: version and build timestamp are set', () => {
- const expectedVersionMessage: string = '0.1.0_2020-01-01T00:00:00.000Z';
- let versionMessage: string;
- before(() => {
- versionMessage = Utils.buildVersionMessage('0.1.0', '1577836800000');
- });
- it('should build version message', () => {
- assert.equal(versionMessage, expectedVersionMessage);
- });
- });
- describe('Variant #2: version is not set set', () => {
- const expectedVersionMessage: string = 'unknown';
- let versionMessage: string;
- before(() => {
- versionMessage = Utils.buildVersionMessage(undefined, '1577836800000');
- });
- it('should build version message', () => {
- assert.equal(versionMessage, expectedVersionMessage);
- });
- });
- describe('Variant #3: build timestamp is not set set', () => {
- const expectedVersionMessage: string = 'unknown';
- let versionMessage: string;
- before(() => {
- versionMessage = Utils.buildVersionMessage('0.1.0', undefined);
- });
- it('should build version message', () => {
- assert.equal(versionMessage, expectedVersionMessage);
- });
- });
- });
- });
|