You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1.3 KiB
30 lines
1.3 KiB
"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' }); |
|
}); |
|
});
|
|
|