From 2a3f4d7b172ed056494fcdfb45b784bd6139708f Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Thu, 3 Nov 2016 17:05:03 -0700 Subject: [PATCH] refactor: kill MapWrapper --- .../core/test/testing_internal_spec.ts | 26 ++++++++++--------- modules/@angular/facade/src/collection.ts | 10 ------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/modules/@angular/core/test/testing_internal_spec.ts b/modules/@angular/core/test/testing_internal_spec.ts index 45a42fe0cd..c366e853bd 100644 --- a/modules/@angular/core/test/testing_internal_spec.ts +++ b/modules/@angular/core/test/testing_internal_spec.ts @@ -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 = 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 = new Map(); + m1.set('a', 1); + const m2: Map = 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 = new Map(); + m1.set('a', 1); + const m2: Map = new Map(); + m2.set('a', 2); + expect(m1).not.toEqual(m2); }); it('should detect additional entries', () => { diff --git a/modules/@angular/facade/src/collection.ts b/modules/@angular/facade/src/collection.ts index 6fd5d69d19..a5c6fc07a7 100644 --- a/modules/@angular/facade/src/collection.ts +++ b/modules/@angular/facade/src/collection.ts @@ -8,16 +8,6 @@ import {getSymbolIterator, isJsObject, isPresent} from './lang'; -export class MapWrapper { - static createFromStringMap(stringMap: {[key: string]: T}): Map { - const result = new Map(); - for (let prop in stringMap) { - result.set(prop, stringMap[prop]); - } - return result; - } -} - /** * Wraps Javascript Objects */