There are three type of selectors:
- basic
- cached
- cached factory
// Basic
const selectUsers = state => get(state, '_entites.users');| const doAdd = (a, b, callback) => { | |
| callback(a + b); | |
| }; | |
| test("calls callback with arguments added", () => { | |
| const mockCallback = jest.fn(); | |
| doAdd(1, 2, mockCallback); | |
| expect(mockCallback).toHaveBeenCalledWith(3); | |
| }); |
| test("mock implementation", () => { | |
| const mock = jest.fn(() => "bar"); | |
| expect(mock("foo")).toBe("bar"); | |
| expect(mock).toHaveBeenCalledWith("foo"); | |
| }); | |
| test("also mock implementation", () => { | |
| const mock = jest.fn().mockImplementation(() => "bar"); |
| test("returns undefined by default", () => { | |
| const mock = jest.fn(); | |
| let result = mock("foo"); | |
| expect(result).toBeUndefined(); | |
| expect(mock).toHaveBeenCalled(); | |
| expect(mock).toHaveBeenCalledTimes(1); | |
| expect(mock).toHaveBeenCalledWith("foo"); | |
| }); |
| { | |
| "/Users/rph/dev/oss/jest-coverage-leak/module.js": { | |
| "path": "/Users/rph/dev/oss/jest-coverage-leak/module.js", | |
| "statementMap": { | |
| "0": { | |
| "start": { | |
| "line": 1, | |
| "column": 13 | |
| }, | |
| "end": { |
I hereby claim:
To claim this, I am signing this object:
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <!-- This policy is broken --> | |
| <meta http-equiv="Content-Security-Policy" content="script-src * 'unsafe-inline'"> | |
| <!-- This policy works --> | |
| <!--<meta http-equiv="Content-Security-Policy" content="script-src * 'unsafe-inline' 'unsafe-eval">--> | |
| <script src="https://code.jquery.com/jquery-2.2.1.min.js" integrity="sha256-gvQgAFzTH6trSrAWoH1iPo9Xc96QxSZ3feW6kem+O00=" crossorigin="anonymous"></script> |
| . |
| import notifs | |
| def print_notification(title, message): | |
| print "Notification received: {0}: {1}".format(title, message) | |
| def web_app_notify(title, message): | |
| print "Webapp notification received: {0}: {1}".format(title, message) | |
| def iphone_app_notify(title, message): | |
| print "iPhone App notification received: {0}: {1}".format(title, message) |