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/OceanSecretStore.test.ts

41 lines
1.1 KiB
TypeScript
Raw Normal View History

2019-02-14 11:26:12 +01:00
import { assert, expect, spy, use } from "chai"
import * as spies from "chai-spies"
import Account from "../../src/ocean/Account"
import { Ocean } from "../../src/ocean/Ocean"
import { OceanSecretStore } from "../../src/ocean/OceanSecretStore"
2019-02-14 11:26:12 +01:00
import config from "../config"
use(spies)
describe("OceanSecretStore", () => {
let oceanSecretStore: OceanSecretStore
let accounts: Account[]
let ocean: Ocean
const did = "a".repeat(64)
2019-02-14 11:26:12 +01:00
before(async () => {
ocean = await Ocean.getInstance(config)
oceanSecretStore = ocean.secretStore
accounts = await ocean.accounts.list()
2019-02-14 11:26:12 +01:00
})
afterEach(() => {
spy.restore()
})
describe("#encrypt()", () => {
it("should encrypt a content", async () => {
const secretStoreEncryptSpy = spy.on(ocean.brizo, "encrypt", () => "encryptedResult")
2019-02-14 11:26:12 +01:00
const result = await oceanSecretStore.encrypt(did, "test", accounts[0])
expect(secretStoreEncryptSpy).to.have.been.called.with(did, "test")
assert.equal(result, "encryptedResult", "Result doesn't match")
})
})
})