2016-07-12 16:55:06 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2016-07-21 20:12:00 -04:00
|
|
|
import {fakeAsync} from '@angular/core/testing/fake_async';
|
2016-07-12 16:55:06 -04:00
|
|
|
import {beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal';
|
|
|
|
|
2016-08-01 14:33:35 -04:00
|
|
|
import {SyncAsyncResult, splitAtColon} from '../src/util';
|
2016-07-12 16:55:06 -04:00
|
|
|
|
|
|
|
export function main() {
|
|
|
|
describe('util', () => {
|
|
|
|
describe('SyncAsyncResult', () => {
|
|
|
|
it('async value should default to Promise.resolve(syncValue)', fakeAsync(() => {
|
|
|
|
const syncValue = {};
|
|
|
|
const sar = new SyncAsyncResult(syncValue);
|
|
|
|
sar.asyncResult.then((v: any) => expect(v).toBe(syncValue));
|
|
|
|
}));
|
|
|
|
});
|
2016-08-01 14:33:35 -04:00
|
|
|
|
|
|
|
describe('splitAtColon', () => {
|
|
|
|
it('should split when a single ":" is present', () => {
|
|
|
|
expect(splitAtColon('a:b', [])).toEqual(['a', 'b']);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should trim parts', () => { expect(splitAtColon(' a : b ', [])).toEqual(['a', 'b']); });
|
|
|
|
|
|
|
|
it('should support multiple ":"', () => {
|
|
|
|
expect(splitAtColon('a:b:c', [])).toEqual(['a', 'b:c']);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should use the default value when no ":" is present', () => {
|
|
|
|
expect(splitAtColon('ab', ['c', 'd'])).toEqual(['c', 'd']);
|
|
|
|
});
|
|
|
|
});
|
2016-07-21 20:12:00 -04:00
|
|
|
});
|
2016-07-12 16:55:06 -04:00
|
|
|
}
|