How to use the san-store.connect.createConnector function in san-store

To help you get started, we’ve selected a few san-store examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github baidu / san-store / test / connect.createConnector.spec.js View on Github external
describe('Connect createConnector component', () => {
    const store = new Store();
    store.addAction('reset-for-connect', () => {
        let resetBuilder = updateBuilder()
            .set('name', 'errorrik')
            .set('emails', ['errorrik@gmail.com']);

        return resetBuilder;
    });

    beforeEach(done => {
        store.dispatch('reset-for-connect');
        setTimeout(done, 1);
    });
    // 手动连接自己声明的store
    const manualConnect = connect.createConnector(store);

    it('data should be ready when component init', () => {
        let MyComponent = manualConnect({
            name: 'name',
            email: 'emails[0]'
        })(san.defineComponent({
            template: '<u title="{{name}}-{{email}}">{{name}}-{{email}}</u>'
        }));

        let myComponent = new MyComponent();
        let wrap = document.createElement('div');
        document.body.appendChild(wrap);
        myComponent.attach(wrap);

        let u = wrap.getElementsByTagName('u')[0];
        expect(u.title).toBe('errorrik-errorrik@gmail.com');

san-store

Application State Management for San

MIT
Latest version published 2 months ago

Package Health Score

76 / 100
Full package analysis