1
0
Fork 0
freesewing/packages/core/tests/store.test.mjs

32 lines
870 B
JavaScript
Raw Normal View History

2022-08-25 11:47:54 +02:00
import chai from "chai"
import freesewing from "./dist/index.mjs"
const expect = chai.expect
2018-08-12 13:32:53 +02:00
const pattern = new freesewing.Pattern();
const store = pattern.store;
2018-08-12 13:32:53 +02:00
describe('Store', () => {
it("Store should be a Map", () => {
expect(store.data.toString()).to.equal("[object Map]");
});
2018-08-12 13:32:53 +02:00
it("Should set/get a store value", () => {
store.set("foo", "bar");
expect(store.get("foo")).to.equal("bar");
});
2018-08-12 13:32:53 +02:00
it("Should set a store value only if unset", () => {
store.setIfUnset("few", "baz");
store.setIfUnset("few", "schmoo");
expect(store.get("few")).to.equal("baz");
});
it("Should raise a warning when retrieving a invalid key", () => {
store.get('nope')
expect(pattern.events.warning.length).to.equal(1)
expect(pattern.events.warning[0]).to.equal('Tried to access `nope` in the `store` but it is not set')
});
});