117 lines
3.2 KiB
TypeScript
117 lines
3.2 KiB
TypeScript
import {
|
|
assert,
|
|
describe,
|
|
test,
|
|
clearStore,
|
|
beforeAll,
|
|
afterAll
|
|
} from "matchstick-as/assembly/index"
|
|
import { BigInt, Address } from "@graphprotocol/graph-ts"
|
|
import { ExampleEntity } from "../generated/schema"
|
|
import { VideoUploaded } from "../generated/Ourtube/Ourtube"
|
|
import { handleVideoUploaded } from "../src/ourtube"
|
|
import { createVideoUploadedEvent } from "./ourtube-utils"
|
|
|
|
// Tests structure (matchstick-as >=0.5.0)
|
|
// https://thegraph.com/docs/en/developer/matchstick/#tests-structure-0-5-0
|
|
|
|
describe("Describe entity assertions", () => {
|
|
beforeAll(() => {
|
|
let id = BigInt.fromI32(234)
|
|
let hash = "Example string value"
|
|
let title = "Example string value"
|
|
let description = "Example string value"
|
|
let location = "Example string value"
|
|
let category = "Example string value"
|
|
let thumbnailHash = "Example string value"
|
|
let isAudio = "boolean Not implemented"
|
|
let date = "Example string value"
|
|
let author = Address.fromString(
|
|
"0x0000000000000000000000000000000000000001"
|
|
)
|
|
let newVideoUploadedEvent = createVideoUploadedEvent(
|
|
id,
|
|
hash,
|
|
title,
|
|
description,
|
|
location,
|
|
category,
|
|
thumbnailHash,
|
|
isAudio,
|
|
date,
|
|
author
|
|
)
|
|
handleVideoUploaded(newVideoUploadedEvent)
|
|
})
|
|
|
|
afterAll(() => {
|
|
clearStore()
|
|
})
|
|
|
|
// For more test scenarios, see:
|
|
// https://thegraph.com/docs/en/developer/matchstick/#write-a-unit-test
|
|
|
|
test("ExampleEntity created and stored", () => {
|
|
assert.entityCount("ExampleEntity", 1)
|
|
|
|
// 0xa16081f360e3847006db660bae1c6d1b2e17ec2a is the default address used in newMockEvent() function
|
|
assert.fieldEquals(
|
|
"ExampleEntity",
|
|
"0xa16081f360e3847006db660bae1c6d1b2e17ec2a",
|
|
"hash",
|
|
"Example string value"
|
|
)
|
|
assert.fieldEquals(
|
|
"ExampleEntity",
|
|
"0xa16081f360e3847006db660bae1c6d1b2e17ec2a",
|
|
"title",
|
|
"Example string value"
|
|
)
|
|
assert.fieldEquals(
|
|
"ExampleEntity",
|
|
"0xa16081f360e3847006db660bae1c6d1b2e17ec2a",
|
|
"description",
|
|
"Example string value"
|
|
)
|
|
assert.fieldEquals(
|
|
"ExampleEntity",
|
|
"0xa16081f360e3847006db660bae1c6d1b2e17ec2a",
|
|
"location",
|
|
"Example string value"
|
|
)
|
|
assert.fieldEquals(
|
|
"ExampleEntity",
|
|
"0xa16081f360e3847006db660bae1c6d1b2e17ec2a",
|
|
"category",
|
|
"Example string value"
|
|
)
|
|
assert.fieldEquals(
|
|
"ExampleEntity",
|
|
"0xa16081f360e3847006db660bae1c6d1b2e17ec2a",
|
|
"thumbnailHash",
|
|
"Example string value"
|
|
)
|
|
assert.fieldEquals(
|
|
"ExampleEntity",
|
|
"0xa16081f360e3847006db660bae1c6d1b2e17ec2a",
|
|
"isAudio",
|
|
"boolean Not implemented"
|
|
)
|
|
assert.fieldEquals(
|
|
"ExampleEntity",
|
|
"0xa16081f360e3847006db660bae1c6d1b2e17ec2a",
|
|
"date",
|
|
"Example string value"
|
|
)
|
|
assert.fieldEquals(
|
|
"ExampleEntity",
|
|
"0xa16081f360e3847006db660bae1c6d1b2e17ec2a",
|
|
"author",
|
|
"0x0000000000000000000000000000000000000001"
|
|
)
|
|
|
|
// More assert options:
|
|
// https://thegraph.com/docs/en/developer/matchstick/#asserts
|
|
})
|
|
})
|