refactor: kill MapWrapper

This commit is contained in:
Victor Berchet 2016-11-03 17:05:03 -07:00 committed by vikerman
parent ec92f4b198
commit 2a3f4d7b17
2 changed files with 14 additions and 22 deletions

View File

@ -8,8 +8,6 @@
import {SpyObject} from '@angular/core/testing/testing_internal';
import {MapWrapper} from '../../platform-browser/src/facade/collection';
class TestObj {
prop: any;
constructor(prop: any) { this.prop = prop; }
@ -25,9 +23,9 @@ export function main() {
describe('testing', () => {
describe('equality', () => {
it('should structurally compare objects', () => {
var expected = new TestObj(new TestObj({'one': [1, 2]}));
var actual = new TestObj(new TestObj({'one': [1, 2]}));
var falseActual = new TestObj(new TestObj({'one': [1, 3]}));
const expected = new TestObj(new TestObj({'one': [1, 2]}));
const actual = new TestObj(new TestObj({'one': [1, 2]}));
const falseActual = new TestObj(new TestObj({'one': [1, 3]}));
expect(actual).toEqual(expected);
expect(falseActual).not.toEqual(expected);
@ -36,7 +34,8 @@ export function main() {
describe('toEqual for Maps', () => {
it('should detect equality for same reference', () => {
var m1 = MapWrapper.createFromStringMap({'a': 1});
const m1: Map<string, number> = new Map();
m1.set('a', 1);
expect(m1).toEqual(m1);
});
@ -49,15 +48,18 @@ export function main() {
});
it('should detect missing entries', () => {
expect(MapWrapper.createFromStringMap({
'a': 1
})).not.toEqual(MapWrapper.createFromStringMap({}));
const m1: Map<string, number> = new Map();
m1.set('a', 1);
const m2: Map<string, number> = new Map();
expect(m1).not.toEqual(m2);
});
it('should detect different values', () => {
expect(MapWrapper.createFromStringMap({
'a': 1
})).not.toEqual(MapWrapper.createFromStringMap({'a': 2}));
const m1: Map<string, number> = new Map();
m1.set('a', 1);
const m2: Map<string, number> = new Map();
m2.set('a', 2);
expect(m1).not.toEqual(m2);
});
it('should detect additional entries', () => {

View File

@ -8,16 +8,6 @@
import {getSymbolIterator, isJsObject, isPresent} from './lang';
export class MapWrapper {
static createFromStringMap<T>(stringMap: {[key: string]: T}): Map<string, T> {
const result = new Map<string, T>();
for (let prop in stringMap) {
result.set(prop, stringMap[prop]);
}
return result;
}
}
/**
* Wraps Javascript Objects
*/