"use strict"; var buildUnwrapper_1 = require("../buildUnwrapper"); describe('buildUnwrapper', function () { it('should return unwrapped action', function () { var unwrap = buildUnwrapper_1["default"]('Foo'); expect(unwrap({ type: 'Foo.Bar' })).toEqual({ type: 'Bar' }); }); it('should not match when action does not start with pattern', function () { var unwrap = buildUnwrapper_1["default"]('Foo'); expect(unwrap({ type: 'BarFoo' })).toBeNull(); expect(unwrap({ type: 'Bar.Foo' })).toBeNull(); }); it('should return pattern for exact match', function () { var pattern = 'Foo'; var unwrap = buildUnwrapper_1["default"](pattern); expect(unwrap({ type: pattern })).toEqual({ type: pattern }); }); it('should pass through the content of the action when matched', function () { var unwrap = buildUnwrapper_1["default"]('Foo'); expect(unwrap({ type: 'Foo.Bar', payload: 42 })).toEqual({ type: 'Bar', payload: 42 }); }); it('should be able to use as parameterized unwrapper', function () { var unwrap = buildUnwrapper_1["default"]('Foo'); expect(unwrap({ type: 'Foo.1.Bar' })).toEqual({ type: '1.Bar' }); }); });