diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2020-05-02 17:25:56 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-02 17:25:56 +0900 |
commit | 5df0537bcf65a341e79852b1b30379c73318529c (patch) | |
tree | aee5efe52412855f620cb514a13a2c14373f27b7 /test/background/infrastructures | |
parent | 685f2b7b69218b06b5bb676069e35f79c5048c9b (diff) | |
parent | 75abd90ecb8201ad845b266f96220d8adfe19b2d (diff) |
Merge pull request #749 from ueokande/qa-0.28
QA 0.28
Diffstat (limited to 'test/background/infrastructures')
-rw-r--r-- | test/background/infrastructures/MemoryStorage.test.ts | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/test/background/infrastructures/MemoryStorage.test.ts b/test/background/infrastructures/MemoryStorage.test.ts index ccdf9f0..1c67b18 100644 --- a/test/background/infrastructures/MemoryStorage.test.ts +++ b/test/background/infrastructures/MemoryStorage.test.ts @@ -1,44 +1,45 @@ -import MemoryStorage from 'background/infrastructures/MemoryStorage'; +import MemoryStorage from "../../../src/background/infrastructures/MemoryStorage"; +import { expect } from "chai"; describe("background/infrastructures/memory-storage", () => { - it('stores values', () => { + it("stores values", () => { const cache = new MemoryStorage(); - cache.set('number', 123); - expect(cache.get('number')).to.equal(123); + cache.set("number", 123); + expect(cache.get("number")).to.equal(123); - cache.set('string', '123'); - expect(cache.get('string')).to.equal('123'); + cache.set("string", "123"); + expect(cache.get("string")).to.equal("123"); - cache.set('object', { hello: '123' }); - expect(cache.get('object')).to.deep.equal({ hello: '123' }); + cache.set("object", { hello: "123" }); + expect(cache.get("object")).to.deep.equal({ hello: "123" }); }); - it('returns undefined if no keys', () => { + it("returns undefined if no keys", () => { const cache = new MemoryStorage(); - expect(cache.get('no-keys')).to.be.undefined; - }) + expect(cache.get("no-keys")).to.be.undefined; + }); - it('stored on shared memory', () => { + it("stored on shared memory", () => { let cache = new MemoryStorage(); - cache.set('red', 'apple'); + cache.set("red", "apple"); cache = new MemoryStorage(); - const got = cache.get('red'); - expect(got).to.equal('apple'); + const got = cache.get("red"); + expect(got).to.equal("apple"); }); - it('stored cloned objects', () => { + it("stored cloned objects", () => { const cache = new MemoryStorage(); - const recipe = { sugar: '300g' }; - cache.set('recipe', recipe); + const recipe = { sugar: "300g", salt: "10g" }; + cache.set("recipe", recipe); - recipe.salt = '20g' - const got = cache.get('recipe', recipe); - expect(got).to.deep.equal({ sugar: '300g' }); + recipe.salt = "20g"; + const got = cache.get("recipe"); + expect(got).to.deep.equal({ sugar: "300g", salt: "10g" }); }); - it('throws an error with unserializable objects', () => { + it("throws an error with unserializable objects", () => { const cache = new MemoryStorage(); - expect(() => cache.set('fn', setTimeout)).to.throw(); - }) + expect(() => cache.set("fn", setTimeout)).to.throw(); + }); }); |