Documentation ¶
Overview ¶
Package fakes implements fake implementations of Chrome's extension APIs to ease unit testing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Errs ¶
type Errs struct { // Get is the error that should be returned by Storage.Get(). Get error // Set is the error that should be returned by Storage.Set(). Set error // Delete is the error that should be returned by Storage.Delete(). Delete error }
Errs contains errors that should be returned by the fake implementation.
type MemStorage ¶
type MemStorage struct {
// contains filtered or unexported fields
}
MemStorage is a fake implementation of Chrome's storage API.
func NewMemStorage ¶
func NewMemStorage() *MemStorage
NewMemStorage returns a fake implementation of Chrome's storage API.
func (*MemStorage) Delete ¶
func (m *MemStorage) Delete(keys []string, callback func(err error))
Delete is a fake implmentation of chrome.Storage.Delete().
func (*MemStorage) Get ¶
func (m *MemStorage) Get(callback func(data map[string]interface{}, err error))
Get is a fake implmentation of chrome.Storage.Get().
func (*MemStorage) Set ¶
func (m *MemStorage) Set(data map[string]interface{}, callback func(err error))
Set is a fake implmentation of chrome.Storage.Set().
func (*MemStorage) SetError ¶
func (m *MemStorage) SetError(err Errs)
SetError specifies the errors that should be returned from various operations. Forcing the fake implementation to return errors is useful to test error conditions in unit tests.
type MessageHub ¶
type MessageHub struct {
// contains filtered or unexported fields
}
MessageHub is a fake implementation of Chrome's messaging APIs.
func NewMessageHub ¶
func NewMessageHub() *MessageHub
NewMessageHub returns a fake implementation of Chrome's messaging APIs.
func (*MessageHub) Error ¶
func (m *MessageHub) Error() error
Error is a fake implementation of chrome.C.Error. This fake implementation does not simulate errors, so Error() always returns nil.
func (*MessageHub) OnMessage ¶
func (m *MessageHub) OnMessage(callback func(header *js.Object, sender *js.Object, sendResponse func(interface{})) bool)
OnMessage is a fake implementation of chrome.C.OnMessage.
func (*MessageHub) SendMessage ¶
func (m *MessageHub) SendMessage(msg interface{}, callback func(rsp *js.Object))
SendMessage is a fake implementation of chrome.C.SendMessage.