1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00
squid-js/test/ocean/Asset.test.ts

64 lines
1.7 KiB
TypeScript
Raw Normal View History

2018-10-09 15:24:36 +02:00
import * as assert from "assert"
2018-10-16 14:56:18 +02:00
import ConfigProvider from "../../src/ConfigProvider"
2018-10-09 15:24:36 +02:00
import ContractHandler from "../../src/keeper/ContractHandler"
import Account from "../../src/ocean/Account"
import Asset from "../../src/ocean/Asset"
2018-10-16 14:56:18 +02:00
import Ocean from "../../src/ocean/Ocean"
import config from "../config"
2018-10-09 15:24:36 +02:00
2018-10-16 14:56:18 +02:00
const testName = "Test Asset 2"
const testDescription = "This asset is pure owange"
const testPrice = 100
2018-10-09 15:24:36 +02:00
2018-10-16 14:56:18 +02:00
let ocean: Ocean
let testAsset: Asset
let accounts: Account[]
let testPublisher: Account
2018-10-09 15:24:36 +02:00
before(async () => {
2018-10-16 14:56:18 +02:00
ConfigProvider.configure(config)
await ContractHandler.deployContracts()
ocean = await Ocean.getInstance(config)
accounts = await ocean.getAccounts()
testPublisher = accounts[0]
testAsset = new Asset(testName, testDescription, testPrice, testPublisher)
await ocean.register(testAsset)
2018-10-09 15:24:36 +02:00
})
describe("Asset", () => {
2018-10-16 14:56:18 +02:00
describe("#isActive()", () => {
2018-10-09 15:24:36 +02:00
2018-10-16 14:56:18 +02:00
it("should return true on new asset", async () => {
2018-10-09 15:24:36 +02:00
2018-10-16 14:56:18 +02:00
const isAssetActive = await testAsset.isActive()
assert(true === isAssetActive)
})
2018-10-09 15:24:36 +02:00
2018-10-16 14:56:18 +02:00
it("should return false on unknown asset", async () => {
2018-10-09 15:24:36 +02:00
2018-10-16 14:56:18 +02:00
const isAssetActive = await new Asset(testName, testDescription, testPrice, testPublisher)
.isActive()
assert(false === isAssetActive)
2018-10-09 15:24:36 +02:00
})
})
2018-10-16 14:56:18 +02:00
describe("#purchase()", () => {
2018-10-09 15:24:36 +02:00
2018-10-16 14:56:18 +02:00
it("should purchase an asset", async () => {
2018-10-09 15:24:36 +02:00
2018-10-16 14:56:18 +02:00
// todo
await testAsset.purchase(accounts[5], 10000)
2018-10-09 15:24:36 +02:00
})
2018-10-16 14:56:18 +02:00
})
2018-10-09 15:24:36 +02:00
2018-10-16 14:56:18 +02:00
describe("#purchase()", () => {
2018-10-09 15:24:36 +02:00
2018-10-16 14:56:18 +02:00
it("should purchase an asset", async () => {
// todo
// await testAsset.finalizePurchaseAsset()
2018-10-09 15:24:36 +02:00
})
})
})