그래서 매장과 작업에 역류가 사용됩니다. 응용 프로그램 저장소에 두 번 클릭 방지 여부에 대한 플래그를 포함한 일부 응용 프로그램의 광범위한 데이터를 사용할 수 있습니다. 내 테스트 (모카, 차이, 그리고 sinon 사용)과 같이 :플럭스 구조의 테스트 상점
var applicationStore = require('../../../../web/app/components/core/application.store.js');
var initialState = _.clone(applicationStore._internalData, true);
function resetToInitialState() {
applicationStore._internalData = _.clone(initialState, true);
}
chai.use(sinonChai);
describe('application store', function() {
beforeEach(function() {
resetToInitialState();
});
it('should have default data set properly', function() {
expect(applicationStore.getPreventDoubleClick()).to.be.false;
});
it('should be able to enable prevent double click flag', function() {
applicationStore._onEnablePreventDoubleClick();
expect(applicationStore.getPreventDoubleClick()).to.be.true;
});
it('should be able to disable prevent double click flag', function() {
applicationStore._onEnablePreventDoubleClick();
applicationStore._onDisablePreventDoubleClick();
expect(applicationStore.getPreventDoubleClick()).to.be.false;
});
});
모든 상점 싱글 효과적으로 때문에하는 것은, 수동은 beforeEach에 있는지 더 테스트 효과도하지 않습니다하기 위해 테스트 할 수있는 유효한 방법 내부 데이터의 설정하라는한다 다른 것? mocha/chai/sinon을 사용하여 더 좋은 방법이 있습니까?