@metamask/snaps-jest 0.37.2-flask.1 → 0.37.4-flask.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -1
- package/dist/cjs/matchers.js.map +1 -1
- package/dist/esm/matchers.js.map +1 -1
- package/dist/types/matchers.d.ts +1 -1
- package/package.json +12 -11
package/CHANGELOG.md
CHANGED
|
@@ -6,11 +6,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.37.4-flask.1]
|
|
10
|
+
### Fixed
|
|
11
|
+
- Remove unused dependencies ([#1680](https://github.com/MetaMask/snaps/pull/1680))
|
|
12
|
+
|
|
13
|
+
## [0.37.3-flask.1]
|
|
14
|
+
### Changed
|
|
15
|
+
- Bump `semver` to `^7.5.4` ([#1631](https://github.com/MetaMask/snaps/pull/1631))
|
|
16
|
+
|
|
9
17
|
## [0.37.2-flask.1]
|
|
10
18
|
### Changed
|
|
11
19
|
- Release package independently ([#1600](https://github.com/MetaMask/snaps/pull/1600))
|
|
12
20
|
- The version of the package no longer needs to match the version of all other
|
|
13
21
|
MetaMask Snaps packages.
|
|
14
22
|
|
|
15
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@0.37.
|
|
23
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@0.37.4-flask.1...HEAD
|
|
24
|
+
[0.37.4-flask.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@0.37.3-flask.1...@metamask/snaps-jest@0.37.4-flask.1
|
|
25
|
+
[0.37.3-flask.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@0.37.2-flask.1...@metamask/snaps-jest@0.37.3-flask.1
|
|
16
26
|
[0.37.2-flask.1]: https://github.com/MetaMask/snaps/releases/tag/@metamask/snaps-jest@0.37.2-flask.1
|
package/dist/cjs/matchers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/matchers.ts"],"sourcesContent":["/* eslint-disable no-invalid-this */\n\n// Note: Because this file imports from `@jest/globals`, it can only be used in\n// a Jest environment. This is why it's not exported from the index file.\n\nimport { expect } from '@jest/globals';\nimport type { NotificationType } from '@metamask/rpc-methods';\nimport type { Component } from '@metamask/snaps-ui';\nimport type { EnumToUnion } from '@metamask/snaps-utils';\nimport type { Json } from '@metamask/utils';\nimport { hasProperty } from '@metamask/utils';\nimport type { MatcherFunction } from 'expect';\nimport type { MatcherHintOptions } from 'jest-matcher-utils';\nimport {\n diff,\n matcherErrorMessage,\n matcherHint,\n printReceived,\n printWithType,\n RECEIVED_COLOR,\n} from 'jest-matcher-utils';\nimport { is } from 'superstruct';\n\nimport { InterfaceStruct, SnapResponseStruct } from './internals';\nimport type { SnapResponse } from './types';\n\n/**\n * Ensure that the actual value is a response from the `request` function.\n *\n * @param actual - The actual value.\n * @param matcherName - The name of the matcher.\n * @param options - The matcher options.\n */\nfunction assertActualIsSnapResponse(\n actual: unknown,\n matcherName: string,\n options?: MatcherHintOptions,\n): asserts actual is SnapResponse {\n if (!is(actual, SnapResponseStruct)) {\n throw new Error(\n matcherErrorMessage(\n matcherHint(matcherName, undefined, undefined, options),\n `${RECEIVED_COLOR(\n 'received',\n )} value must be a response from the \\`request\\` function`,\n printWithType('Received', actual, printReceived),\n ),\n );\n }\n}\n\n/**\n * Ensure that the actual value is a response from the `request` function, and\n * that it has a `ui` property.\n *\n * @param actual - The actual value.\n * @param matcherName - The name of the matcher.\n * @param options - The matcher options.\n */\nfunction assertHasInterface(\n actual: unknown,\n matcherName: string,\n options?: MatcherHintOptions,\n): asserts actual is { content: Component } {\n if (!is(actual, InterfaceStruct) || !actual.content) {\n throw new Error(\n matcherErrorMessage(\n matcherHint(matcherName, undefined, undefined, options),\n `${RECEIVED_COLOR('received')} value must have a \\`content\\` property`,\n printWithType('Received', actual, printReceived),\n ),\n );\n }\n}\n\n/**\n * Check if a JSON-RPC response matches the expected value. This matcher is\n * intended to be used with the `expect` global.\n *\n * @param actual - The actual response.\n * @param expected - The expected response.\n * @returns The status and message.\n */\nexport const toRespondWith: MatcherFunction<[expected: Json]> = function (\n actual,\n expected,\n) {\n assertActualIsSnapResponse(actual, 'toRespondWith');\n\n const { response } = actual;\n if (hasProperty(response, 'error')) {\n const message = () =>\n `${this.utils.matcherHint('.toRespondWith')}\\n\\n` +\n `Expected response: ${this.utils.printExpected(expected)}\\n` +\n `Received error: ${this.utils.printReceived(response.error)}`;\n\n return { message, pass: false };\n }\n\n const pass = this.equals(response.result, expected);\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRespondWith')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.result)}`\n : () =>\n `${this.utils.matcherHint('.toRespondWith')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.result)}`;\n\n return { message, pass };\n};\n\nexport const toRespondWithError: MatcherFunction<[expected: Json]> = function (\n actual,\n expected,\n) {\n assertActualIsSnapResponse(actual, 'toRespondWithError');\n\n const { response } = actual;\n if (hasProperty(response, 'result')) {\n const message = () =>\n `${this.utils.matcherHint('.toRespondWithError')}\\n\\n` +\n `Expected error: ${this.utils.printExpected(expected)}\\n` +\n `Received result: ${this.utils.printReceived(response.result)}`;\n\n return { message, pass: false };\n }\n\n const pass = this.equals(response.error, expected);\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRespondWithError')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.error)}`\n : () =>\n `${this.utils.matcherHint('.toRespondWithError')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.error)}`;\n\n return { message, pass };\n};\n\n/**\n * Check if the snap sent a notification with the expected message. This matcher\n * is intended to be used with the `expect` global.\n *\n * @param actual - The actual response.\n * @param expected - The expected notification message.\n * @param type - The expected notification type.\n * @returns The status and message.\n */\nexport const toSendNotification: MatcherFunction<\n [expected: string, type?: EnumToUnion<NotificationType> | undefined]\n> = async function (actual, expected, type) {\n assertActualIsSnapResponse(actual, 'toSendNotification');\n\n const { notifications } = actual;\n const pass = notifications.some(\n (notification) =>\n this.equals(notification.message, expected) &&\n (type === undefined || notification.type === type),\n );\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toSendNotification')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Expected type: ${this.utils.printExpected(type)}\\n` +\n `Received: ${this.utils.printReceived(notifications)}`\n : () =>\n `${this.utils.matcherHint('.toSendNotification')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Expected type: ${this.utils.printExpected(type)}\\n` +\n `Received: ${this.utils.printReceived(notifications)}`;\n\n return { message, pass };\n};\n\nexport const toRender: MatcherFunction<[expected: Component]> = function (\n actual,\n expected,\n) {\n assertHasInterface(actual, 'toRender');\n\n const { content } = actual;\n const pass = this.equals(content, expected);\n\n const difference = diff(expected, content);\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toShowInterface')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(content)}` +\n `${difference ? `\\n\\nDifference:\\n\\n${difference}` : ''}`\n : () =>\n `${this.utils.matcherHint('.toShowInterface')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(content)}` +\n `${difference ? `\\n\\nDifference:\\n\\n${difference}` : ''}`;\n\n return { message, pass };\n};\n\nexpect.extend({\n toRespondWith,\n toRespondWithError,\n toSendNotification,\n toRender,\n});\n"],"names":["toRespondWith","toRespondWithError","toSendNotification","toRender","assertActualIsSnapResponse","actual","matcherName","options","is","SnapResponseStruct","Error","matcherErrorMessage","matcherHint","undefined","RECEIVED_COLOR","printWithType","printReceived","assertHasInterface","InterfaceStruct","content","expected","response","hasProperty","message","utils","printExpected","error","pass","equals","result","type","notifications","some","notification","difference","diff","expect","extend"],"mappings":"AAAA,kCAAkC,GAElC,+EAA+E;AAC/E,yEAAyE;;;;;;;;;;;;IAgF5DA,aAAa;eAAbA;;IA8BAC,kBAAkB;eAAlBA;;IAuCAC,kBAAkB;eAAlBA;;IA2BAC,QAAQ;eAARA;;;yBA9KU;uBAKK;kCAUrB;6BACY;2BAEiC;AAGpD;;;;;;CAMC,GACD,SAASC,2BACPC,MAAe,EACfC,WAAmB,EACnBC,OAA4B;IAE5B,IAAI,CAACC,IAAAA,eAAE,EAACH,QAAQI,6BAAkB,GAAG;QACnC,MAAM,IAAIC,MACRC,IAAAA,qCAAmB,EACjBC,IAAAA,6BAAW,EAACN,aAAaO,WAAWA,WAAWN,UAC/C,CAAC,EAAEO,IAAAA,gCAAc,EACf,YACA,uDAAuD,CAAC,EAC1DC,IAAAA,+BAAa,EAAC,YAAYV,QAAQW,+BAAa;IAGrD;AACF;AAEA;;;;;;;CAOC,GACD,SAASC,mBACPZ,MAAe,EACfC,WAAmB,EACnBC,OAA4B;IAE5B,IAAI,CAACC,IAAAA,eAAE,EAACH,QAAQa,0BAAe,KAAK,CAACb,OAAOc,OAAO,EAAE;QACnD,MAAM,IAAIT,MACRC,IAAAA,qCAAmB,EACjBC,IAAAA,6BAAW,EAACN,aAAaO,WAAWA,WAAWN,UAC/C,CAAC,EAAEO,IAAAA,gCAAc,EAAC,YAAY,uCAAuC,CAAC,EACtEC,IAAAA,+BAAa,EAAC,YAAYV,QAAQW,+BAAa;IAGrD;AACF;AAUO,MAAMhB,gBAAmD,SAC9DK,MAAM,EACNe,QAAQ;IAERhB,2BAA2BC,QAAQ;IAEnC,MAAM,EAAEgB,QAAQ,EAAE,GAAGhB;IACrB,IAAIiB,IAAAA,kBAAW,EAACD,UAAU,UAAU;QAClC,MAAME,UAAU,IACd,CAAC,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,CAAC,GAChD,CAAC,EAAEe,aAAa,CAAC,mBAAmB,EAAEA,WAAW,CAAC,GAAG,GAAG,CAAC;IAE/D,OAAO;QAAEX;QAASI;IAAK;AACzB;AAEAS,eAAM,CAACC,MAAM,CAAC;IACZrC;IACAC;IACAC;IACAC;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/matchers.ts"],"sourcesContent":["/* eslint-disable no-invalid-this */\n\n// Note: Because this file imports from `@jest/globals`, it can only be used in\n// a Jest environment. This is why it's not exported from the index file.\n\nimport type { MatcherFunction } from '@jest/expect';\nimport { expect } from '@jest/globals';\nimport type { NotificationType } from '@metamask/rpc-methods';\nimport type { Component } from '@metamask/snaps-ui';\nimport type { EnumToUnion } from '@metamask/snaps-utils';\nimport type { Json } from '@metamask/utils';\nimport { hasProperty } from '@metamask/utils';\nimport type { MatcherHintOptions } from 'jest-matcher-utils';\nimport {\n diff,\n matcherErrorMessage,\n matcherHint,\n printReceived,\n printWithType,\n RECEIVED_COLOR,\n} from 'jest-matcher-utils';\nimport { is } from 'superstruct';\n\nimport { InterfaceStruct, SnapResponseStruct } from './internals';\nimport type { SnapResponse } from './types';\n\n/**\n * Ensure that the actual value is a response from the `request` function.\n *\n * @param actual - The actual value.\n * @param matcherName - The name of the matcher.\n * @param options - The matcher options.\n */\nfunction assertActualIsSnapResponse(\n actual: unknown,\n matcherName: string,\n options?: MatcherHintOptions,\n): asserts actual is SnapResponse {\n if (!is(actual, SnapResponseStruct)) {\n throw new Error(\n matcherErrorMessage(\n matcherHint(matcherName, undefined, undefined, options),\n `${RECEIVED_COLOR(\n 'received',\n )} value must be a response from the \\`request\\` function`,\n printWithType('Received', actual, printReceived),\n ),\n );\n }\n}\n\n/**\n * Ensure that the actual value is a response from the `request` function, and\n * that it has a `ui` property.\n *\n * @param actual - The actual value.\n * @param matcherName - The name of the matcher.\n * @param options - The matcher options.\n */\nfunction assertHasInterface(\n actual: unknown,\n matcherName: string,\n options?: MatcherHintOptions,\n): asserts actual is { content: Component } {\n if (!is(actual, InterfaceStruct) || !actual.content) {\n throw new Error(\n matcherErrorMessage(\n matcherHint(matcherName, undefined, undefined, options),\n `${RECEIVED_COLOR('received')} value must have a \\`content\\` property`,\n printWithType('Received', actual, printReceived),\n ),\n );\n }\n}\n\n/**\n * Check if a JSON-RPC response matches the expected value. This matcher is\n * intended to be used with the `expect` global.\n *\n * @param actual - The actual response.\n * @param expected - The expected response.\n * @returns The status and message.\n */\nexport const toRespondWith: MatcherFunction<[expected: Json]> = function (\n actual,\n expected,\n) {\n assertActualIsSnapResponse(actual, 'toRespondWith');\n\n const { response } = actual;\n if (hasProperty(response, 'error')) {\n const message = () =>\n `${this.utils.matcherHint('.toRespondWith')}\\n\\n` +\n `Expected response: ${this.utils.printExpected(expected)}\\n` +\n `Received error: ${this.utils.printReceived(response.error)}`;\n\n return { message, pass: false };\n }\n\n const pass = this.equals(response.result, expected);\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRespondWith')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.result)}`\n : () =>\n `${this.utils.matcherHint('.toRespondWith')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.result)}`;\n\n return { message, pass };\n};\n\nexport const toRespondWithError: MatcherFunction<[expected: Json]> = function (\n actual,\n expected,\n) {\n assertActualIsSnapResponse(actual, 'toRespondWithError');\n\n const { response } = actual;\n if (hasProperty(response, 'result')) {\n const message = () =>\n `${this.utils.matcherHint('.toRespondWithError')}\\n\\n` +\n `Expected error: ${this.utils.printExpected(expected)}\\n` +\n `Received result: ${this.utils.printReceived(response.result)}`;\n\n return { message, pass: false };\n }\n\n const pass = this.equals(response.error, expected);\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRespondWithError')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.error)}`\n : () =>\n `${this.utils.matcherHint('.toRespondWithError')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.error)}`;\n\n return { message, pass };\n};\n\n/**\n * Check if the snap sent a notification with the expected message. This matcher\n * is intended to be used with the `expect` global.\n *\n * @param actual - The actual response.\n * @param expected - The expected notification message.\n * @param type - The expected notification type.\n * @returns The status and message.\n */\nexport const toSendNotification: MatcherFunction<\n [expected: string, type?: EnumToUnion<NotificationType> | undefined]\n> = async function (actual, expected, type) {\n assertActualIsSnapResponse(actual, 'toSendNotification');\n\n const { notifications } = actual;\n const pass = notifications.some(\n (notification) =>\n this.equals(notification.message, expected) &&\n (type === undefined || notification.type === type),\n );\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toSendNotification')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Expected type: ${this.utils.printExpected(type)}\\n` +\n `Received: ${this.utils.printReceived(notifications)}`\n : () =>\n `${this.utils.matcherHint('.toSendNotification')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Expected type: ${this.utils.printExpected(type)}\\n` +\n `Received: ${this.utils.printReceived(notifications)}`;\n\n return { message, pass };\n};\n\nexport const toRender: MatcherFunction<[expected: Component]> = function (\n actual,\n expected,\n) {\n assertHasInterface(actual, 'toRender');\n\n const { content } = actual;\n const pass = this.equals(content, expected);\n\n const difference = diff(expected, content);\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toShowInterface')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(content)}` +\n `${difference ? `\\n\\nDifference:\\n\\n${difference}` : ''}`\n : () =>\n `${this.utils.matcherHint('.toShowInterface')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(content)}` +\n `${difference ? `\\n\\nDifference:\\n\\n${difference}` : ''}`;\n\n return { message, pass };\n};\n\nexpect.extend({\n toRespondWith,\n toRespondWithError,\n toSendNotification,\n toRender,\n});\n"],"names":["toRespondWith","toRespondWithError","toSendNotification","toRender","assertActualIsSnapResponse","actual","matcherName","options","is","SnapResponseStruct","Error","matcherErrorMessage","matcherHint","undefined","RECEIVED_COLOR","printWithType","printReceived","assertHasInterface","InterfaceStruct","content","expected","response","hasProperty","message","utils","printExpected","error","pass","equals","result","type","notifications","some","notification","difference","diff","expect","extend"],"mappings":"AAAA,kCAAkC,GAElC,+EAA+E;AAC/E,yEAAyE;;;;;;;;;;;;IAgF5DA,aAAa;eAAbA;;IA8BAC,kBAAkB;eAAlBA;;IAuCAC,kBAAkB;eAAlBA;;IA2BAC,QAAQ;eAARA;;;yBA7KU;uBAKK;kCASrB;6BACY;2BAEiC;AAGpD;;;;;;CAMC,GACD,SAASC,2BACPC,MAAe,EACfC,WAAmB,EACnBC,OAA4B;IAE5B,IAAI,CAACC,IAAAA,eAAE,EAACH,QAAQI,6BAAkB,GAAG;QACnC,MAAM,IAAIC,MACRC,IAAAA,qCAAmB,EACjBC,IAAAA,6BAAW,EAACN,aAAaO,WAAWA,WAAWN,UAC/C,CAAC,EAAEO,IAAAA,gCAAc,EACf,YACA,uDAAuD,CAAC,EAC1DC,IAAAA,+BAAa,EAAC,YAAYV,QAAQW,+BAAa;IAGrD;AACF;AAEA;;;;;;;CAOC,GACD,SAASC,mBACPZ,MAAe,EACfC,WAAmB,EACnBC,OAA4B;IAE5B,IAAI,CAACC,IAAAA,eAAE,EAACH,QAAQa,0BAAe,KAAK,CAACb,OAAOc,OAAO,EAAE;QACnD,MAAM,IAAIT,MACRC,IAAAA,qCAAmB,EACjBC,IAAAA,6BAAW,EAACN,aAAaO,WAAWA,WAAWN,UAC/C,CAAC,EAAEO,IAAAA,gCAAc,EAAC,YAAY,uCAAuC,CAAC,EACtEC,IAAAA,+BAAa,EAAC,YAAYV,QAAQW,+BAAa;IAGrD;AACF;AAUO,MAAMhB,gBAAmD,SAC9DK,MAAM,EACNe,QAAQ;IAERhB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CAAC,UAAU,EAAE,IAAI,CAACY,KAAK,CAACC,aAAa,CAACL,UAAU,EAAE,CAAC,GACnD,CAAC,UAAU,EAAE,IAAI,CAACI,KAAK,CAACR,aAAa,CAACG,SAAS,CAAC,GAChD,CAAC,EAAEe,aAAa,CAAC,mBAAmB,EAAEA,WAAW,CAAC,GAAG,GAAG,CAAC;IAE/D,OAAO;QAAEX;QAASI;IAAK;AACzB;AAEAS,eAAM,CAACC,MAAM,CAAC;IACZrC;IACAC;IACAC;IACAC;AACF"}
|
package/dist/esm/matchers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/matchers.ts"],"sourcesContent":["/* eslint-disable no-invalid-this */\n\n// Note: Because this file imports from `@jest/globals`, it can only be used in\n// a Jest environment. This is why it's not exported from the index file.\n\nimport { expect } from '@jest/globals';\nimport type { NotificationType } from '@metamask/rpc-methods';\nimport type { Component } from '@metamask/snaps-ui';\nimport type { EnumToUnion } from '@metamask/snaps-utils';\nimport type { Json } from '@metamask/utils';\nimport { hasProperty } from '@metamask/utils';\nimport type { MatcherFunction } from 'expect';\nimport type { MatcherHintOptions } from 'jest-matcher-utils';\nimport {\n diff,\n matcherErrorMessage,\n matcherHint,\n printReceived,\n printWithType,\n RECEIVED_COLOR,\n} from 'jest-matcher-utils';\nimport { is } from 'superstruct';\n\nimport { InterfaceStruct, SnapResponseStruct } from './internals';\nimport type { SnapResponse } from './types';\n\n/**\n * Ensure that the actual value is a response from the `request` function.\n *\n * @param actual - The actual value.\n * @param matcherName - The name of the matcher.\n * @param options - The matcher options.\n */\nfunction assertActualIsSnapResponse(\n actual: unknown,\n matcherName: string,\n options?: MatcherHintOptions,\n): asserts actual is SnapResponse {\n if (!is(actual, SnapResponseStruct)) {\n throw new Error(\n matcherErrorMessage(\n matcherHint(matcherName, undefined, undefined, options),\n `${RECEIVED_COLOR(\n 'received',\n )} value must be a response from the \\`request\\` function`,\n printWithType('Received', actual, printReceived),\n ),\n );\n }\n}\n\n/**\n * Ensure that the actual value is a response from the `request` function, and\n * that it has a `ui` property.\n *\n * @param actual - The actual value.\n * @param matcherName - The name of the matcher.\n * @param options - The matcher options.\n */\nfunction assertHasInterface(\n actual: unknown,\n matcherName: string,\n options?: MatcherHintOptions,\n): asserts actual is { content: Component } {\n if (!is(actual, InterfaceStruct) || !actual.content) {\n throw new Error(\n matcherErrorMessage(\n matcherHint(matcherName, undefined, undefined, options),\n `${RECEIVED_COLOR('received')} value must have a \\`content\\` property`,\n printWithType('Received', actual, printReceived),\n ),\n );\n }\n}\n\n/**\n * Check if a JSON-RPC response matches the expected value. This matcher is\n * intended to be used with the `expect` global.\n *\n * @param actual - The actual response.\n * @param expected - The expected response.\n * @returns The status and message.\n */\nexport const toRespondWith: MatcherFunction<[expected: Json]> = function (\n actual,\n expected,\n) {\n assertActualIsSnapResponse(actual, 'toRespondWith');\n\n const { response } = actual;\n if (hasProperty(response, 'error')) {\n const message = () =>\n `${this.utils.matcherHint('.toRespondWith')}\\n\\n` +\n `Expected response: ${this.utils.printExpected(expected)}\\n` +\n `Received error: ${this.utils.printReceived(response.error)}`;\n\n return { message, pass: false };\n }\n\n const pass = this.equals(response.result, expected);\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRespondWith')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.result)}`\n : () =>\n `${this.utils.matcherHint('.toRespondWith')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.result)}`;\n\n return { message, pass };\n};\n\nexport const toRespondWithError: MatcherFunction<[expected: Json]> = function (\n actual,\n expected,\n) {\n assertActualIsSnapResponse(actual, 'toRespondWithError');\n\n const { response } = actual;\n if (hasProperty(response, 'result')) {\n const message = () =>\n `${this.utils.matcherHint('.toRespondWithError')}\\n\\n` +\n `Expected error: ${this.utils.printExpected(expected)}\\n` +\n `Received result: ${this.utils.printReceived(response.result)}`;\n\n return { message, pass: false };\n }\n\n const pass = this.equals(response.error, expected);\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRespondWithError')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.error)}`\n : () =>\n `${this.utils.matcherHint('.toRespondWithError')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.error)}`;\n\n return { message, pass };\n};\n\n/**\n * Check if the snap sent a notification with the expected message. This matcher\n * is intended to be used with the `expect` global.\n *\n * @param actual - The actual response.\n * @param expected - The expected notification message.\n * @param type - The expected notification type.\n * @returns The status and message.\n */\nexport const toSendNotification: MatcherFunction<\n [expected: string, type?: EnumToUnion<NotificationType> | undefined]\n> = async function (actual, expected, type) {\n assertActualIsSnapResponse(actual, 'toSendNotification');\n\n const { notifications } = actual;\n const pass = notifications.some(\n (notification) =>\n this.equals(notification.message, expected) &&\n (type === undefined || notification.type === type),\n );\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toSendNotification')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Expected type: ${this.utils.printExpected(type)}\\n` +\n `Received: ${this.utils.printReceived(notifications)}`\n : () =>\n `${this.utils.matcherHint('.toSendNotification')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Expected type: ${this.utils.printExpected(type)}\\n` +\n `Received: ${this.utils.printReceived(notifications)}`;\n\n return { message, pass };\n};\n\nexport const toRender: MatcherFunction<[expected: Component]> = function (\n actual,\n expected,\n) {\n assertHasInterface(actual, 'toRender');\n\n const { content } = actual;\n const pass = this.equals(content, expected);\n\n const difference = diff(expected, content);\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toShowInterface')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(content)}` +\n `${difference ? `\\n\\nDifference:\\n\\n${difference}` : ''}`\n : () =>\n `${this.utils.matcherHint('.toShowInterface')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(content)}` +\n `${difference ? `\\n\\nDifference:\\n\\n${difference}` : ''}`;\n\n return { message, pass };\n};\n\nexpect.extend({\n toRespondWith,\n toRespondWithError,\n toSendNotification,\n toRender,\n});\n"],"names":["expect","hasProperty","diff","matcherErrorMessage","matcherHint","printReceived","printWithType","RECEIVED_COLOR","is","InterfaceStruct","SnapResponseStruct","assertActualIsSnapResponse","actual","matcherName","options","Error","undefined","assertHasInterface","content","toRespondWith","expected","response","message","utils","printExpected","error","pass","equals","result","toRespondWithError","toSendNotification","type","notifications","some","notification","toRender","difference","extend"],"mappings":"AAAA,kCAAkC,GAElC,+EAA+E;AAC/E,yEAAyE;AAEzE,SAASA,MAAM,QAAQ,gBAAgB;AAKvC,SAASC,WAAW,QAAQ,kBAAkB;AAG9C,SACEC,IAAI,EACJC,mBAAmB,EACnBC,WAAW,EACXC,aAAa,EACbC,aAAa,EACbC,cAAc,QACT,qBAAqB;AAC5B,SAASC,EAAE,QAAQ,cAAc;AAEjC,SAASC,eAAe,EAAEC,kBAAkB,QAAQ,cAAc;AAGlE;;;;;;CAMC,GACD,SAASC,2BACPC,MAAe,EACfC,WAAmB,EACnBC,OAA4B;IAE5B,IAAI,CAACN,GAAGI,QAAQF,qBAAqB;QACnC,MAAM,IAAIK,MACRZ,oBACEC,YAAYS,aAAaG,WAAWA,WAAWF,UAC/C,CAAC,EAAEP,eACD,YACA,uDAAuD,CAAC,EAC1DD,cAAc,YAAYM,QAAQP;IAGxC;AACF;AAEA;;;;;;;CAOC,GACD,SAASY,mBACPL,MAAe,EACfC,WAAmB,EACnBC,OAA4B;IAE5B,IAAI,CAACN,GAAGI,QAAQH,oBAAoB,CAACG,OAAOM,OAAO,EAAE;QACnD,MAAM,IAAIH,MACRZ,oBACEC,YAAYS,aAAaG,WAAWA,WAAWF,UAC/C,CAAC,EAAEP,eAAe,YAA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,CAACa,SAAS,CAAC,GAChD,CAAC,EAAEkB,aAAa,CAAC,mBAAmB,EAAEA,WAAW,CAAC,GAAG,GAAG,CAAC,GAC3D,IACE,CAAC,EAAE,IAAI,CAACb,KAAK,CAACnB,WAAW,CAAC,oBAAoB,IAAI,CAAC,GACnD,CAAC,UAAU,EAAE,IAAI,CAACmB,KAAK,CAACC,aAAa,CAACJ,UAAU,EAAE,CAAC,GACnD,CAAC,UAAU,EAAE,IAAI,CAACG,KAAK,CAAClB,aAAa,CAACa,SAAS,CAAC,GAChD,CAAC,EAAEkB,aAAa,CAAC,mBAAmB,EAAEA,WAAW,CAAC,GAAG,GAAG,CAAC;IAE/D,OAAO;QAAEd;QAASI;IAAK;AACzB,EAAE;AAEF1B,OAAOqC,MAAM,CAAC;IACZlB;IACAU;IACAC;IACAK;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/matchers.ts"],"sourcesContent":["/* eslint-disable no-invalid-this */\n\n// Note: Because this file imports from `@jest/globals`, it can only be used in\n// a Jest environment. This is why it's not exported from the index file.\n\nimport type { MatcherFunction } from '@jest/expect';\nimport { expect } from '@jest/globals';\nimport type { NotificationType } from '@metamask/rpc-methods';\nimport type { Component } from '@metamask/snaps-ui';\nimport type { EnumToUnion } from '@metamask/snaps-utils';\nimport type { Json } from '@metamask/utils';\nimport { hasProperty } from '@metamask/utils';\nimport type { MatcherHintOptions } from 'jest-matcher-utils';\nimport {\n diff,\n matcherErrorMessage,\n matcherHint,\n printReceived,\n printWithType,\n RECEIVED_COLOR,\n} from 'jest-matcher-utils';\nimport { is } from 'superstruct';\n\nimport { InterfaceStruct, SnapResponseStruct } from './internals';\nimport type { SnapResponse } from './types';\n\n/**\n * Ensure that the actual value is a response from the `request` function.\n *\n * @param actual - The actual value.\n * @param matcherName - The name of the matcher.\n * @param options - The matcher options.\n */\nfunction assertActualIsSnapResponse(\n actual: unknown,\n matcherName: string,\n options?: MatcherHintOptions,\n): asserts actual is SnapResponse {\n if (!is(actual, SnapResponseStruct)) {\n throw new Error(\n matcherErrorMessage(\n matcherHint(matcherName, undefined, undefined, options),\n `${RECEIVED_COLOR(\n 'received',\n )} value must be a response from the \\`request\\` function`,\n printWithType('Received', actual, printReceived),\n ),\n );\n }\n}\n\n/**\n * Ensure that the actual value is a response from the `request` function, and\n * that it has a `ui` property.\n *\n * @param actual - The actual value.\n * @param matcherName - The name of the matcher.\n * @param options - The matcher options.\n */\nfunction assertHasInterface(\n actual: unknown,\n matcherName: string,\n options?: MatcherHintOptions,\n): asserts actual is { content: Component } {\n if (!is(actual, InterfaceStruct) || !actual.content) {\n throw new Error(\n matcherErrorMessage(\n matcherHint(matcherName, undefined, undefined, options),\n `${RECEIVED_COLOR('received')} value must have a \\`content\\` property`,\n printWithType('Received', actual, printReceived),\n ),\n );\n }\n}\n\n/**\n * Check if a JSON-RPC response matches the expected value. This matcher is\n * intended to be used with the `expect` global.\n *\n * @param actual - The actual response.\n * @param expected - The expected response.\n * @returns The status and message.\n */\nexport const toRespondWith: MatcherFunction<[expected: Json]> = function (\n actual,\n expected,\n) {\n assertActualIsSnapResponse(actual, 'toRespondWith');\n\n const { response } = actual;\n if (hasProperty(response, 'error')) {\n const message = () =>\n `${this.utils.matcherHint('.toRespondWith')}\\n\\n` +\n `Expected response: ${this.utils.printExpected(expected)}\\n` +\n `Received error: ${this.utils.printReceived(response.error)}`;\n\n return { message, pass: false };\n }\n\n const pass = this.equals(response.result, expected);\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRespondWith')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.result)}`\n : () =>\n `${this.utils.matcherHint('.toRespondWith')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.result)}`;\n\n return { message, pass };\n};\n\nexport const toRespondWithError: MatcherFunction<[expected: Json]> = function (\n actual,\n expected,\n) {\n assertActualIsSnapResponse(actual, 'toRespondWithError');\n\n const { response } = actual;\n if (hasProperty(response, 'result')) {\n const message = () =>\n `${this.utils.matcherHint('.toRespondWithError')}\\n\\n` +\n `Expected error: ${this.utils.printExpected(expected)}\\n` +\n `Received result: ${this.utils.printReceived(response.result)}`;\n\n return { message, pass: false };\n }\n\n const pass = this.equals(response.error, expected);\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRespondWithError')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.error)}`\n : () =>\n `${this.utils.matcherHint('.toRespondWithError')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.error)}`;\n\n return { message, pass };\n};\n\n/**\n * Check if the snap sent a notification with the expected message. This matcher\n * is intended to be used with the `expect` global.\n *\n * @param actual - The actual response.\n * @param expected - The expected notification message.\n * @param type - The expected notification type.\n * @returns The status and message.\n */\nexport const toSendNotification: MatcherFunction<\n [expected: string, type?: EnumToUnion<NotificationType> | undefined]\n> = async function (actual, expected, type) {\n assertActualIsSnapResponse(actual, 'toSendNotification');\n\n const { notifications } = actual;\n const pass = notifications.some(\n (notification) =>\n this.equals(notification.message, expected) &&\n (type === undefined || notification.type === type),\n );\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toSendNotification')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Expected type: ${this.utils.printExpected(type)}\\n` +\n `Received: ${this.utils.printReceived(notifications)}`\n : () =>\n `${this.utils.matcherHint('.toSendNotification')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Expected type: ${this.utils.printExpected(type)}\\n` +\n `Received: ${this.utils.printReceived(notifications)}`;\n\n return { message, pass };\n};\n\nexport const toRender: MatcherFunction<[expected: Component]> = function (\n actual,\n expected,\n) {\n assertHasInterface(actual, 'toRender');\n\n const { content } = actual;\n const pass = this.equals(content, expected);\n\n const difference = diff(expected, content);\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toShowInterface')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(content)}` +\n `${difference ? `\\n\\nDifference:\\n\\n${difference}` : ''}`\n : () =>\n `${this.utils.matcherHint('.toShowInterface')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(content)}` +\n `${difference ? `\\n\\nDifference:\\n\\n${difference}` : ''}`;\n\n return { message, pass };\n};\n\nexpect.extend({\n toRespondWith,\n toRespondWithError,\n toSendNotification,\n toRender,\n});\n"],"names":["expect","hasProperty","diff","matcherErrorMessage","matcherHint","printReceived","printWithType","RECEIVED_COLOR","is","InterfaceStruct","SnapResponseStruct","assertActualIsSnapResponse","actual","matcherName","options","Error","undefined","assertHasInterface","content","toRespondWith","expected","response","message","utils","printExpected","error","pass","equals","result","toRespondWithError","toSendNotification","type","notifications","some","notification","toRender","difference","extend"],"mappings":"AAAA,kCAAkC,GAElC,+EAA+E;AAC/E,yEAAyE;AAGzE,SAASA,MAAM,QAAQ,gBAAgB;AAKvC,SAASC,WAAW,QAAQ,kBAAkB;AAE9C,SACEC,IAAI,EACJC,mBAAmB,EACnBC,WAAW,EACXC,aAAa,EACbC,aAAa,EACbC,cAAc,QACT,qBAAqB;AAC5B,SAASC,EAAE,QAAQ,cAAc;AAEjC,SAASC,eAAe,EAAEC,kBAAkB,QAAQ,cAAc;AAGlE;;;;;;CAMC,GACD,SAASC,2BACPC,MAAe,EACfC,WAAmB,EACnBC,OAA4B;IAE5B,IAAI,CAACN,GAAGI,QAAQF,qBAAqB;QACnC,MAAM,IAAIK,MACRZ,oBACEC,YAAYS,aAAaG,WAAWA,WAAWF,UAC/C,CAAC,EAAEP,eACD,YACA,uDAAuD,CAAC,EAC1DD,cAAc,YAAYM,QAAQP;IAGxC;AACF;AAEA;;;;;;;CAOC,GACD,SAASY,mBACPL,MAAe,EACfC,WAAmB,EACnBC,OAA4B;IAE5B,IAA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B,IAAI,CAAC,GACvD,CAAC,UAAU,EAAE,IAAI,CAACmB,KAAK,CAACC,aAAa,CAACJ,UAAU,EAAE,CAAC,GACnD,CAAC,UAAU,EAAE,IAAI,CAACG,KAAK,CAAClB,aAAa,CAACa,SAAS,CAAC,GAChD,CAAC,EAAEkB,aAAa,CAAC,mBAAmB,EAAEA,WAAW,CAAC,GAAG,GAAG,CAAC,GAC3D,IACE,CAAC,EAAE,IAAI,CAACb,KAAK,CAACnB,WAAW,CAAC,oBAAoB,IAAI,CAAC,GACnD,CAAC,UAAU,EAAE,IAAI,CAACmB,KAAK,CAACC,aAAa,CAACJ,UAAU,EAAE,CAAC,GACnD,CAAC,UAAU,EAAE,IAAI,CAACG,KAAK,CAAClB,aAAa,CAACa,SAAS,CAAC,GAChD,CAAC,EAAEkB,aAAa,CAAC,mBAAmB,EAAEA,WAAW,CAAC,GAAG,GAAG,CAAC;IAE/D,OAAO;QAAEd;QAASI;IAAK;AACzB,EAAE;AAEF1B,OAAOqC,MAAM,CAAC;IACZlB;IACAU;IACAC;IACAK;AACF"}
|
package/dist/types/matchers.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import type { MatcherFunction } from '@jest/expect';
|
|
1
2
|
import type { NotificationType } from '@metamask/rpc-methods';
|
|
2
3
|
import type { Component } from '@metamask/snaps-ui';
|
|
3
4
|
import type { EnumToUnion } from '@metamask/snaps-utils';
|
|
4
5
|
import type { Json } from '@metamask/utils';
|
|
5
|
-
import type { MatcherFunction } from 'expect';
|
|
6
6
|
/**
|
|
7
7
|
* Check if a JSON-RPC response matches the expected value. This matcher is
|
|
8
8
|
* intended to be used with the `expect` global.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/snaps-jest",
|
|
3
|
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.4-flask.1",
|
|
4
4
|
"description": "A Jest preset for end-to-end testing MetaMask Snaps, including a Jest environment, and a set of Jest matchers.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"test:ci": "yarn test",
|
|
19
19
|
"lint:eslint": "eslint . --cache --ext js,ts,jsx,tsx",
|
|
20
20
|
"lint:misc": "prettier --no-error-on-unmatched-pattern --loglevel warn \"**/*.json\" \"**/*.md\" \"**/*.html\" \"!CHANGELOG.md\" --ignore-path ../../.gitignore",
|
|
21
|
-
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn lint:changelog",
|
|
21
|
+
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn lint:changelog && yarn lint:dependencies",
|
|
22
22
|
"lint:ci": "yarn lint",
|
|
23
23
|
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
|
|
24
24
|
"lint:changelog": "../../scripts/validate-changelog.sh @metamask/snaps-jest",
|
|
@@ -30,18 +30,18 @@
|
|
|
30
30
|
"build:clean": "yarn clean && yarn build",
|
|
31
31
|
"clean": "rimraf '*.tsbuildinfo' 'dist'",
|
|
32
32
|
"prepare-manifest:preview": "../../scripts/prepare-preview-manifest.sh",
|
|
33
|
-
"publish:preview": "yarn npm publish --tag preview"
|
|
33
|
+
"publish:preview": "yarn npm publish --tag preview",
|
|
34
|
+
"lint:dependencies": "depcheck"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
37
|
"@jest/environment": "^29.5.0",
|
|
37
38
|
"@jest/expect": "^29.5.0",
|
|
38
39
|
"@jest/globals": "^29.5.0",
|
|
39
|
-
"@
|
|
40
|
-
"@metamask/
|
|
41
|
-
"@metamask/snaps-
|
|
42
|
-
"@metamask/snaps-
|
|
43
|
-
"@metamask/snaps-
|
|
44
|
-
"@metamask/snaps-utils": "^0.37.2-flask.1",
|
|
40
|
+
"@metamask/rpc-methods": "^0.38.1-flask.1",
|
|
41
|
+
"@metamask/snaps-execution-environments": "^0.38.2-flask.1",
|
|
42
|
+
"@metamask/snaps-simulator": "^0.38.0-flask.1",
|
|
43
|
+
"@metamask/snaps-ui": "^0.37.4-flask.1",
|
|
44
|
+
"@metamask/snaps-utils": "^0.38.2-flask.1",
|
|
45
45
|
"@metamask/utils": "^6.0.1",
|
|
46
46
|
"express": "^4.18.2",
|
|
47
47
|
"jest-environment-node": "^29.5.0",
|
|
@@ -59,13 +59,14 @@
|
|
|
59
59
|
"@metamask/eslint-config-nodejs": "^12.1.0",
|
|
60
60
|
"@metamask/eslint-config-typescript": "^12.1.0",
|
|
61
61
|
"@swc/cli": "^0.1.62",
|
|
62
|
-
"@swc/core": "
|
|
62
|
+
"@swc/core": "1.3.78",
|
|
63
63
|
"@swc/jest": "^0.2.26",
|
|
64
64
|
"@types/jest": "^27.5.1",
|
|
65
|
-
"@types/semver": "^7.
|
|
65
|
+
"@types/semver": "^7.5.0",
|
|
66
66
|
"@typescript-eslint/eslint-plugin": "^5.42.1",
|
|
67
67
|
"@typescript-eslint/parser": "^5.42.1",
|
|
68
68
|
"deepmerge": "^4.2.2",
|
|
69
|
+
"depcheck": "^1.4.5",
|
|
69
70
|
"eslint": "^8.27.0",
|
|
70
71
|
"eslint-config-prettier": "^8.5.0",
|
|
71
72
|
"eslint-plugin-import": "^2.26.0",
|