-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor tests to use snapshots (#1824)
- Loading branch information
1 parent
f3c94f1
commit ae26254
Showing
8 changed files
with
1,562 additions
and
697 deletions.
There are no files selected for viewing
961 changes: 961 additions & 0 deletions
961
packages/cli/src/protocols/ethereum/codegen/__snapshots__/abi.test.ts.snap
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
packages/cli/src/scaffold/__snapshots__/cosmos.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`Cosmos subgraph scaffolding > Manifest 1`] = ` | ||
"specVersion: 1.0.0 | ||
indexerHints: | ||
prune: auto | ||
schema: | ||
file: ./schema.graphql | ||
dataSources: | ||
- kind: cosmos | ||
name: CosmosHub | ||
network: cosmoshub-4 | ||
source: | ||
startBlock: 0 | ||
mapping: | ||
apiVersion: 0.0.5 | ||
language: wasm/assemblyscript | ||
entities: | ||
- ExampleEntity | ||
blockHandlers: | ||
- handler: handleBlock | ||
file: ./src/contract.ts | ||
" | ||
`; | ||
|
||
exports[`Cosmos subgraph scaffolding > Mapping (default) 1`] = ` | ||
"import { cosmos, BigInt } from "@graphprotocol/graph-ts" | ||
import { ExampleEntity } from "../generated/schema" | ||
export function handleBlock(block: cosmos.Block): void { | ||
// Entities can be loaded from the store using a string ID; this ID | ||
// needs to be unique across all entities of the same type | ||
let entity = ExampleEntity.load(block.header.hash.toHex()) | ||
// Entities only exist after they have been saved to the store; | ||
// \`null\` checks allow to create entities on demand | ||
if (!entity) { | ||
entity = new ExampleEntity(block.header.hash.toHex()) | ||
// Entity fields can be set using simple assignments | ||
entity.count = BigInt.fromI32(0) | ||
} | ||
// BigInt and BigDecimal math are supported | ||
entity.count = entity.count + BigInt.fromI32(1) | ||
// Entity fields can be set based on receipt information | ||
entity.height = block.header.height | ||
// Entities can be written to the store with \`.save()\` | ||
entity.save() | ||
// Note: If a handler doesn't require existing field values, it is faster | ||
// _not_ to load the entity from the store. Instead, create it fresh with | ||
// \`new Entity(...)\`, set the fields that should be updated and save the | ||
// entity back to the store. Fields that were not set or unset remain | ||
// unchanged, allowing for partial updates to be applied. | ||
} | ||
" | ||
`; | ||
|
||
exports[`Cosmos subgraph scaffolding > Schema (default) 1`] = ` | ||
"type ExampleEntity @entity { | ||
id: ID! | ||
block: Bytes! | ||
count: BigInt! | ||
} | ||
" | ||
`; |
Oops, something went wrong.