2018-08-12 17:02:49 +02:00
|
|
|
let expect = require("chai").expect;
|
2022-06-12 21:49:34 +02:00
|
|
|
let freesewing = require("../dist/index.js");
|
2018-08-12 13:32:53 +02:00
|
|
|
|
2018-08-12 17:02:49 +02:00
|
|
|
let pattern = new freesewing.Pattern();
|
|
|
|
let store = pattern.store;
|
2018-08-12 13:32:53 +02:00
|
|
|
|
|
|
|
it("Store should be a Map", () => {
|
|
|
|
expect(store.data.toString()).to.equal("[object Map]");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should set/get a store value", () => {
|
|
|
|
store.set("foo", "bar");
|
|
|
|
expect(store.get("foo")).to.equal("bar");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should set a store value only if unset", () => {
|
|
|
|
store.setIfUnset("few", "baz");
|
|
|
|
store.setIfUnset("few", "schmoo");
|
|
|
|
expect(store.get("few")).to.equal("baz");
|
|
|
|
});
|
2022-07-30 20:02:42 +02:00
|
|
|
|
|
|
|
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')
|
|
|
|
});
|
|
|
|
|